diff options
author | doccvs <doccvs@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2001-03-27 07:50:10 +0000 |
---|---|---|
committer | doccvs <doccvs@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2001-03-27 07:50:10 +0000 |
commit | 4da1a649f5d4ac7821d6b818ec3f4670f03e29dc (patch) | |
tree | 504a17114894e5e0b997cfbb021b3a77c823a4dd /ace/Unbounded_Set.h | |
parent | ee369a313236dd95dab05a276621d719f37df439 (diff) | |
download | ATCD-4da1a649f5d4ac7821d6b818ec3f4670f03e29dc.tar.gz |
ChangeLogTag: Tue Mar 12 09:45:45 2001 Johnny Willemsen <jwillemsen@remedy.nl>
Diffstat (limited to 'ace/Unbounded_Set.h')
-rw-r--r-- | ace/Unbounded_Set.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/ace/Unbounded_Set.h b/ace/Unbounded_Set.h index 3a6f94daf03..9098e5c2091 100644 --- a/ace/Unbounded_Set.h +++ b/ace/Unbounded_Set.h @@ -83,6 +83,65 @@ private: }; /** + * @class ACE_Unbounded_Set_Const_Iterator + * + * @brief Implement an const iterator over an unbounded set. + */ +template <class T> +class ACE_Unbounded_Set_Const_Iterator +{ +public: + // = Initialization method. + ACE_Unbounded_Set_Const_Iterator (const ACE_Unbounded_Set<T> &s, int end = 0); + + // = Iteration methods. + + /// Pass back the <next_item> that hasn't been seen in the Set. + /// Returns 0 when all items have been seen, else 1. + int next (T *&next_item); + + /// Move forward by one element in the set. Returns 0 when all the + /// items in the set have been seen, else 1. + int advance (void); + + /// Move to the first element in the set. Returns 0 if the + /// set is empty, else 1. + int first (void); + + /// Returns 1 when all items have been seen, else 0. + int done (void) const; + + /// Dump the state of an object. + void dump (void) const; + + // = STL styled iteration, compare, and reference functions. + + /// Postfix advance. + ACE_Unbounded_Set_Const_Iterator<T> operator++ (int); + + /// Prefix advance. + ACE_Unbounded_Set_Const_Iterator<T>& operator++ (void); + + /// Returns a reference to the internal element <this> is pointing to. + T& operator* (void); + + /// Check if two iterators point to the same position + int operator== (const ACE_Unbounded_Set_Const_Iterator<T> &) const; + int operator!= (const ACE_Unbounded_Set_Const_Iterator<T> &) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + + /// Pointer to the current node in the iteration. + ACE_Node<T> *current_; + + /// Pointer to the set we're iterating over. + const ACE_Unbounded_Set<T> *set_; +}; + +/** * @class ACE_Unbounded_Set * * @brief Implement a simple unordered set of <T> of unbounded size. @@ -96,10 +155,13 @@ class ACE_Unbounded_Set { public: friend class ACE_Unbounded_Set_Iterator<T>; + friend class ACE_Unbounded_Set_Const_Iterator<T>; // Trait definition. typedef ACE_Unbounded_Set_Iterator<T> ITERATOR; typedef ACE_Unbounded_Set_Iterator<T> iterator; + typedef ACE_Unbounded_Set_Const_Iterator<T> CONST_ITERATOR; + typedef ACE_Unbounded_Set_Const_Iterator<T> const_iterator; // = Initialization and termination methods. /// Constructor. Use user specified allocation strategy |