claw::avl_base< K, Comp >::avl_iterator Class Reference

AVL iterator. More...

#include <avl_base.hpp>

List of all members.

Public Types

typedef K value_type
typedef K & reference
typedef K *const pointer
typedef ptrdiff_t difference_type
typedef
std::bidirectional_iterator_tag 
iterator_category

Public Member Functions

 avl_iterator ()
 Constructor.
 avl_iterator (avl_node_ptr node, bool final)
 Constructor.
avl_iteratoroperator++ ()
 Preincrement.
avl_iterator operator++ (int)
 Postincrement.
avl_iteratoroperator-- ()
 Predecrement.
avl_iterator operator-- (int)
 Postdecrement.
reference operator* () const
 Dereference.
pointer operator-> () const
 Reference.
bool operator== (const avl_iterator &it) const
 Equality.
bool operator!= (const avl_iterator &it) const
 Difference.

Private Attributes

avl_node_ptr m_current
 Current node in the tree.
bool m_is_final
 True if we've gone past the last node.

Detailed Description

template<class K, class Comp = std::less<K>>
class claw::avl_base< K, Comp >::avl_iterator

AVL iterator.

Definition at line 131 of file avl_base.hpp.


Member Typedef Documentation

template<class K, class Comp = std::less<K>>
typedef ptrdiff_t claw::avl_base< K, Comp >::avl_iterator::difference_type

Definition at line 137 of file avl_base.hpp.

template<class K, class Comp = std::less<K>>
typedef std::bidirectional_iterator_tag claw::avl_base< K, Comp >::avl_iterator::iterator_category

Definition at line 139 of file avl_base.hpp.

template<class K, class Comp = std::less<K>>
typedef K* const claw::avl_base< K, Comp >::avl_iterator::pointer

Definition at line 136 of file avl_base.hpp.

template<class K, class Comp = std::less<K>>
typedef K& claw::avl_base< K, Comp >::avl_iterator::reference

Definition at line 135 of file avl_base.hpp.

template<class K, class Comp = std::less<K>>
typedef K claw::avl_base< K, Comp >::avl_iterator::value_type

Definition at line 134 of file avl_base.hpp.


Constructor & Destructor Documentation

template<class K , class Comp >
claw::avl_base< K, Comp >::avl_iterator::avl_iterator (  )  [inline]

Constructor.

Definition at line 607 of file avl_base.tpp.

00608   : m_current(NULL), m_is_final(true)
00609 {
00610 
00611 } // avl_iterator::avl_iterator() [constructeur]

template<class K , class Comp >
claw::avl_base< K, Comp >::avl_iterator::avl_iterator ( avl_node_ptr  node,
bool  final 
) [inline]

Constructor.

Definition at line 619 of file avl_base.tpp.

00620   : m_current(node), m_is_final(final)
00621 {
00622 
00623 } // avl_iterator::avl_iterator() [constructeur with node]


Member Function Documentation

template<class K , class Comp >
bool claw::avl_base< K, Comp >::avl_iterator::operator!= ( const avl_iterator it  )  const [inline]

Difference.

Parameters:
it Iterator to compare to.

Definition at line 735 of file avl_base.tpp.

00736 {
00737   return !( *this == it ); 
00738 } // avl_iterator::operator!=()

template<class K , class Comp >
claw::avl_base< K, Comp >::avl_iterator::reference claw::avl_base< K, Comp >::avl_iterator::operator* (  )  const [inline]

Dereference.

Definition at line 700 of file avl_base.tpp.

References claw::avl_base< K, Comp >::avl_node::key, and claw::avl_base< K, Comp >::avl_iterator::m_current.

00701 {
00702   return m_current->key; 
00703 } // avl_iterator::operator*() [dereference]

template<class K , class Comp >
claw::avl_base< K, Comp >::avl_iterator claw::avl_base< K, Comp >::avl_iterator::operator++ ( int   )  [inline]

Postincrement.

Definition at line 653 of file avl_base.tpp.

00654 {
00655   avl_iterator it = *this;
00656   ++(*this);
00657   return it;
00658 } // avl_iterator::operator++ [postincrement]

template<class K , class Comp >
claw::avl_base< K, Comp >::avl_iterator & claw::avl_base< K, Comp >::avl_iterator::operator++ (  )  [inline]

Preincrement.

Precondition:
not final(this).

Definition at line 632 of file avl_base.tpp.

References claw::avl_base< K, Comp >::avl_iterator::m_current, claw::avl_base< K, Comp >::avl_iterator::m_is_final, and claw::avl_base< K, Comp >::avl_node::next().

00633 {
00634   assert(!m_is_final);
00635   assert(m_current);
00636 
00637   avl_node* p = m_current->next();
00638 
00639   if ( m_current == p )
00640     m_is_final = true;
00641   else
00642     m_current = p;
00643 
00644   return *this;
00645 } // avl_iterator::operator++() [preincrement]

template<class K , class Comp >
claw::avl_base< K, Comp >::avl_iterator claw::avl_base< K, Comp >::avl_iterator::operator-- ( int   )  [inline]

Postdecrement.

Definition at line 687 of file avl_base.tpp.

00688 {
00689   avl_iterator it = *this;
00690   --(*this);
00691   return it;
00692 } // avl_iterator::operator-- [postdecrement]

template<class K , class Comp >
claw::avl_base< K, Comp >::avl_iterator & claw::avl_base< K, Comp >::avl_iterator::operator-- (  )  [inline]

Predecrement.

Precondition:
iterator is not at the begining of the container.

Definition at line 667 of file avl_base.tpp.

References claw::avl_base< K, Comp >::avl_iterator::m_current, claw::avl_base< K, Comp >::avl_iterator::m_is_final, and claw::avl_base< K, Comp >::avl_node::prev().

00668 {
00669   assert(m_current);
00670 
00671   if (m_is_final)
00672     m_is_final = !m_is_final;
00673   else
00674     m_current = m_current->prev();
00675 
00676   assert(m_current != NULL);
00677   
00678   return *this;
00679 } // avl_iterator::operator--() [predecrement]

template<class K , class Comp >
claw::avl_base< K, Comp >::avl_iterator::pointer claw::avl_base< K, Comp >::avl_iterator::operator-> (  )  const [inline]

Reference.

Definition at line 711 of file avl_base.tpp.

References claw::avl_base< K, Comp >::avl_node::key, and claw::avl_base< K, Comp >::avl_iterator::m_current.

00712 {
00713   return &m_current->key; 
00714 } // avl_iterator::operator->()

template<class K , class Comp >
bool claw::avl_base< K, Comp >::avl_iterator::operator== ( const avl_iterator it  )  const [inline]

Equality.

Parameters:
it Iterator to compare to.

Definition at line 723 of file avl_base.tpp.

References claw::avl_base< K, Comp >::avl_iterator::m_current, and claw::avl_base< K, Comp >::avl_iterator::m_is_final.

00724 {
00725   return (m_current == it.m_current) && (m_is_final == it.m_is_final); 
00726 } // avl_iterator::operator==()


Member Data Documentation

template<class K, class Comp = std::less<K>>
avl_node_ptr claw::avl_base< K, Comp >::avl_iterator::m_current [private]
template<class K, class Comp = std::less<K>>
bool claw::avl_base< K, Comp >::avl_iterator::m_is_final [private]

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

Generated on 9 Nov 2009 for CLAW Library (a C++ Library Absolutely Wonderful) by  doxygen 1.6.1