casacore::ListIter< t > Class Template Reference
Doubly linked non-constant list iterator The List class above only provides for the list framework.
More...
#include <List.h>
List of all members.
Detailed Description
template<class t>
class casacore::ListIter< t >
Doubly linked non-constant list iterator The List class above only provides for the list framework.
This is one of two classes which allow list iteration, insertion, and removal. This class can be used to modify a list. Unlike ConstListIter , this class can insert and remove elements from a list as well as look at or observe a list. ConstListIter should be used whenever the list is not modified.
All of the operations take place to the right of a conceptual cursor. The cursor starts out before the first element of the list and can be incremented past the last element of the list. Going further than the end of the list results in an exception. All additions and deletions occur to the right of this conceptual cursor. In addition, this class uses the Notice class to ensure that multiple iterators which are observing the same list are updated as the list changes. This is important when multiple iterators are used.
Example
#include <casacore/casa/Containers/List.h>
#include <casacore/casa/Containers/ListIO.h>
main() {
ListIter<int> one(new List<int>,True);
ListIter<int> three, two = one;
one.addRight(12);
one.addRight(2);
one.addRight(89);
cout << one.getRight() << " "
<< two.getRight() << endl;
two.addRight(21);
cout << one.getRight() << " "
<< two.getRight() << endl;
one++; two++; two++;
three = one;
one.removeRight();
cout << one.getRight() << " "
<< two.getRight() << " "
<< three.getRight() << endl;
three.addRight(17);
cout << one.getRight() << " "
<< two.getRight() << " "
<< three.getRight() << endl;
one.toEnd();
one.addRight(18);
two.pos(3);
three--;
two.step();
one.step(4);
cout << "one: " << one << endl;
cout << "two: " << two << endl;
cout << "three: " << three << endl;
return 0;
}
The output from this example would look like:
89 89
21 21
2 2 2
17 2 17
one: len=5 pos=2 21 17 2 12 18
two: len=5 pos=4 21 17 2 12 18
three: len=5 pos=0 21 17 2 12 18
Tip: This class uses the "Notice" classes to implement "dynamic" cursors so that multiple cursors are updated as elements are added and removed from the list;
Definition at line 604 of file List.h.
Constructor & Destructor Documentation
This constructor allows one to construct a ListIter and attach it to the List parameter.
The own flag can be set to indicate that the List should be destroyed when the ListIter is deleted.
Definition at line 613 of file List.h.
This constructor allows one to construct a ListIter and attach it to the List parameter.
These constructors allow for the creation of a ListIter from another ListIter.
This will attach this ListIter to the List tracked by the ListIter parameter at the time of construction.
This is the default constructor.
It allows one to create an initially invalid empty ListIter. The instantiated class will accept assignment and thus become valid later.
Definition at line 637 of file List.h.
Member Function Documentation
This function adds the element to the right of the current cursor position.
Allow container to update
Definition at line 644 of file List.h.
This function changes the List which this ListIter tracks and specifies that the List should be deleted when this iterator is deleted.
Returns the element to the right of the cursor.
Definition at line 676 of file List.h.
This assignment operator substitutes the "List<t>" tracked by this iterator to the "List<t>" passed as an argument.
Reimplemented from casacore::ConstListIter< t >.
This assignment operator changes the List which this iterator tracks to the List parameter.
This function removes the element to the right of the current cursor position.
This function swaps the list section after the current position of the list with the right section of the list of another iterator.
This can be particularly useful for "remembering" the position of a cursor in a list.
Member Data Documentation
Indicates if this iterator "owns" the container it observes.
Definition at line 724 of file List.h.
The documentation for this class was generated from the following file:
- casacore/casa/Containers/List.h