## NAME

ACE_RB_Tree_Iterator_Base - Implements a common base class for iterators for a Red-Black Tree ADT.

## SYNOPSIS

    #include <ace/RB_Tree.h>

    template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
    class ACE_RB_Tree_Iterator_Base
    {
      public:
        void operator= (
            const ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &iter
            );
        int done (void) const;
        ACE_RB_Tree_Node<EXT_ID, INT_ID> & operator* (void) const;
        const ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &tree (
            void
            );
        int operator== (
            const ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &
            ) const;
        int operator!= (
            const ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &
            ) const;
        ACE_ALLOC_HOOK_DECLARE;
      protected:
        ACE_RB_Tree_Iterator_Base (
            const ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &tree,
            int set_first
            );
        ACE_RB_Tree_Iterator_Base (
            const ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &iter
            );
        ~ACE_RB_Tree_Iterator_Base (void);
        int forward_i (void);
        int reverse_i (void);
        void dump_i (void) const;
        const ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> *tree_;
        ACE_RB_Tree_Node <EXT_ID, INT_ID> *node_;
    };

## Iteration methods.

    int done (void) const;

Returns 1 when the iteration has completed, otherwise 0.

    ACE_RB_Tree_Node<EXT_ID, INT_ID> & operator* (void) const;

STL-like iterator dereference operator: returns a reference to the node underneath the iterator.

    const ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &tree (
        void
        );

Returns a const reference to the tree over which we're iterating.

    int operator== (
        const ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &
        ) const;

Comparison operator: returns 1 if both iterators point to the same position, otherwise 0.

    int operator!= (
        const ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &
        ) const;

Comparison operator: returns 1 if the iterators point to different positions, otherwise 0.

    ACE_ALLOC_HOOK_DECLARE;

Declare the dynamic allocation hooks.

## Initialization and termination methods.

    ACE_RB_Tree_Iterator_Base (
        const ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &tree,
        int set_first
        );

Constructor. Takes an ACE_RB_Tree over which to iterate, and an integer indicating (if non-zero) to position the iterator at the first element in the tree (if this integer is 0, the iterator is positioned at the last element in the tree).

    ACE_RB_Tree_Iterator_Base (
        const ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &iter
        );

Copy constructor.

    ~ACE_RB_Tree_Iterator_Base (void);

Destructor.

## Internal methods

    int forward_i (void);

Move forward by one element in the tree. Returns 0 when there are no more elements in the tree, otherwise 1.

    int reverse_i (void);

Move back by one element in the tree. Returns 0 when there are no more elements in the tree, otherwise 1.

    void dump_i (void) const;

Dump the state of an object.

## Protected members.

    const ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> *tree_;

Reference to the ACE_RB_Tree over which we're iterating.

    ACE_RB_Tree_Node <EXT_ID, INT_ID> *node_;

Pointer to the node currently under the iterator.

## AUTHOR

Chris Gill

## LIBRARY

ace