Sleipnir
Public Member Functions
Sleipnir::CTrieIterator< tType > Class Template Reference

Iterator for inorder traversal of trie keys. More...

#include <trie.h>

Inheritance diagram for Sleipnir::CTrieIterator< tType >:
Sleipnir::CTrieIteratorImpl< tType >

Public Member Functions

 CTrieIterator (const CTrieIterator &Iter)
 Copy constructor.
 CTrieIterator (const CTrie< tType > &Trie)
 Construct a new iterator for the given trie.
bool IsDone () const
 Return true if the iterator has completed its traversal.
const std::vector< unsigned
char > & 
GetPosition () const
 Return the key at the current iterator position.
const tType & Get () const
 Return the value at the current iterator position.
tType & Set () const
 Return a writable value at the current iterator position.
bool Next ()
 Advance the iterator to the next key/value position.

Detailed Description

template<class tType>
class Sleipnir::CTrieIterator< tType >

Iterator for inorder traversal of trie keys.

Parameters:
tTypeType of element contained by the trie.

A trie iterator provides inorder access to each key in the trie. Given a trie, a new iterator will subsequently provide read/write access to the value for each key in the dictionary. Sample usage might be:

 for( TTrieData::iterator SomeIterator( SomeTrie ); !SomeIterator.IsDone( ); SomeIterator.Next( ) ) {
   cout << SomeIterator.Get( ) << endl; }
See also:
CTrie

Definition at line 249 of file trie.h.


Constructor & Destructor Documentation

template<class tType >
Sleipnir::CTrieIterator< tType >::CTrieIterator ( const CTrieIterator< tType > &  Iter) [inline]

Copy constructor.

Parameters:
IterIterator whose values should be copied to the new iterator.
Remarks:
The newly constructed iterator will begin traversal in the same position as the given iterator.

Definition at line 261 of file trie.h.

template<class tType >
Sleipnir::CTrieIterator< tType >::CTrieIterator ( const CTrie< tType > &  Trie) [inline]

Construct a new iterator for the given trie.

Parameters:
TrieTrie whose key/value pairs should be traversed.

Definition at line 270 of file trie.h.


Member Function Documentation

template<class tType >
const tType& Sleipnir::CTrieIterator< tType >::Get ( ) const [inline]

Return the value at the current iterator position.

Returns:
Value at the current iterator position.
See also:
Set

Definition at line 307 of file trie.h.

References Sleipnir::CTrieIterator< tType >::Set().

template<class tType >
const std::vector<unsigned char>& Sleipnir::CTrieIterator< tType >::GetPosition ( ) const [inline]

Return the key at the current iterator position.

Returns:
Key at the current iterator position.

Definition at line 293 of file trie.h.

template<class tType >
bool Sleipnir::CTrieIterator< tType >::IsDone ( ) const [inline]

Return true if the iterator has completed its traversal.

Returns:
True if there are no more valid key/value pairs to be iterated.
Remarks:
Note that if IsDone returns true, Get, Set, and GetPosition are invalid.

Definition at line 282 of file trie.h.

Referenced by Sleipnir::CTrieIterator< tType >::Next().

template<class tType >
bool Sleipnir::CTrieIterator< tType >::Next ( ) [inline]

Advance the iterator to the next key/value position.

Returns:
True if the iterator was advanced; false if it was already at the end of the trie.
Remarks:
If IsDone returns true, Next will return false.

Definition at line 335 of file trie.h.

References Sleipnir::CTrieIterator< tType >::IsDone().

template<class tType >
tType& Sleipnir::CTrieIterator< tType >::Set ( ) const [inline]

Return a writable value at the current iterator position.

Returns:
Writable value at the current iterator position.
See also:
Get

Definition at line 321 of file trie.h.

Referenced by Sleipnir::CTrieIterator< tType >::Get().


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