CGEM BOSS
6.6.5.i
BESIII Offline Software System
Loading...
Searching...
No Matches
GmsList.cxx
Go to the documentation of this file.
1
// File: GmsList.cc
2
// Authors: Alan Breakstone, Gary Word
3
4
/* This class is derived from a similar class in "A C++ Toolkit",
5
which is Copyright 1991 by Jonathan S. Shapiro, and is used
6
with permission. "A C++ Toolkit" is published by Prentice Hall, Inc. */
7
8
// Contents ----------------------------------------------------------
9
//
10
// GmsList::append( GmsListLink *l )
11
// GmsList::prepend( GmsListLink *l )
12
// GmsList::remove( GmsListLink *l )
13
//
14
// End ---------------------------------------------------------------
15
16
#include "
MdcTrkRecon/GmsList.h
"
17
18
GmsList::~GmsList
() {}
19
20
GmsList
&
GmsList::append
(
GmsListLink
*l )
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
}
35
36
GmsList
&
GmsList::prepend
(
GmsListLink
*l )
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
}
51
GmsList
&
GmsList::insertAfter
(
GmsListLink
*l,
GmsListLink
*here )
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
}
77
GmsList
&
GmsList::moveAfter
(
GmsListLink
*l,
GmsListLink
*here )
78
{
// add an item from one place in list to another
79
80
// First remove it from its current position
81
if
( l ==
_first
)
82
_first
=
_first
->
_next
;
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
}
117
118
GmsList
&
GmsList::remove
(
GmsListLink
*l )
119
{
// remove an item from the list
120
if
( l ==
_first
)
121
_first
=
_first
->
_next
;
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
}
GmsList.h
GmsListLink
Definition
GmsListLink.h:30
GmsListLink::_prev
GmsListLink * _prev
Definition
GmsListLink.h:34
GmsListLink::_next
GmsListLink * _next
Definition
GmsListLink.h:33
GmsList
Definition
GmsList.h:33
GmsList::~GmsList
virtual ~GmsList()
Definition
GmsList.cxx:18
GmsList::moveAfter
GmsList & moveAfter(GmsListLink *link, GmsListLink *insertHere)
Definition
GmsList.cxx:77
GmsList::prepend
GmsList & prepend(GmsListLink *)
Definition
GmsList.cxx:36
GmsList::append
GmsList & append(GmsListLink *)
Definition
GmsList.cxx:20
GmsList::insertAfter
GmsList & insertAfter(GmsListLink *link, GmsListLink *insertHere)
Definition
GmsList.cxx:51
GmsList::_count
unsigned int _count
Definition
GmsList.h:37
GmsList::_last
GmsListLink * _last
Definition
GmsList.h:36
GmsList::remove
GmsList & remove(GmsListLink *)
Definition
GmsList.cxx:118
GmsList::_first
GmsListLink * _first
Definition
GmsList.h:35
6.6.5.i
Reconstruction
MdcPatRec
MdcTrkRecon
MdcTrkRecon-00-03-49
src
GmsList.cxx
Generated by
1.12.0