CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
GmsList Class Reference

#include <GmsList.h>

Public Member Functions

 GmsList ()
 
virtual ~GmsList ()
 
GmsListLinklast () const
 
GmsListLinkfirst () const
 
unsigned int count () const
 
GmsListappend (GmsListLink *)
 
GmsListprepend (GmsListLink *)
 
GmsListremove (GmsListLink *)
 
GmsListinsertAfter (GmsListLink *link, GmsListLink *insertHere)
 
GmsListmoveAfter (GmsListLink *link, GmsListLink *insertHere)
 
void reset ()
 

Protected Attributes

GmsListLink_first
 
GmsListLink_last
 
unsigned int _count
 

Detailed Description

Definition at line 32 of file GmsList.h.

Constructor & Destructor Documentation

◆ GmsList()

GmsList::GmsList ( )
inline

Definition at line 39 of file GmsList.h.

39{ _first = _last = 0; _count = 0;}
unsigned int _count
Definition: GmsList.h:37
GmsListLink * _last
Definition: GmsList.h:36
GmsListLink * _first
Definition: GmsList.h:35

◆ ~GmsList()

GmsList::~GmsList ( )
virtual

Definition at line 18 of file GmsList.cxx.

18{}

Member Function Documentation

◆ append()

GmsList & GmsList::append ( GmsListLink l)

Definition at line 20 of file GmsList.cxx.

21{ // add an item to the end of a list
22 if ( _last ) {
23 _last->_next = l;
24 l->_prev = _last;
25 }
26 else
27 _first = l;
28
29 _last = l;
30
31 _count++;
32
33 return *this;
34}

Referenced by MdcSegList::append().

◆ count()

unsigned int GmsList::count ( ) const
inline

◆ first()

GmsListLink * GmsList::first ( ) const
inline

◆ insertAfter()

GmsList & GmsList::insertAfter ( GmsListLink link,
GmsListLink insertHere 
)

Definition at line 51 of file GmsList.cxx.

52{ // add an item to the middle of a list
53 GmsListLink *after = 0;
54 if ( here != 0 ) {
55 after = here->_next;
56 here->_next = l;
57 l->_prev = here;
58 }
59 else {
60 after = _first;
61 l->_prev = 0;
62 _first = l;
63 }
64 l->_next = after;
65
66 if (after == 0) {
67 _last = l;
68 }
69 else {
70 after->_prev = l;
71 }
72
73 _count++;
74
75 return *this;
76}

◆ last()

GmsListLink * GmsList::last ( ) const
inline

Definition at line 41 of file GmsList.h.

41{ return _last; }

◆ moveAfter()

GmsList & GmsList::moveAfter ( GmsListLink link,
GmsListLink insertHere 
)

Definition at line 77 of file GmsList.cxx.

78{ // add an item from one place in list to another
79
80 // First remove it from its current position
81 if ( l == _first )
83 if ( l == _last )
84 _last = _last->_prev;
85
86 if ( l->_next ) {
87 l->_next->_prev = l->_prev;
88 }
89 if ( l->_prev ) {
90 l->_prev->_next = l->_next;
91 }
92
93
94 GmsListLink *after = 0;
95 if ( here != 0 ) {
96 after = here->_next;
97 here->_next = l;
98 l->_prev = here;
99 }
100 else {
101 after = _first;
102 l->_prev = 0;
103 _first = l;
104 }
105 l->_next = after;
106
107 if (after == 0) {
108 _last = l;
109 }
110 else {
111 after->_prev = l;
112 }
113
114
115 return *this;
116}

◆ prepend()

GmsList & GmsList::prepend ( GmsListLink l)

Definition at line 36 of file GmsList.cxx.

37{ // add an item to the beginning of a list
38 if ( _first ) {
39 _first->_prev = l;
40 l->_next = _first;
41 }
42 else
43 _last = l;
44
45 _first = l;
46
47 _count++;
48
49 return *this;
50}

◆ remove()

GmsList & GmsList::remove ( GmsListLink l)

Definition at line 118 of file GmsList.cxx.

119{ // remove an item from the list
120 if ( l == _first )
122 if ( l == _last )
123 _last = _last->_prev;
124
125 if ( l->_next ) {
126 l->_next->_prev = l->_prev;
127 }
128 if ( l->_prev ) {
129 l->_prev->_next = l->_next;
130 }
131 l->_next = 0;
132 l->_prev = 0;
133
134 _count--;
135
136 return *this;
137}

Referenced by MdcSegList::destroySegs().

◆ reset()

void GmsList::reset ( )
inline

Definition at line 51 of file GmsList.h.

51{ _first = _last = 0; _count = 0;}

Member Data Documentation

◆ _count

unsigned int GmsList::_count
protected

Definition at line 37 of file GmsList.h.

Referenced by append(), count(), GmsList(), insertAfter(), prepend(), remove(), and reset().

◆ _first

GmsListLink* GmsList::_first
protected

Definition at line 35 of file GmsList.h.

Referenced by append(), first(), GmsList(), insertAfter(), moveAfter(), prepend(), remove(), and reset().

◆ _last

GmsListLink* GmsList::_last
protected

Definition at line 36 of file GmsList.h.

Referenced by append(), GmsList(), insertAfter(), last(), moveAfter(), prepend(), remove(), and reset().


The documentation for this class was generated from the following files: