summaryrefslogtreecommitdiff
path: root/ace/Containers_T.h
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>2004-08-02 14:01:36 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>2004-08-02 14:01:36 +0000
commit0fcea4065e9b4ef08847e0c18fe336b1c6bb35b1 (patch)
treefc76f856010cf4b2655ee21e8214d16eb84d650c /ace/Containers_T.h
parent41e15274a790f6412f9efc29259381c69f0fcd78 (diff)
downloadATCD-0fcea4065e9b4ef08847e0c18fe336b1c6bb35b1.tar.gz
ChangeLogTag:Mon Aug 2 08:55:17 2004 Douglas C. Schmidt <schmidt@cs.wustl.edu>
Diffstat (limited to 'ace/Containers_T.h')
-rw-r--r--ace/Containers_T.h99
1 files changed, 63 insertions, 36 deletions
diff --git a/ace/Containers_T.h b/ace/Containers_T.h
index 9c7fd552d49..f4ce021d7fb 100644
--- a/ace/Containers_T.h
+++ b/ace/Containers_T.h
@@ -1199,20 +1199,14 @@ template <class T, size_t ACE_SIZE>
class ACE_Fixed_Set;
/**
- * @class ACE_Fixed_Set_Iterator
- *
- * @brief Iterates through an unordered set.
+ * @class ACE_Fixed_Set_Iterator_Base
*
- * This implementation of an unordered set uses a fixed array.
- * Allows deletions while iteration is occurring.
+ * @brief Implements a common base class for iterators for a unordered set.
*/
template <class T, size_t ACE_SIZE>
-class ACE_Fixed_Set_Iterator
+class ACE_Fixed_Set_Iterator_Base
{
public:
- // = Initialization method.
- ACE_Fixed_Set_Iterator (ACE_Fixed_Set<T, ACE_SIZE> &s);
-
// = Iteration methods.
/// Pass back the <next_item> that hasn't been seen in the Set.
@@ -1230,33 +1224,44 @@ public:
/// Returns 1 when all items have been seen, else 0.
int done (void) const;
- /// Dump the state of an object.
- void dump (void) const;
-
/// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
-private:
+protected:
+ // = Initialization method.
+ ACE_Fixed_Set_Iterator_Base (ACE_Fixed_Set<T, ACE_SIZE> &s);
+
/// Set we are iterating over.
ACE_Fixed_Set<T, ACE_SIZE> &s_;
/// How far we've advanced over the set.
ssize_t next_;
-};
+
+ /// The number of non free items that the iterator had pointed at.
+ size_t iterated_items_;
+
+ /// Dump the state of an object.
+ void dump_i (void) const;
+
+ /// 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_i (T *&next_item);
+};
/**
- * @class ACE_Fixed_Set_Const_Iterator
+ * @class ACE_Fixed_Set_Iterator
*
- * @brief Iterates through a const unordered set.
+ * @brief Iterates through an unordered set.
*
* This implementation of an unordered set uses a fixed array.
+ * Allows deletions while iteration is occurring.
*/
template <class T, size_t ACE_SIZE>
-class ACE_Fixed_Set_Const_Iterator
+class ACE_Fixed_Set_Iterator : public ACE_Fixed_Set_Iterator_Base <T, ACE_SIZE>
{
public:
// = Initialization method.
- ACE_Fixed_Set_Const_Iterator (const ACE_Fixed_Set<T, ACE_SIZE> &s);
+ ACE_Fixed_Set_Iterator (ACE_Fixed_Set<T, ACE_SIZE> &s);
// = Iteration methods.
@@ -1264,32 +1269,53 @@ public:
/// 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);
+ /// Dump the state of an object.
+ void dump (void) const;
+
+ /// Remove the item where the itearetor is located at.
+ /// Returns 1 if it removes a item, else 0.
+ /// Pass back the removed <item>.
+ int remove (T *&item);
+
+ /// STL-like iterator dereference operator: returns a reference
+ /// to the node underneath the iterator.
+ T & operator* (void);
- /// Move to the first element in the set. Returns 0 if the
- /// set is empty, else 1.
- int first (void);
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+};
- /// Returns 1 when all items have been seen, else 0.
- int done (void) const;
+/**
+ * @class ACE_Fixed_Set_Const_Iterator
+ *
+ * @brief Iterates through a const unordered set.
+ *
+ * This implementation of an unordered set uses a fixed array.
+ */
+template <class T, size_t ACE_SIZE>
+class ACE_Fixed_Set_Const_Iterator : public ACE_Fixed_Set_Iterator_Base <T, ACE_SIZE>
+{
+public:
+ // = Initialization method.
+ ACE_Fixed_Set_Const_Iterator (const ACE_Fixed_Set<T, ACE_SIZE> &s);
+
+ // = 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 (const T *&next_item);
/// Dump the state of an object.
void dump (void) const;
+
+ /// STL-like iterator dereference operator: returns a reference
+ /// to the node underneath the iterator.
+ const T & operator* (void) const ;
/// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
-
-private:
- /// Set we are iterating over.
- const ACE_Fixed_Set<T, ACE_SIZE> &s_;
-
- /// How far we've advanced over the set.
- ssize_t next_;
};
-
/**
* @class ACE_Fixed_Set
*
@@ -1327,12 +1353,13 @@ template <class T, size_t ACE_SIZE>
class ACE_Fixed_Set
{
public:
+ friend class ACE_Fixed_Set_Iterator_Base<T, ACE_SIZE>;
friend class ACE_Fixed_Set_Iterator<T, ACE_SIZE>;
friend class ACE_Fixed_Set_Const_Iterator<T, ACE_SIZE>;
- // Trait definition.
+ // Trait definitions.
typedef ACE_Fixed_Set_Iterator<T, ACE_SIZE> ITERATOR;
- typedef ACE_Fixed_Set_Iterator<T, ACE_SIZE> CONST_ITERATOR;
+ typedef ACE_Fixed_Set_Const_Iterator<T, ACE_SIZE> CONST_ITERATOR;
// = Initialization and termination methods.
/// Default Constructor.