21 template <
typename TYPE>
22 tlp::BmdList<TYPE>::BmdList():head(0),tail(0),count(0) {
25 template <
typename TYPE>
26 tlp::BmdList<TYPE>::~BmdList() {
30 template <
typename TYPE>
31 tlp::BmdLink<TYPE> *tlp::BmdList<TYPE>::firstItem() {
35 template <
typename TYPE>
36 tlp::BmdLink<TYPE> *tlp::BmdList<TYPE>::lastItem() {
40 template <
typename TYPE>
41 TYPE tlp::BmdList<TYPE>::entry(tlp::BmdLink<TYPE> *it) {
45 template <
typename TYPE>
46 int BmdList<TYPE>::size() {
50 template <
typename TYPE>
51 tlp::BmdLink<TYPE>* BmdList<TYPE>::nextItem(tlp::BmdLink<TYPE> *p, tlp::BmdLink<TYPE> *predP) {
59 if (p->prev() != predP)
68 template <
typename TYPE>
69 tlp::BmdLink<TYPE> *tlp::BmdList<TYPE>::predItem(tlp::BmdLink<TYPE> *p, tlp::BmdLink<TYPE> *succP) {
77 if (p->succ() != succP)
86 template <
typename TYPE>
87 tlp::BmdLink<TYPE> *tlp::BmdList<TYPE>::cyclicPred(tlp::BmdLink<TYPE> *it, tlp::BmdLink<TYPE> *succIt) {
97 return predItem(it, succIt);
100 template <
typename TYPE>
101 tlp::BmdLink<TYPE> *tlp::BmdList<TYPE>::cyclicSucc(tlp::BmdLink<TYPE> *it, tlp::BmdLink<TYPE> *predIt) {
111 return nextItem(it, predIt);
114 template <
typename TYPE>
115 tlp::BmdLink<TYPE> *tlp::BmdList<TYPE>::push(
const TYPE &data) {
119 if (head->suc != NULL)
120 head = head->pre =
new tlp::BmdLink<TYPE>(data, NULL, head);
122 head = head->suc =
new tlp::BmdLink<TYPE>(data, NULL, head);
125 head = tail =
new tlp::BmdLink<TYPE>(data, NULL, NULL);
130 template <
typename TYPE>
131 tlp::BmdLink<TYPE> *tlp::BmdList<TYPE>::append(
const TYPE &data) {
135 if (tail->pre != NULL)
136 tail = tail->suc =
new tlp::BmdLink<TYPE>(data, tail, NULL);
138 tail = tail->pre =
new tlp::BmdLink<TYPE>(data, tail, NULL);
142 tail = head =
new tlp::BmdLink<TYPE>(data, NULL, NULL);
148 template <
typename TYPE>
149 TYPE tlp::BmdList<TYPE>::delItem(tlp::BmdLink<TYPE> *it) {
158 tlp::BmdLink<TYPE> *p = predItem(it, NULL);
159 tlp::BmdLink<TYPE> *s = nextItem(it, p);
177 template <
typename TYPE>
178 TYPE tlp::BmdList<TYPE>::pop() {
179 assert(head != NULL);
180 tlp::BmdLink<TYPE> *x = head;
181 head = nextItem(head, NULL);
198 template <
typename TYPE>
199 TYPE tlp::BmdList<TYPE>::popBack() {
200 assert(head != NULL);
201 tlp::BmdLink<TYPE> *x= tail;
202 tail = predItem(tail, NULL);
219 template <
typename TYPE>
220 void tlp::BmdList<TYPE>::reverse() {
221 tlp::BmdLink<TYPE> *x = head;
226 template <
typename TYPE>
227 void tlp::BmdList<TYPE>::conc(tlp::BmdList<TYPE> &l) {
233 if (tail->pre == NULL)
239 if (l.head->suc == NULL)
249 l.head = l.tail = NULL;
253 template <
typename TYPE>
254 void tlp::BmdList<TYPE>::clear() {
255 if (head == NULL)
return;
257 tlp::BmdLink<TYPE> *it = head;
258 tlp::BmdLink<TYPE> *p = head;
260 for (
int i = 0 ; i < count ; i++) {
261 tlp::BmdLink<TYPE> *x = it;
262 it = nextItem(it, p);
275 template <
typename TYPE>
276 void tlp::BmdList<TYPE>::swap(tlp::BmdList<TYPE>& l) {
277 tlp::BmdLink<TYPE> *tmp;