idaeim studio
 PVL: Parameter Value Language

Public Member Functions
Array::Depth_Iterator Class Reference

A Depth_Iterator is a bidirectional iterator over an Array's Value list and, depth-first, over the Value list of each Array encountered. More...

#include <Value.hh>

Collaboration diagram for Array::Depth_Iterator:
Collaboration graph
[legend]

List of all members.

Public Member Functions

Arrayarray () const
 Gets the current Array context.
 Depth_Iterator (const Array &array)
 Constructs a Depth_Iterator for an Array.
 Depth_Iterator ()
 Constructs a Depth_Iterator without a root Array.
 Depth_Iterator (const Array::iterator &list_iterator)
 Construct a Depth_Iterator from a normal Array iterator.
Depth_Iterator end_depth () const
 Gets a Depth_Iterator positioned at the end of the traversal for this Depth_Iterator.
Depth_Iteratornext_sibling ()
 operator Array::iterator ()
 Converts the Depth_Iterator to a Value_List iterator.
bool operator!= (const Depth_Iterator &depth_iterator) const
 Tests if the current positions of this Depth_Iterator and another Depth_Iterator are not equivalent.
bool operator!= (const Array::iterator &list_iterator) const
 Tests if the current position of this Depth_Iterator and an Array list iterator are not equivalent.
Valueoperator* () const
 Gets a reference to the Value at the current position.
Depth_Iterator operator+ (int distance) const
 Gets a Depth_Iterator for a position at some distance from the current position.
Depth_Iteratoroperator++ ()
 Pre-increments forward to the next Value position.
Depth_Iterator operator++ (int)
 Post-increments forward to the next Value position.
Depth_Iteratoroperator+= (int distance)
 Relocates the current position by the specified distance.
int operator- (const Array::iterator &list_iterator) const
 Get the distance between this Depth_Iterator and an Array list iterator.
Depth_Iterator operator- (int distance) const
 Gets a Depth_Iterator for a position at some distance from the current position.
int operator- (const Depth_Iterator &depth_iterator) const
 Gets the distance between this and another Depth_Iterator.
Depth_Iterator operator-- (int)
 Post-decrements backward to the previous Value position.
Depth_Iteratoroperator-- ()
 Pre-decrements backward to the previous Value position.
Depth_Iteratoroperator-= (int distance)
 Relocates the current position by the specified distance.
Valueoperator-> () const
 Gets a pointer to the Value at the current position.
bool operator< (const Array::iterator &list_iterator) const
 Tests if the current position of this Depth_Iterator is less than the position of an Array list iterator.
bool operator< (const Depth_Iterator &depth_iterator) const
 Tests if the position of this Depth_Iterator is less than the position of another Depth_Iterator.
bool operator<= (const Array::iterator &list_iterator) const
 Tests if the position of this Depth_Iterator is less than or equal to the position of an Array list iterator.
bool operator<= (const Depth_Iterator &depth_iterator) const
 Tests if the position of this Depth_Iterator is less than or equal to the position of another Depth_Iterator.
Depth_Iteratoroperator= (const Array::iterator &list_iterator)
 Assigns a Value list iterator to this Depth_Iterator.
bool operator== (const Array::iterator &list_iterator) const
 Tests if the current position of this Depth_Iterator and an Array list iterator are equivalent.
bool operator== (const Depth_Iterator &depth_iterator) const
 Tests if the current positions of this Depth_Iterator and another Depth_Iterator are equivalent.
bool operator> (const Depth_Iterator &depth_iterator) const
 Tests if the position of this Depth_Iterator is greater than the position of another Depth_Iterator.
bool operator> (const Array::iterator &list_iterator) const
 Tests if the position of this Depth_Iterator is greater than the position of an Array list iterator.
bool operator>= (const Array::iterator &list_iterator) const
 Tests if the position of this Depth_Iterator is greater than or equal to the position of an Array list iterator.
bool operator>= (const Depth_Iterator &depth_iterator) const
 Tests if the position of this Depth_Iterator is greater than or equal to the position of another Depth_Iterator.
Valueoperator[] (int offset) const
 Array-style access to the Value at an offset from the current position.
Depth_Iteratorprevious_sibling ()
Arrayroot () const
 Gets the root Array.

Detailed Description

A Depth_Iterator is a bidirectional iterator over an Array's Value list and, depth-first, over the Value list of each Array encountered.

The Depth_Iterator operates like a normal breadth-only interator for a Value list until it encounters an Array in the list. When it is incremented from an Array position it decends into the Array, and only returns to the next Value in the current list when the end of the Value list of the Array has been reached. This process is recursive resulting in a depth-first traversal of the entire Array Value hierarchy. The mechanism operates similarly when decrementing by descending into each Array and reverse iterating its Value list, then returning to the current Value list when the beginning of the Array's list has been reached.

A Depth_Iterator is associated with a specific Array which it knows as its root Array. It will not ascend into the Value list of the root Array's parent. Like other container iterators, all positions are expected to be for valid Values except the final end position of the root Array; reverse iteration will not go beyond the initial begin position of the root Array.

Random-access operators are also provided. But because they are not truely random access, and do not operate in constant time, the Depth_Iterator is tagged as only bidirectional.


Constructor & Destructor Documentation

Depth_Iterator ( ) [inline]

Constructs a Depth_Iterator without a root Array.

This Depth_Iterator is invalid until it is assigned a valid iterator.

Depth_Iterator ( const Array array) [explicit]

Constructs a Depth_Iterator for an Array.

The initial position of this Depth_Iterator is the beginning of the Array's Value list.

Parameters:
arrayThe root Array.
See also:
Vectal::begin()
Depth_Iterator ( const Array::iterator list_iterator) [inline]

Construct a Depth_Iterator from a normal Array iterator.

Warning: The iterator must be valid; i.e. it must refer to a Value. An end iterator is not valid. Use the end_depth method to get the iterator for the end of a Depth_Iterator.


Member Function Documentation

operator Array::iterator ( ) [inline]

Converts the Depth_Iterator to a Value_List iterator.

Returns:
An iterator at the current position of the Depth_Iterator.
Array* root ( ) const

Gets the root Array.

Returns:
A pointer to the root Array for this Depth_Iterator.
Array* array ( ) const [inline]

Gets the current Array context.

Returns:
A pointer to the Array containing the Value list for the current iterator position.
Depth_Iterator end_depth ( ) const

Gets a Depth_Iterator positioned at the end of the traversal for this Depth_Iterator.

This is the same as the end iterator for the root Array.

Returns:
A Depth_Iterator positioned at the end of this Depth_Iterator.
Exceptions:
ErrorIf this Depth_Iterator is invalid (it doesn't have a root Array).
See also:
Vectal::end()
Depth_Iterator& operator= ( const Array::iterator list_iterator)

Assigns a Value list iterator to this Depth_Iterator.

If the Depth_Iterator is currently positioned at the same Value as the list iterator nothing happens.

If the Depth_Iterator and list iterator are positioned in the Value list of the same Array, then the current position of the Depth_Iterator is simply moved to the list iterator position. However, if the list iterator position is the end of the current Value list, and the list is not in the root Array, then the current position is moved to the position preceeding the end; unless the list has become empty (due to some other user action on the list) in which case the Depth_Iterator is incremented forward to the next valid position.

When the Depth_Iterator and list iterator are not positioned in the same Array, then a search is made for the list iterator position within the scope of the Depth_Iterator. First a search is made from the current Depth_Iterator position towards the beginning of its scope. If this fails a search is made from the current Depth_Iterator position towards the end of its scope. The current position of the Depth_Iterator becomes list iterator position if it is found.

Parameters:
list_iteratorThe Value_List iterator position to be assigned to this Depth_Iterator.
Returns:
This Depth_Iterator.
Exceptions:
Invalid_ArgumentIf the list iterator is not in the scope of this Depth_Iterator.
ErrorIf on attempting to ascend from an Array hierarchy, a non-root Array is encountered without a parent (this should not happen unless the Array hierachy was inappropriately modified during traversal).
Value& operator* ( ) const [inline]

Gets a reference to the Value at the current position.

Returns:
The reference to the Value at the current position.
Value* operator-> ( ) const [inline]

Gets a pointer to the Value at the current position.

Returns:
The pointer to the Value at the current position.
Depth_Iterator& operator++ ( )

Pre-increments forward to the next Value position.

If the Value at the current position is a non-empty Array, the current position is pushed onto a LIFO (last-in-first-out) stack and then the current position moves to the first entry in the child Array's list.

If the Value at the current position is an Assignment or an empty Array, then the current position is moved forward to the next position in the Value list. If this position is the end of the Value list, and the list is not for the root Array, then the previous position in the parent's Value list is popped from the stack to the current position and it is moved forward again. Ascending up the Array hierarchy continues in this way until a non-end list position is found, or the end of the root Array is encountered.

Caution: Like any iterator, care must be taken not to inappropriately modify the container structure being traversed or the integrity of the Depth_Iterator will be lost. The Array hierachy of the Depth_Iterator's current position is the primary issue. Each iterator, saved on the stack, to a previous position in the Array heirarchy must remain consistent; the location of its Array in the Value list must remain unchanged and the parent of the Array must remain unchanged. Changes to the current Value list may be made as long as the current position of the Depth_Iterator remains valid; e.g. assigning back to the Depth_Iterator the iterator returned from an insert (or poke) or erase (or pull) using the current Depth_Iterator. Modfications anywhere in the Depth_Iterator scope beyond any current hierachy path position is safe; e.g. push_back or poke_back is always OK. But modifications at or before any current hierachy path position is almost always going to disrupt a Depth_Iterator.

Returns:
This Depth_Iterator.
Exceptions:
Out_of_RangeIf the current position is the end of the root Array.
ErrorIf the Depth_Iterator is invalid (doesn't have a root Array). An Error will also be thrown if, on attempting to ascend the Array hierarchy, a non-root Array is encountered without a parent (this should not happen unless the Array hierachy was inappropriately modified during traversal).
Depth_Iterator& next_sibling ( )
Depth_Iterator operator++ ( int  )

Post-increments forward to the next Value position.

Returns:
A copy of the Depth_Iterator before it was incremented.
See also:
operator++();
Depth_Iterator& operator-- ( )

Pre-decrements backward to the previous Value position.

If the current position is not the beginning of a Value list, the current position moves to the previous Value in the list. If this Value is a non-empty Array, the current position is pushed onto a LIFO (last-in-first-out) stack and then the current position moves to the last entry (the Value immediately preceeding the end position) in the child Array's list. If this Value is a non-empty Array then the currrent positionis pushed onto the stack again and the current position becomes the last entry in this Array. This back-down cycle continues until an Assignment, or empty Array, Value is encountered.

If the current position is the beginning of a Value list, and it is not the root Array's Value list, then the previous position in the parent's Value list is popped from the stack to the current position.

Returns:
This Depth_Iterator.
Exceptions:
Out_of_RangeIf the current position is the beginning of the root Array.
ErrorIf the Depth_Iterator is invalid (doesn't have a root Array). An Error will also be thrown if, on attempting to ascend the Array hierarchy, a non-root Array is encountered without a parent (this should not happen unless the Array hierachy was inappropriately modified during traversal).
See also:
operator++()
Depth_Iterator& previous_sibling ( )
Depth_Iterator operator-- ( int  )

Post-decrements backward to the previous Value position.

Returns:
A copy of the Depth_Iterator before it was incremented.
See also:
operator--();
Value& operator[] ( int  offset) const

Array-style access to the Value at an offset from the current position.

The Depth_Iterator is copied and offset to the new position, and then dereferenced.

Parameters:
offsetThe position of the Value relative (positive or negative) to the current position.
Returns:
The Value reference at the offset position.
See also:
operator+(int)
Depth_Iterator& operator+= ( int  distance)

Relocates the current position by the specified distance.

The Depth_Iterator is incremented for a positive distance, or decremented for a negative distance, repeatedly the absolute amount of the distance.

Note: This is a random-access iterator operator that does not occur in constant time.

Parameters:
distanceThe number of increment (positive) or decrement (negative) operations to apply.
Returns:
This Depth_Iterator.
See also:
operator++()
operator--()
Depth_Iterator operator+ ( int  distance) const

Gets a Depth_Iterator for a position at some distance from the current position.

A copy of this Depth_Iterator is offset the distance.

Parameters:
distanceThe offset of the new Depth_Iterator.
Returns:
A Depth_Iterator at the new position.
See also:
operator+=(int)
Depth_Iterator& operator-= ( int  distance)

Relocates the current position by the specified distance.

Parameters:
distanceThe number of increment (negative) or decrement (positive) operations to apply.
Returns:
This Depth_Iterator.
See also:
operator+=()
Depth_Iterator operator- ( int  distance) const

Gets a Depth_Iterator for a position at some distance from the current position.

Parameters:
distanceThe offset of the new Depth_Iterator.
Returns:
A Depth_Iterator at the new position.
See also:
operator+(int)
int operator- ( const Depth_Iterator depth_iterator) const

Gets the distance between this and another Depth_Iterator.

Parameters:
depth_iteratorA Depth_Iterator position to find.
Returns:
The distance, in terms of decrement (positive) or increment (negative) count, to the depth_iterator position.
Exceptions:
Out_of_RangeIf the depth_iterator is not within the scope of this Depth_Iterator.
See also:
operator-(const Array::iterator&)
int operator- ( const Array::iterator list_iterator) const

Get the distance between this Depth_Iterator and an Array list iterator.

A search is made for the list iterator position in the scope of this Depth_Iterator; first backwards (positive distance), and then forwards (negative distance).

Note: This is a random-access iterator operator that does not occur in constant time.

Parameters:
list_iteratorAn Array::iterator position to find.
Returns:
The distance, in terms of decrement (positive) or increment (negative) count, to the list_iterator position.
Exceptions:
Out_of_RangeIf the list_iterator is not within the scope of this Depth_Iterator.
bool operator== ( const Depth_Iterator depth_iterator) const [inline]

Tests if the current positions of this Depth_Iterator and another Depth_Iterator are equivalent.

Parameters:
depth_iteratorThe Depth_Iterator to compare against.
Returns:
true if the current positions are identical; false otherwise.
bool operator!= ( const Depth_Iterator depth_iterator) const [inline]

Tests if the current positions of this Depth_Iterator and another Depth_Iterator are not equivalent.

Parameters:
depth_iteratorThe Depth_Iterator to compare against.
Returns:
false if the current positions are identical; true otherwise.
bool operator== ( const Array::iterator list_iterator) const [inline]

Tests if the current position of this Depth_Iterator and an Array list iterator are equivalent.

WARNING: This method may result in undefined behaviour if the list_iterator argument is not bound to the same Array vector that the Depth_Iterator current position iterator is bound to. If this is possible a Depth_Iterator should first be constructed from the list_iterator before the equality test is made.

Parameters:
list_iteratorThe Array::iterator to compare against.
Returns:
true if the positions are identical; false otherwise.
bool operator!= ( const Array::iterator list_iterator) const [inline]

Tests if the current position of this Depth_Iterator and an Array list iterator are not equivalent.

Parameters:
list_iteratorThe Array::iterator to compare against.
Returns:
false if the positions are identical; true otherwise.
bool operator< ( const Depth_Iterator depth_iterator) const

Tests if the position of this Depth_Iterator is less than the position of another Depth_Iterator.

Parameters:
depth_iteratorThe Depth_Iterator to compare against.
Returns:
true if this Depth_Iterator preceeds the position of the other Depth_Iterator; flase otherwise.
See also:
operator<(const Array::iterator&)
bool operator< ( const Array::iterator list_iterator) const

Tests if the current position of this Depth_Iterator is less than the position of an Array list iterator.

A copy of this Depth_Iterator is incremented forward searching for the list iterator position.

Note: This is a random-access iterator operator that does not occur in constant time. This is always more, often much more, expensive that the == (or !=) test. The latter should be used whenever possible (e.g. in loop conditions).

Parameters:
list_iteratorThe Array::iterator to compare against.
Returns:
true if the list_iterator position is found; false otherwise.
bool operator> ( const Depth_Iterator depth_iterator) const [inline]

Tests if the position of this Depth_Iterator is greater than the position of another Depth_Iterator.

Parameters:
depth_iteratorThe Depth_Iterator to compare against.
Returns:
true if the other Depth_Iterator is less than this Depth_Iterator; false otherwise.
See also:
operator<(const Array::iterator&)
bool operator<= ( const Depth_Iterator depth_iterator) const [inline]

Tests if the position of this Depth_Iterator is less than or equal to the position of another Depth_Iterator.

Parameters:
depth_iteratorThe Depth_Iterator to compare against.
Returns:
true if the other Depth_Iterator is not less than this Depth_Iterator; false otherwise.
See also:
operator<(const Array::iterator&)
bool operator>= ( const Depth_Iterator depth_iterator) const [inline]

Tests if the position of this Depth_Iterator is greater than or equal to the position of another Depth_Iterator.

Parameters:
depth_iteratorThe Depth_Iterator to compare against.
Returns:
true if this Depth_Iterator is less than the other Depth_Iterator; false otherwise.
See also:
operator<(const Array::iterator&)
bool operator> ( const Array::iterator list_iterator) const [inline]

Tests if the position of this Depth_Iterator is greater than the position of an Array list iterator.

Parameters:
list_iteratorThe Array::iterator to compare against.
Returns:
true if this Depth_Iterator is not less than or equal to the list_terator; false otherwise.
See also:
operator<(const Array::iterator&)
bool operator<= ( const Array::iterator list_iterator) const [inline]

Tests if the position of this Depth_Iterator is less than or equal to the position of an Array list iterator.

Parameters:
list_iteratorThe Array::iterator to compare against.
Returns:
true if this Depth_Iterator is eqivalent to, or less than, the the list_iterator; false otherwise.
See also:
operator<(const Array::iterator&)
bool operator>= ( const Array::iterator list_iterator) const [inline]

Tests if the position of this Depth_Iterator is greater than or equal to the position of an Array list iterator.

Parameters:
list_iteratorThe Array::iterator to compare against.
Returns:
true if this Depth_Iterator is not less than the list iterator; false otherwise.
See also:
operator<(const Array::iterator&)

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