diff options
author | nw1 <nw1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-01-02 15:39:24 +0000 |
---|---|---|
committer | nw1 <nw1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-01-02 15:39:24 +0000 |
commit | 26dd55079ad194de852d254b9f00726219ce1abc (patch) | |
tree | 6a86f21d811c7efcc2bc3b46c11a54ddc0d77fe5 /ace/Map_Manager.h | |
parent | f121286b6f97c816ed7ae81353a2e42a5359e6e0 (diff) | |
download | ATCD-26dd55079ad194de852d254b9f00726219ce1abc.tar.gz |
Abstracted out ACE_Map_Iterator_Base and added some missing functionalities.
Diffstat (limited to 'ace/Map_Manager.h')
-rw-r--r-- | ace/Map_Manager.h | 106 |
1 files changed, 70 insertions, 36 deletions
diff --git a/ace/Map_Manager.h b/ace/Map_Manager.h index ea374af607d..26cfdc66bc9 100644 --- a/ace/Map_Manager.h +++ b/ace/Map_Manager.h @@ -50,6 +50,10 @@ public: // Forward decl. template <class EXT_ID, class INT_ID, class ACE_LOCK> +class ACE_Map_Iterator_Base; + +// Forward decl. +template <class EXT_ID, class INT_ID, class ACE_LOCK> class ACE_Map_Iterator; // Forward decl. @@ -74,6 +78,7 @@ class ACE_Map_Manager // linearly. For more efficient searching you should use the // <ACE_Hash_Map_Manager>. public: + friend class ACE_Map_Iterator_Base<EXT_ID, INT_ID, ACE_LOCK>; friend class ACE_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK>; friend class ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK>; @@ -265,16 +270,16 @@ private: }; template <class EXT_ID, class INT_ID, class ACE_LOCK> -class ACE_Map_Iterator +class ACE_Map_Iterator_Base { // = TITLE // Iterator for the ACE_Map_Manager. public: // = Initialization method. - ACE_Map_Iterator (ACE_Map_Manager <EXT_ID, INT_ID, ACE_LOCK> &mm); - - ACE_Map_Iterator (ACE_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK> &mi); - // Copy constructor. + ACE_Map_Iterator_Base (ACE_Map_Manager <EXT_ID, INT_ID, ACE_LOCK> &mm, + int head); + // Contructor. If head != 0, the iterator constructed is positioned + // at the head of the map, it is positioned at the end otherwise. // = Iteration methods. @@ -285,6 +290,53 @@ public: int done (void) const; // Returns 1 when all items have been seen, else 0. + ACE_Map_Entry<EXT_ID, INT_ID>& operator* (void); + // Returns a reference to the interal element <this> is pointing to. + +#if 0 + int operator== (ACE_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK> &); + int operator!= (ACE_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK> &); + // Check if two iterators point to the same position +#endif /* 0 */ + + ACE_ALLOC_HOOK_DECLARE; + // Declare the dynamic allocation hooks. + +protected: + int forward_i (void); + // Move forward by one element in the set. Returns 0 when there's + // no more item in the set after the current items, else 1. + + int reverse_i (void); + // Move backware by one element in the set. Returns 0 when there's + // no more item in the set before the current item, else 1. + + void dump_i (void) const; + // Dump the state of an object. + + ACE_Map_Manager <EXT_ID, INT_ID, ACE_LOCK> *map_man_; + // Map we are iterating over. + + ssize_t next_; + // Keeps track of how far we've advanced... +}; + +template <class EXT_ID, class INT_ID, class ACE_LOCK> +class ACE_Map_Iterator + : public ACE_Map_Iterator_Base<EXT_ID, INT_ID, ACE_LOCK> +{ + // = TITLE + // Iterator for the ACE_Map_Manager. +public: + // = Initialization method. + ACE_Map_Iterator (ACE_Map_Manager <EXT_ID, INT_ID, ACE_LOCK> &mm, + int tail = 0); + + // = Iteration methods. + + int done (void) const; + // Returns 1 when all items have been seen, else 0. + int advance (void); // Move forward by one element in the set. Returns 0 when all the // items in the set have been seen, else 1. @@ -300,42 +352,29 @@ public: ACE_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK>& operator++ (int); // Prefix advance. - ACE_Map_Entry<EXT_ID, INT_ID>& operator* (void); - // Returns a reference to the interal element <this> is pointing to. + ACE_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK> operator-- (void); + // Postfix advance. - int operator== (ACE_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK> &); - int operator!= (ACE_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK> &); - // Check if two iterators point to the same position + ACE_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK>& operator-- (int); + // Prefix advance. ACE_ALLOC_HOOK_DECLARE; // Declare the dynamic allocation hooks. - -private: - ACE_Map_Manager <EXT_ID, INT_ID, ACE_LOCK> *map_man_; - // Map we are iterating over. - - ssize_t next_; - // Keeps track of how far we've advanced... }; template <class EXT_ID, class INT_ID, class ACE_LOCK> class ACE_Map_Reverse_Iterator + : public ACE_Map_Iterator_Base<EXT_ID, INT_ID, ACE_LOCK> { // = TITLE // Reverse Iterator for the ACE_Map_Manager. public: // = Initialization method. - ACE_Map_Reverse_Iterator (ACE_Map_Manager <EXT_ID, INT_ID, ACE_LOCK> &mm); - - ACE_Map_Reverse_Iterator (ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK> &mi); - // Copy constructor. + ACE_Map_Reverse_Iterator (ACE_Map_Manager <EXT_ID, INT_ID, ACE_LOCK> &mm, + int head = 0); // = Iteration methods. - int next (ACE_Map_Entry<EXT_ID, INT_ID> *&next_entry); - // Pass back the <entry> that hasn't been seen in the Set. - // Returns 0 when all items have been seen, else 1. - int done (void) const; // Returns 1 when all items have been seen, else 0. @@ -354,22 +393,17 @@ public: ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK>& operator++ (int); // Prefix advance. + ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK> operator-- (void); + // Postfix advance. + + ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK>& operator-- (int); + // Prefix advance. + ACE_Map_Entry<EXT_ID, INT_ID>& operator* (void); // Returns a reference to the interal element <this> is pointing to. - int operator== (ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK> &); - int operator!= (ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK> &); - // Check if two iterators point to the same position - ACE_ALLOC_HOOK_DECLARE; // Declare the dynamic allocation hooks. - -private: - ACE_Map_Manager <EXT_ID, INT_ID, ACE_LOCK> *map_man_; - // Map we are iterating over. - - ssize_t next_; - // Keeps track of how far we've advanced... }; #if defined (__ACE_INLINE__) |