Public Member Functions | Protected Attributes

nsDequeIterator Class Reference

#include <nsDeque.h>

Collaboration diagram for nsDequeIterator:

List of all members.

Public Member Functions

 nsDequeIterator (const nsDeque &aQueue, int aIndex=0)
 DequeIterator is an object that knows how to iterate (forward and backward) through a Deque.
 nsDequeIterator (const nsDequeIterator &aCopy)
 Create a copy of a DequeIterator.
nsDequeIteratorFirst ()
 Moves iterator to first element in the deque.
nsDequeIteratoroperator= (const nsDequeIterator &aCopy)
 Standard assignment operator for dequeiterator.
PRBool operator!= (nsDequeIterator &aIter)
 preform ! operation against two iterators to test for equivalence (or lack thereof)!
PRBool operator< (nsDequeIterator &aIter)
 Compare two iterators for increasing order.
PRBool operator== (nsDequeIterator &aIter)
 Compare two iterators for equivalence.
PRBool operator>= (nsDequeIterator &aIter)
 Compare two iterators for non strict decreasing order.
void * operator++ ()
 Pre-increment operator Iterator will advance one index towards the end.
void * operator++ (int)
 Post-increment operator Iterator will advance one index towards the end.
void * operator-- ()
 Pre-decrement operator Iterator will advance one index towards the beginning.
void * operator-- (int)
 Post-decrement operator Iterator will advance one index towards the beginning.
void * GetCurrent ()
 Retrieve the the iterator's notion of current node.
void ForEach (nsDequeFunctor &aFunctor) const
 Call this method when you want to iterate all the members of the container, passing a functor along to call your code.
const void * FirstThat (nsDequeFunctor &aFunctor) const
 Call this method when you want to iterate all the members of the container, calling the functor you passed with each member.

Protected Attributes

PRInt32 mIndex
const nsDequemDeque

Constructor & Destructor Documentation

nsDequeIterator::nsDequeIterator ( const nsDeque aQueue,
int  aIndex = 0 
)

DequeIterator is an object that knows how to iterate (forward and backward) through a Deque.

Normally, you don't need to do this, but there are some special cases where it is pretty handy.

One warning: the iterator is not bound to an item, it is bound to an index, so if you insert or remove from the beginning while using an iterator (which is not recommended) then the iterator will point to a different item.

See also:
GetCurrent()

Here you go.

Parameters:
aQueue is the deque object to be iterated
aIndex is the starting position for your iteration
nsDequeIterator::nsDequeIterator ( const nsDequeIterator aCopy  ) 

Create a copy of a DequeIterator.

Parameters:
aCopy is another iterator to copy from

Member Function Documentation

nsDequeIterator& nsDequeIterator::First (  ) 

Moves iterator to first element in the deque.

Returns:
*this
const void* nsDequeIterator::FirstThat ( nsDequeFunctor aFunctor  )  const

Call this method when you want to iterate all the members of the container, calling the functor you passed with each member.

This process will interrupt if your function returns non 0 to this method.

Parameters:
aFunctor object to call for each member
Returns:
first nonzero result of aFunctor or 0.
void nsDequeIterator::ForEach ( nsDequeFunctor aFunctor  )  const

Call this method when you want to iterate all the members of the container, passing a functor along to call your code.

Parameters:
aFunctor object to call for each member
Returns:
*this
void* nsDequeIterator::GetCurrent (  ) 

Retrieve the the iterator's notion of current node.

Note that the iterator floats, so you don't need to do: ++iter; aDeque.PopFront(); Unless you actually want your iterator to jump 2 positions relative to its origin.

Picture: [1 2i 3 4] PopFront() Picture: [2 3i 4] Note that I still happily points to object at the second index.

Returns:
object at i'th index
PRBool nsDequeIterator::operator!= ( nsDequeIterator aIter  ) 

preform ! operation against two iterators to test for equivalence (or lack thereof)!

Parameters:
aIter is the object to be compared to
Returns:
TRUE if NOT equal.
void* nsDequeIterator::operator++ ( int   ) 

Post-increment operator Iterator will advance one index towards the end.

Parameters:
param is ignored
Returns:
object_at(mIndex++)
void* nsDequeIterator::operator++ (  ) 

Pre-increment operator Iterator will advance one index towards the end.

Returns:
object_at(++index)
void* nsDequeIterator::operator-- (  ) 

Pre-decrement operator Iterator will advance one index towards the beginning.

Returns:
object_at(--index)
void* nsDequeIterator::operator-- ( int   ) 

Post-decrement operator Iterator will advance one index towards the beginning.

Parameters:
param is ignored
Returns:
object_at(index--)
PRBool nsDequeIterator::operator< ( nsDequeIterator aIter  ) 

Compare two iterators for increasing order.

Parameters:
aIter is the other iterator to be compared to
Returns:
TRUE if this object points to an element before the element pointed to by aIter. FALSE if this and aIter are not iterating over the same deque.
nsDequeIterator& nsDequeIterator::operator= ( const nsDequeIterator aCopy  ) 

Standard assignment operator for dequeiterator.

Parameters:
aCopy is another iterator to copy from
Returns:
*this
PRBool nsDequeIterator::operator== ( nsDequeIterator aIter  ) 

Compare two iterators for equivalence.

Parameters:
aIter is the other iterator to be compared to
Returns:
TRUE if EQUAL
PRBool nsDequeIterator::operator>= ( nsDequeIterator aIter  ) 

Compare two iterators for non strict decreasing order.

Parameters:
aIter is the other iterator to be compared to
Returns:
TRUE if this object points to the same element, or an element after the element pointed to by aIter. FALSE if this and aIter are not iterating over the same deque.

Member Data Documentation

const nsDeque& nsDequeIterator::mDeque [protected]
PRInt32 nsDequeIterator::mIndex [protected]

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