casacore
List.h
Go to the documentation of this file.
1 //# List.h: Doubly linked list classes
2 //# Copyright (C) 1993,1994,1995,1996,1997,1998,1999,2000,2001
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef CASA_LIST_H
29 #define CASA_LIST_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/casa/Utilities/Register.h>
35 #include <casacore/casa/Utilities/Notice.h>
36 #include <casacore/casa/Containers/Link.h>
37 #include <casacore/casa/Utilities/Assert.h>
38 #include <casacore/casa/Containers/IterError.h>
39 
40 namespace casacore { //#Begin casa namespace
41 
42 // The function which throws an exception for advancing the internal
43 // cursor past the end of a list
48 
49 //# Forward Declarations
50 template<class t> class ListIter;
51 template<class t> class ConstListIter;
52 template<class t> class List;
53 
54 
55 //
56 // <summary>Linked list update notice</summary>
57 // <use visibility=local>
58 //
59 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
60 // </reviewed>
61 //
62 // <synopsis>
63 // This class is the notification which is passed between <src>List<t></src>
64 // and <src>ListIter<t></src> in order to keep cursors and container in sync.
65 // This is the mechanism which allows multiple iterators to view the same
66 // list and automatically update as the list is changed. See the
67 // <linkto class=Notice:description>Notice</linkto> class for more information.
68 // </synopsis>
69 //
70 template<class t> class ListNotice : public Notice {
71 friend class ConstListIter<t>;
72 friend class ListIter<t>;
73 friend class List<t>;
74 public:
76  //
77  // This function returns the Notice "type", which is retrieved
78  // from the "type registry". The registry information is maintained
79  // automatically by the Notice constructors. A form of run
80  // time type information, this function is mostly intended for advanced
81  // users.
82  //
83  uInt type() const;
84 
85  //
86  // This operator can be used to compare two
87  // ListNotices.
88  //
89  int operator==(const Notice &op) const;
90 
91 private:
97  int off;
98  int otherOff;
99 
100  //
101  // This is used to construct a list notice. The parameters are:
102  // <ul>
103  // <li> (m) what was done to the list
104  // <li> (oc) the old current position
105  // <li> (op) the old previous position
106  // <li> (nc) the new current position
107  // <li> (np) the new previous position
108  // <li> (of) current offset;
109  // <li> (nf) other offset (only used with SWAP mod)
110  // </ul>
111  //
112  ListNotice(modification m, Link<t> *oc,Link<t> *op,Link<t> *nc,Link<t> *np, int of, int nf=0) :
113  mod(m),oprev(op),ocur(oc),nprev(np),ncur(nc), off(of), otherOff(nf) {}
114 
115  //
116  // This constructor is used to initialize a notice for a deleted
117  // "List".
118  //
119  ListNotice() : mod(DELETE), oprev(0),ocur(0),
120  nprev(0),ncur(0),off(0),otherOff(0) {}
121 
122 };
123 
124 //
125 // <summary>Doubly linked list</summary>
126 // <use visibility=export>
127 //
128 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
129 // </reviewed>
130 //
131 // <synopsis>
132 // This class is a container which by itself has little functionality
133 // because the iteration functionality is contained in the iterator
134 // classes, <linkto class=ListIter>ListIter</linkto> and
135 // <linkto class=ConstListIter>ConstListIterr</linkto>. These iterator
136 // classes allow traversal, insertion into list, and removal from the list.
137 //
138 // This group of classes, List and iterators, was designed to allow
139 // multiple iterators to manipulate a list at the same time. However,
140 // if only one iterator is required the <a href=#simple_example>simple
141 // example</a> below shows how a simple list can be created and used
142 // without complication. The <a href=#complete_example>more complete
143 // example</a> below demonstrates all of the functionality of the List
144 // classes.
145 // </synopsis>
146 //
147 // <anchor name=simple_example>
148 // <example>
149 // <srcblock>
150 // #include <casacore/casa/Containers/List.h>
151 // #include <casacore/casa/Containers/ListIO.h>
152 //
153 // main() {
154 // // List, conceptual
155 // // cursor = "|"
156 // ListIter<int> list(new List<int>(),True); // |
157 // list.addRight(12); // | 12
158 // list.addRight(2); // | 2 12
159 // list.addRight(89); // | 89 2 12
160 // list++; // 89 | 2 12
161 // list.addRight(10); // 89 | 10 2 12
162 // list++; // 89 10 | 2 12
163 // list.addRight(8); // 89 10 | 8 2 12
164 // list--; // 89 | 10 8 2 12
165 // list.pos(0); // | 89 10 8 2 12
166 // list.pos(5); // 89 10 8 2 12 |
167 // list.pos(4); // 89 10 8 2 | 12
168 // list.step(3); // 89 | 10 8 2 12
169 // list.step(); // 89 10 | 8 2 12
170 // list.step(-4); // 89 10 8 2 | 12
171 // list.removeRight(); // 89 10 8 2 |
172 // cout << list << endl;
173 // return 0;
174 // }
175 // </srcblock>
176 // <em>The output from this example looks like:</em>
177 // <pre>
178 // len=4 pos=4 89 10 8 2
179 // </pre>
180 // </example>
181 // </anchor>
182 //
183 template<class t> class List : public NoticeSource
184 {
185 friend class ConstListIter<t>;
186 friend class ListIter<t>;
187 public:
188  //
189  // Creates an empty list.
190  //
191  List() : head(0), tail(0), length(0){}
192  //
193  // Copy Semantics
194  // <group>
195  List(const List<t> &other);
196  List(const List<t> *other);
197  List<t> &operator=(const List<t> &other);
198  List<t> &operator=(const List<t> *other);
199  // </group>
200 
201  //*display 4
202  //
203  // Destructs the list.
204  //
205  ~List();
206 
207  //
208  // Returns the length of the list.
209  //
210  uInt len() const {return length;}
211 
212  //
213  // List version
214  //
215  enum {ListVersion = 2};
216 
217 protected:
221 
222  //
223  // Updates the extreme pointers, head or tail
224  // under the appropriate conditions
225  //
226  // <group>
227  virtual void added(Link<t> *, Link<t> *);
228  virtual void removed(Link<t> *, Link<t> *, Link<t> *);
229  // </group>
230 };
231 
232 
233 //
234 // <summary>Doubly linked constant list iterator</summary>
235 //
236 // <synopsis>
237 // The <linkto class=List>List</linkto> class above only provides for
238 // the list framework. This is one of two classes which allow list
239 // iteration, insertion, and removal. This class <em>cannot</em> be
240 // used to modify a list, but rather, it can only be used to look at
241 // or observe a list. It provides <em>no</em> functions for modifying
242 // the list.
243 //
244 // All of the operations take place to the right of a conceptual cursor.
245 // The cursor starts out before the first element of the list and can
246 // be incremented past the last element of the list. Going further than
247 // the end of the list results in an exception.
248 //
249 // <example>
250 // In this example, assume that this function is called at the
251 // end of the <a href=#simple_example>example above</a>, i.e.
252 // assume that the line before the return,
253 // <a href=#simple_example>above</a>, is uncommented.
254 //
255 // <srcblock>
256 // void iterate(ListIter<int> &list) {
257 // // List, conceptual
258 // // cursor = "|"
259 // ConstListIter<int> li = list; // 89 10 8 2 |
260 // li--; // 89 10 8 | 2
261 // cout << li.getRight() << " "; // 89 10 8 | 2
262 // li--; // 89 10 | 8 2
263 // li.pos(0); // | 89 10 8 2
264 // li.pos(3); // 89 10 8 | 2
265 // li.pos(1); // 89 | 10 8 2
266 // li.step(); // 89 10 | 8 2
267 // li.pos(0); // | 89 10 8 2
268 // li.step(-3); // 89 10 | 8 2
269 // cout << li.getRight() << endl; // 89 10 | 8 2
270 // cout << li << endl; // 89 10 | 8 2
271 // }
272 // </srcblock>
273 // The output which this function, <src>iterate()</src>, would
274 // produce would look like:
275 // <pre>
276 // 2 8
277 // len=4 pos=2 89 10 8 2
278 // </pre>
279 //
280 // As shown above:
281 // <dl>
282 // <dt> <src>pos()</src>
283 // <dd> allows for arbitrary positioning of the cursor
284 // <dt> <src>step()</src>, <src>operator++()</src>, and <src>operator--()</src>
285 // <dd> allow for relative positioning
286 // <dt> <src>getRight()</src>
287 // <dd> fetches the next element in the list.
288 // </dl>
289 // In addition:
290 // <dl>
291 // <dt> <src>atStart()</src>, <src>atEnd()</src>, and <src>pos()</src>
292 // <dd> allow querying the position of the cursor
293 // <dt> <src>len()</src>
294 // <dd> returns the number of elements in the list.
295 // </dl>
296 // </example>
297 //
298 // <note role=tip> This class uses the <linkto class=Notice>Notice
299 // classes</linkto> to implement "dynamic" cursors so that
300 // multiple cursors are updated as elements are added and
301 // removed from the list.
302 // </note>
303 //
304 template<class t> class ConstListIter : public NoticeTarget
305 {
306 public:
307 
308  //
309  // This constructor creates a "ConstListIter" which tracks the
310  // "List<t>" parameter.
311  //
312  // <group>
313  ConstListIter(const List<t> *st);
315  cur(st.head), prev(0), curPos(0),
316  container_((List<t> *) (&st))
317  {}
318  // </group>
319 
320  //
321  // This constructor creates a "ConstListIter" which tracks the
322  // same list tracked by the "ConstListIter<t>" parameter.
323  //
324  // <group>
326  NoticeTarget((NoticeTarget &)other),
327  cur(other.cur), prev(other.prev), curPos(other.curPos),
328  container_(other.container_) {}
329 
330  ConstListIter(const ConstListIter<t> *other);
331  // </group>
332 
333 
334  //
335  // This is the default constructor. It allows one
336  // to create an initially invalid empty ConstListIter. The instantiated
337  // class will accept assignment and thus become valid later.
338  //
339  ConstListIter() : NoticeTarget(),cur(0), prev(0), curPos(0),
340  container_(0) {}
341 
342  //*display 4
343  //
344  // Destructor doesn\'t do anything special because
345  // all of the "real" information is in the "List<t>".
346  //
347  ~ConstListIter();
348 
349  //*display 4
350  //
351  // This function is the hook through which iterators
352  // are notified of important changes to the underlying
353  // list. For advanced users.
354  //
355  void notify(const Notice &);
356 
357  //
358  // This functions allows one to checked if the cursor
359  // is at an extreme list position. "atStart()" checks
360  // to see if the cursor is at the beginning of the list,
361  // and "atEnd()" checks to see if the cursor is at the
362  // end of the list.
363  //
364  // <group>
365  Bool atStart() const {
366  AlwaysAssert(isValid(),InvalidIterError);
367  if (prev == 0) return True;
368  else return False;}
369 
370  Bool atEnd() const {
371  AlwaysAssert(isValid(),InvalidIterError);
372  if (cur == 0) return True;
373  else return False;}
374  // </group>
375 
376  //
377  // This function is used to step the cursor forward through
378  // the list.
379  //
380  // <group>
381  void operator++() {
382  AlwaysAssert(isValid(),InvalidIterError);
383  if (cur) {
384  curPos++;
385  prev = cur;
386  cur = (*cur).next();
387  } else throw_list_end_error();}
388 
389  inline void operator++(int) {
390  AlwaysAssert(isValid(),InvalidIterError);
391  if (cur != 0) {
392  curPos++;
393  prev = cur;
394  cur = (*cur).next();
395  } else throw_list_end_error();}
396  // </group>
397 
398  //
399  // This function allow for stepping the cursor toward the
400  // front of the list.
401  //
402  // <group>
403  void operator--() {
404  if (prev) {
405  curPos--;
406  cur = prev;
407  prev = (*prev).prev();
408  } else throw_list_start_error();}
409 
410  void operator--(int) {
411  if (prev) {
412  curPos--;
413  cur = prev;
414  prev = (*prev).prev();
415  } else throw_list_start_error();}
416  // </group>
417 
418  //
419  // "pos()" without arguments returns the current postion
420  // of the cursor.
421  // "pos()" with an unsigned integer parameter
422  // moves the cursor to an absolute position.
423  //
424  // <group>
425  virtual uInt pos(uInt);
426 
427  uInt pos() const {
428  AlwaysAssert(isValid(),InvalidIterError);
429  return curPos;}
430  // </group>
431 
432  //
433  // This function returns the number of elements in the list.
434  //
435  uInt len() const {
436  AlwaysAssert(isValid(),InvalidIterError);
437  return (*container_).length;}
438 
439  //
440  // "step()" with no parameters advances the cursor forward
441  // one element.
442  // "step()" with a signed integer parameter moves the cursor
443  // (forward or backward) by a relative offset indicated by the
444  // parameter.
445  //
446  // <group>
447  inline uInt step(Int offset){
448  Int toffset;
449  AlwaysAssert(isValid(),InvalidIterError);
450  //# Traps a negative offset because aparently some compilers
451  //# do not handle modulo of a negative number correctly.
452  toffset = offset < 0 && -offset > Int(curPos) ? -((- curPos - offset) % ((*container_).length + 1))
453  : (curPos + offset) % ((*container_).length + 1);
454  return(pos(toffset >= 0 ? toffset : (*container_).length + toffset + 1));}
455 
456  inline uInt step() {return(step(1));}
457  // </group>
458 
459  //
460  // Returns the element to the right of the cursor.
461  //
462  const t &getRight() const {
463  AlwaysAssert(isValid(),InvalidIterError);
464  if (!cur) throw_list_end_error();
465  return((*cur).val());}
466 
467  //
468  // This assignment operator substitutes the "List<t>"
469  // tracked by this iterator to the "List<t>" passed as an argument.
470  //
471  // <group>
472  virtual ConstListIter<t> &operator=(const List<t> &other);
473  virtual ConstListIter<t> &operator=(const List<t> *other);
474  // </group>
475 
476  //
477  // This assignment operator substitutes the "List<t>"
478  // tracked by this iterator to the "List<t>" tracked by the
479  // passed "ConstListIter<t>" argument.
480  //
481  // <group>
482  virtual ConstListIter<t> &operator=(const ConstListIter<t> &other);
483  virtual ConstListIter<t> &operator=(const ConstListIter<t> *other);
484  // </group>
485 
486  //
487  // This function moves the cursor to the beginning of the list.
488  //
489  void toStart() {
490  AlwaysAssert(isValid(),InvalidIterError);
491  cur = (*container_).head; prev = 0; curPos = 0;}
492 
493  //
494  // This function moves the cursor to the end of the list.
495  //
496  void toEnd() {
497  AlwaysAssert(isValid(),InvalidIterError);
498  prev = (*container_).tail;
499  cur = 0;
500  curPos = (*container_).length;
501  }
502 
503  //
504  // Get the container over which we are iterating, could be null...
505  //
506  const List<t> *container() const {return container_;}
507 
508  // enum outside class because of compiler errors on HPUX
509  //enum {ConstListIterVersion = 1};
510 
511 protected:
512 
517 };
518 
519 //
520 // <summary>Doubly linked non-constant list iterator</summary>
521 //
522 // The <linkto class=List>List</linkto> class above only provides for
523 // the list framework. This is one of two classes which allow list
524 // iteration, insertion, and removal. This class <em>can</em> be
525 // used to modify a list. Unlike
526 // <linkto class=ConstListIter>ConstListIter</linkto>, this class can
527 // insert and remove elements from a list as well as look at
528 // or observe a list. <linkto class=ConstListIter>ConstListIter</linkto>
529 // should be used whenever the list is not modified.
530 //
531 // All of the operations take place to the right of a conceptual cursor.
532 // The cursor starts out before the first element of the list and can
533 // be incremented past the last element of the list. Going further than
534 // the end of the list results in an exception. All additions and deletions
535 // occur to the right of this conceptual cursor. In addition, this class
536 // uses the <linkto class=Notice>Notice</linkto> class to ensure that multiple
537 // iterators which are observing the same list are updated as the list
538 // changes. This is important when multiple iterators are used.
539 //
540 // <anchor name=complete_example>
541 // <example>
542 // <srcblock>
543 // #include <casacore/casa/Containers/List.h>
544 // #include <casacore/casa/Containers/ListIO.h>
545 //
546 // main() {
547 // // The conceptual cursors are:
548 // // | for one
549 // // ^ for two
550 // // _ for three
551 // ListIter<int> one(new List<int>,True);
552 // ListIter<int> three, two = one;
553 // one.addRight(12); // |^ 12
554 // one.addRight(2); // |^ 2 12
555 // one.addRight(89); // |^ 89 2 12
556 // cout << one.getRight() << " "
557 // << two.getRight() << endl;
558 // two.addRight(21); // |^ 21 89 2 12
559 // cout << one.getRight() << " "
560 // << two.getRight() << endl;
561 // one++; two++; two++; // 21 | 89 ^ 2 12
562 // three = one; // 21 |_ 89 ^ 2 12
563 // one.removeRight(); // 21 |^_ 2 12
564 // cout << one.getRight() << " "
565 // << two.getRight() << " "
566 // << three.getRight() << endl;
567 // three.addRight(17); // 21 |^_ 17 2 12
568 //
569 // cout << one.getRight() << " "
570 // << two.getRight() << " "
571 // << three.getRight() << endl;
572 //
573 // one.toEnd(); // 21 ^_ 17 2 12 |
574 // one.addRight(18); // 21 ^_ 17 2 12 | 18
575 // two.pos(3); // 21 _ 17 2 ^ 12 | 18
576 // three--; // _ 21 17 2 ^ 12 | 18
577 // two.step(); // _ 21 17 2 12 ^| 18
578 // one.step(4); // _ 21 17 | 2 12 ^ 18
579 // cout << "one: " << one << endl;
580 // cout << "two: " << two << endl;
581 // cout << "three: " << three << endl;
582 //
583 // return 0;
584 // }
585 // </srcblock>
586 // The output from this example would look like:
587 // <pre>
588 // 89 89
589 // 21 21
590 // 2 2 2
591 // 17 2 17
592 // one: len=5 pos=2 21 17 2 12 18
593 // two: len=5 pos=4 21 17 2 12 18
594 // three: len=5 pos=0 21 17 2 12 18
595 // </pre>
596 // </example>
597 // </anchor>
598 //
599 // <note role=tip> This class uses the "Notice" classes to implement "dynamic" cursors
600 // so that multiple cursors are updated as elements are added and
601 // removed from the list.
602 // </note>
603 //
604 template<class t> class ListIter : virtual public ConstListIter<t> {
605 public:
606 
607  //
608  // This constructor allows one to construct a ListIter and
609  // attach it to the List parameter. The own flag can be
610  // set to indicate that the List should be destroyed when
611  // the ListIter is deleted.
612  //
613  ListIter(List<t> *st, Bool OWN = False) : ConstListIter<t>(st), own(OWN){}
614 
615 
616  //
617  // This constructor allows one to construct a ListIter and
618  // attach it to the List parameter.
619  //
620  ListIter(List<t> &st);
621 
622  //
623  // These constructors allow for the creation of a ListIter from
624  // another ListIter. This will attach this ListIter to the List
625  // tracked by the ListIter parameter at the time of construction.
626  //
627  // <group>
628  ListIter(const ListIter<t> &other);
629  ListIter(const ListIter<t> *other) : ConstListIter<t>(other), own(False){}
630  // </group>
631 
632  //
633  // This is the default constructor. It allows one
634  // to create an initially invalid empty ListIter. The instantiated
635  // class will accept assignment and thus become valid later.
636  //
637  ListIter() : ConstListIter<t>(), own(False){}
638 
639 
640  //
641  // This function adds the element to the right of the
642  // current cursor position.
643  //
644  void addRight(t e) {
645  AlwaysAssert(this->isValid(),InvalidIterError);
646  Link<t> *c = this->cur;
647  Link<t> *p = this->prev;
648  this->cur = newLink(e,this->prev,this->cur);
649  // Allow container to update
650  (*this->container_).added(this->prev,this->cur);
651  ListNotice<t> state(ListNotice<t>::ADD,c,p,this->cur,this->prev,
652  this->curPos);
653  (*this->container_).notify(state);
654  }
655 
656  //
657  // This function removes the element to the right of the
658  // current cursor position.
659  //
660  void removeRight();
661 
662  //
663  // This function swaps the list section after the
664  // current position of the list with the right section
665  // of the list of another iterator. This can be
666  // particularly useful for "remembering" the position
667  // of a cursor in a list.
668  //
669  virtual void swapRight(ListIter<t> &);
670 
671 
672  //
673  // Returns the element to the right of the cursor.
674  //
675  // <group>
676  t &getRight() {
677  AlwaysAssert(this->isValid(),InvalidIterError);
678  if (!this->cur) throw_list_end_error();
679  return((*this->cur).val());}
680 
681  const t &getRight() const { return(ConstListIter<t>::getRight());}
682  // </group>
683 
684  //
685  // This function changes the List
686  // which this ListIter tracks and specifies that the List
687  // should be deleted when this iterator is deleted.
688  //
689  virtual ListIter<t> &assign(List<t> *other,Bool OWN = False);
690 
691  //
692  // This assignment operator changes the List which this
693  // iterator tracks to the List parameter.
694  //
695  // <group>
696  virtual ListIter<t> &operator=(List<t> &other);
697 
698  virtual ListIter<t> &operator=(List<t> *other);
699  // </group>
700 
701  //
702  // These assignment operators allow one to change the List
703  // to which this iterator tracks to the List currently associated
704  // with the argument ListIter.
705  //
706  // <group>
707  virtual ListIter<t> &operator=(const ListIter<t> &other);
708 
709  virtual ListIter<t> &operator=(const ListIter<t> *other);
710  // </group>
711 
712  ~ListIter();
713 
714 //# **Seems to cause an internal compiler error on Sun's
715 //# **Cfront compiler. Remove when really need or compiler
716 //# **recovers from brain damage (Thu May 4 13:08:21 EDT 1995).
717 //#
718 //# enum {ListIterVersion = 1};
719 
720 protected:
721  //
722  // Indicates if this iterator "owns" the container it observes.
723  //
725 
726  //*display 1
727  //
728  // This function creates a new link. By separating link
729  // creation out into "newLink", the "addRight(t)"
730  // functionality can be performed in the base class.
731  //
732  virtual Link<t> *newLink(t &e, Link<t> *p=0, Link<t> *n=0);
733 
734 private:
735 
736  //*display 6
737  //
738  // These functions are for internal use. They ONLY throw an exception
739  // to prevent improper initialization of a constant OrderedMapIter.
740  //
741  // <group>
746  // </group>
747 };
748 
749 // enum outside class because of compiler errors on HPUX
751 
752 } //#End casa namespace
753 #ifndef CASACORE_NO_AUTO_TEMPLATES
754 #include <casacore/casa/Containers/List.tcc>
755 #endif //# CASACORE_NO_AUTO_TEMPLATES
756 #endif
t & getRight()
Returns the element to the right of the cursor.
Definition: List.h:676
int Int
Definition: aipstype.h:47
ConstListIter(const ConstListIter< t > &other)
This constructor creates a "ConstListIter" which tracks the same list tracked by the "ConstListIter<t...
Definition: List.h:325
abstract base class for notice receptors
Definition: Notice.h:153
ListIter(List< t > *st, Bool OWN=False)
This constructor allows one to construct a ListIter and attach it to the List parameter.
Definition: List.h:613
Link< t > * cur
enum outside class because of compiler errors on HPUX enum {ConstListIterVersion = 1}; ...
Definition: List.h:513
uInt len() const
This function returns the number of elements in the list.
Definition: List.h:435
void operator--()
This function allow for stepping the cursor toward the front of the list.
Definition: List.h:403
int operator==(const Notice &op) const
This operator can be used to compare two ListNotices.
ListNotice(modification m, Link< t > *oc, Link< t > *op, Link< t > *nc, Link< t > *np, int of, int nf=0)
This is used to construct a list notice.
Definition: List.h:112
ListNotice()
This constructor is used to initialize a notice for a deleted "List".
Definition: List.h:119
PtrHolder< T > & operator=(const PtrHolder< T > &other)
List()
Creates an empty list.
Definition: List.h:191
Doubly linked constant list iterator.
Definition: List.h:51
Bool atEnd() const
Definition: List.h:370
Link< t > * oprev
Definition: List.h:93
List< t > * container_
Definition: List.h:516
void throw_list_init_error()
const List< t > * container() const
Get the container over which we are iterating, could be null...
Definition: List.h:506
base class for notice originators
Definition: Notice.h:102
void throw_list_swapright_same_error()
Link< t > * nprev
Definition: List.h:95
Doubly linked list.
Definition: List.h:52
Link< t > * ncur
Definition: List.h:96
void toEnd()
This function moves the cursor to the end of the list.
Definition: List.h:496
uInt step(Int offset)
"step()" with no parameters advances the cursor forward one element.
Definition: List.h:447
uInt pos() const
Definition: List.h:427
Bool atStart() const
This functions allows one to checked if the cursor is at an extreme list position.
Definition: List.h:365
modification mod
Definition: List.h:92
const t & getRight() const
Returns the element to the right of the cursor.
Definition: List.h:462
uInt length
Definition: List.h:220
LatticeExprNode length(const LatticeExprNode &expr, const LatticeExprNode &axis)
2-argument function to get the length of an axis.
Link< t > * tail
Definition: List.h:219
Link< t > * head
Definition: List.h:218
#define AlwaysAssert(expr, exception)
These marcos are provided for use instead of simply using the constructors of assert_ to allow additi...
Definition: Assert.h:157
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:39
abstract base class for notices
Definition: Notice.h:62
Linked list update notice.
Definition: List.h:70
ConstListIter()
This is the default constructor.
Definition: List.h:339
const Bool False
Definition: aipstype.h:41
ConstListIter(const List< t > &st)
Definition: List.h:314
void addRight(t e)
This function adds the element to the right of the current cursor position.
Definition: List.h:644
void operator++()
This function is used to step the cursor forward through the list.
Definition: List.h:381
uInt len() const
Returns the length of the list.
Definition: List.h:210
ListIter(const ListIter< t > *other)
Definition: List.h:629
void operator++(int)
Definition: List.h:389
Link< t > * ocur
Definition: List.h:94
const Double e
e and functions thereof:
void throw_list_end_error()
The function which throws an exception for advancing the internal cursor past the end of a list...
uInt type() const
This function returns the Notice "type", which is retrieved from the "type registry".
Doubly linked non-constant list iterator The List class above only provides for the list framework...
Definition: List.h:50
const Double c
Fundamental physical constants (SI units):
Bool own
Indicates if this iterator "owns" the container it observes.
Definition: List.h:724
Link< t > * prev
Definition: List.h:514
void toStart()
This function moves the cursor to the beginning of the list.
Definition: List.h:489
void operator--(int)
Definition: List.h:410
const Bool True
Definition: aipstype.h:40
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:48
const t & getRight() const
Definition: List.h:681
void throw_list_start_error()
ListIter()
This is the default constructor.
Definition: List.h:637
Invalide iteration error class.
Definition: IterError.h:71