summaryrefslogtreecommitdiff
path: root/ace/Containers_T.h
diff options
context:
space:
mode:
authorcoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-03-26 21:18:51 +0000
committercoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-03-26 21:18:51 +0000
commitdc7b47e328ac184eed767b8287f918a46eb5d68e (patch)
treed2a03a59e7a8e39f4aeef13f0b7eb07b589b076c /ace/Containers_T.h
parent91a94f0f3fa63a897d5556805a23dee7a8bba7fb (diff)
downloadATCD-dc7b47e328ac184eed767b8287f918a46eb5d68e.tar.gz
ChangeLogTag:Mon Mar 26 13:00:37 2001 Carlos O'Ryan <coryan@uci.edu>
Diffstat (limited to 'ace/Containers_T.h')
-rw-r--r--ace/Containers_T.h529
1 files changed, 14 insertions, 515 deletions
diff --git a/ace/Containers_T.h b/ace/Containers_T.h
index 4521a2aa299..83f9dc14dc0 100644
--- a/ace/Containers_T.h
+++ b/ace/Containers_T.h
@@ -24,6 +24,18 @@
// Need by ACE_DLList_Node.
#include "ace/Containers.h"
+// Shared with "ace/Unbounded_Set.h"
+#include "ace/Node.h"
+
+// Backwards compatibility, please include "ace/Array_Base.h" directly.
+#include "ace/Array_Base.h"
+
+// Backwards compatibility, please include "ace/Unbounded_Set.h" directly.
+#include "ace/Unbounded_Set.h"
+
+// Backwards compatibility, please include "ace/Unbounded_Set.h" directly.
+#include "ace/Unbounded_Queue.h"
+
class ACE_Allocator;
/**
@@ -182,49 +194,8 @@ private:
//----------------------------------------
-// Forward declarations.
-template <class T> class ACE_Unbounded_Set;
-template <class T> class ACE_Unbounded_Set_Iterator;
-template <class T> class ACE_Unbounded_Queue;
-template <class T> class ACE_Unbounded_Queue_Iterator;
-template <class T> class ACE_Unbounded_Stack;
-template <class T> class ACE_Unbounded_Stack_Iterator;
-template <class T> class ACE_Ordered_MultiSet;
-template <class T> class ACE_Ordered_MultiSet_Iterator;
-
-/**
- * @class ACE_Node
- *
- * @brief Implementation element in a Queue, Set, and Stack.
- */
-template<class T>
-class ACE_Node
-{
-public:
- friend class ACE_Unbounded_Queue<T>;
- friend class ACE_Unbounded_Queue_Iterator<T>;
- friend class ACE_Unbounded_Set<T>;
- friend class ACE_Unbounded_Set_Iterator<T>;
- friend class ACE_Unbounded_Stack<T>;
- friend class ACE_Unbounded_Stack_Iterator<T>;
-
-# if ! defined (ACE_HAS_BROKEN_NOOP_DTORS)
- /// This isn't necessary, but it keeps some compilers happy.
- ~ACE_Node (void);
-# endif /* ! defined (ACE_HAS_BROKEN_NOOP_DTORS) */
-
-private:
- // = Initialization methods
- ACE_Node (const T &i, ACE_Node<T> *n);
- ACE_Node (ACE_Node<T> *n = 0, int = 0);
- ACE_Node (const ACE_Node<T> &n);
-
- /// Pointer to next element in the list of <ACE_Node>s.
- ACE_Node<T> *next_;
-
- /// Current value of the item in this node.
- T item_;
-};
+template<class T> class ACE_Ordered_MultiSet;
+template<class T> class ACE_Ordered_MultiSet_Iterator;
/**
* @class ACE_DNode
@@ -412,153 +383,6 @@ private:
};
template <class T>
-class ACE_Unbounded_Queue;
-
-/**
- * @class ACE_Unbounded_Queue_Iterator
- *
- * @brief Implement an iterator over an unbounded queue.
- */
-template <class T>
-class ACE_Unbounded_Queue_Iterator
-{
-public:
- // = Initialization method.
- ACE_Unbounded_Queue_Iterator (ACE_Unbounded_Queue<T> &q, int end = 0);
-
- // = Iteration methods.
-
- /// Pass back the <next_item> that hasn't been seen in the queue.
- /// 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 queue have been seen, else 1.
- int advance (void);
-
- /// Move to the first element in the queue. Returns 0 if the
- /// queue 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;
-
- /// 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 queue we're iterating over.
- ACE_Unbounded_Queue<T> &queue_;
-};
-
-/**
- * @class ACE_Unbounded_Queue
- *
- * @brief A Queue of "infinite" length.
- *
- * This implementation of an unbounded queue uses a circular
- * linked list with a dummy node.
- */
-template <class T>
-class ACE_Unbounded_Queue
-{
-public:
- friend class ACE_Unbounded_Queue_Iterator<T>;
-
- // Trait definition.
- typedef ACE_Unbounded_Queue_Iterator<T> ITERATOR;
-
- // = Initialization and termination methods.
- /// construction. Use user specified allocation strategy
- /// if specified.
- ACE_Unbounded_Queue (ACE_Allocator *alloc = 0);
-
- /// Copy constructor.
- ACE_Unbounded_Queue (const ACE_Unbounded_Queue<T> &);
-
- /// Assignment operator.
- void operator= (const ACE_Unbounded_Queue<T> &);
-
- /// construction.
- ~ACE_Unbounded_Queue (void);
-
- // = Check boundary conditions.
-
- /// Returns 1 if the container is empty, otherwise returns 0.
- int is_empty (void) const;
-
- /// Returns 1 if the container is full, otherwise returns 0.
- int is_full (void) const;
-
- // = Classic queue operations.
-
- /// Adds <new_item> to the tail of the queue. Returns 0 on success,
- /// -1 on failure.
- int enqueue_tail (const T &new_item);
-
- /// Adds <new_item> to the head of the queue. Returns 0 on success,
- /// -1 on failure.
- int enqueue_head (const T &new_item);
-
- /// Removes and returns the first <item> on the queue. Returns 0 on
- /// success, -1 if the queue was empty.
- int dequeue_head (T &item);
-
- // = Additional utility methods.
-
- /// Reset the <ACE_Unbounded_Queue> to be empty and release all its
- /// dynamically allocated resources.
- void reset (void);
-
- /// Get the <slot>th element in the set. Returns -1 if the element
- /// isn't in the range {0..<size> - 1}, else 0.
- int get (T *&item, size_t slot = 0) const;
-
- /**
- * Set the <slot>th element in the set. Will pad out the set with
- * empty nodes if <slot> is beyond the range {0..<size> - 1}.
- * Returns -1 on failure, 0 if <slot> isn't initially in range, and
- * 0 otherwise.
- */
- int set (const T &item, size_t slot);
-
- /// The number of items in the queue.
- size_t size (void) const;
-
- /// Dump the state of an object.
- void dump (void) const;
-
- // = STL-styled unidirectional iterator factory.
- ACE_Unbounded_Queue_Iterator<T> begin (void);
- ACE_Unbounded_Queue_Iterator<T> end (void);
-
- /// Declare the dynamic allocation hooks.
- ACE_ALLOC_HOOK_DECLARE;
-
-protected:
- /// Delete all the nodes in the queue.
- void delete_nodes (void);
-
- /// Copy nodes into this queue.
- void copy_nodes (const ACE_Unbounded_Queue<T> &);
-
- /// Pointer to the dummy node in the circular linked Queue.
- ACE_Node<T> *head_;
-
- /// Current size of the queue.
- size_t cur_size_;
-
- /// Allocation Strategy of the queue.
- ACE_Allocator *allocator_;
-};
-
-template <class T>
class ACE_Double_Linked_List;
/**
@@ -1128,163 +952,6 @@ private:
ACE_DLList<T> *list_;
};
-/**
- * @class ACE_Unbounded_Set_Iterator
- *
- * @brief Implement an iterator over an unbounded set.
- */
-template <class T>
-class ACE_Unbounded_Set_Iterator
-{
-public:
- // = Initialization method.
- ACE_Unbounded_Set_Iterator (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_Iterator<T> operator++ (int);
-
- /// Prefix advance.
- ACE_Unbounded_Set_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_Iterator<T> &) const;
- int operator!= (const ACE_Unbounded_Set_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.
- ACE_Unbounded_Set<T> *set_;
-};
-
-/**
- * @class ACE_Unbounded_Set
- *
- * @brief Implement a simple unordered set of <T> of unbounded size.
- *
- * This implementation of an unordered set uses a circular
- * linked list with a dummy node. This implementation does not
- * allow duplicates, but it maintains FIFO ordering of insertions.
- */
-template <class T>
-class ACE_Unbounded_Set
-{
-public:
- friend class ACE_Unbounded_Set_Iterator<T>;
-
- // Trait definition.
- typedef ACE_Unbounded_Set_Iterator<T> ITERATOR;
- typedef ACE_Unbounded_Set_Iterator<T> iterator;
-
- // = Initialization and termination methods.
- /// Constructor. Use user specified allocation strategy
- /// if specified.
- ACE_Unbounded_Set (ACE_Allocator *alloc = 0);
-
- /// Copy constructor.
- ACE_Unbounded_Set (const ACE_Unbounded_Set<T> &);
-
- /// Assignment operator.
- void operator= (const ACE_Unbounded_Set<T> &);
-
- /// Destructor.
- ~ACE_Unbounded_Set (void);
-
- // = Check boundary conditions.
-
- /// Returns 1 if the container is empty, otherwise returns 0.
- int is_empty (void) const;
-
- /// Returns 1 if the container is full, otherwise returns 0.
- int is_full (void) const;
-
- // = Classic unordered set operations.
-
- /**
- * Insert <new_item> into the set (doesn't allow duplicates).
- * Returns -1 if failures occur, 1 if item is already present, else
- * 0.
- */
- int insert (const T &new_item);
-
- /**
- * Remove first occurrence of <item> from the set. Returns 0 if
- * it removes the item, -1 if it can't find the item, and -1 if a
- * failure occurs.
- */
- int remove (const T &item);
-
- /// Finds if <item> occurs in the set. Returns 0 if find succeeds,
- /// else -1.
- int find (const T &item) const;
-
- /// Size of the set.
- size_t size (void) const;
-
- /// Dump the state of an object.
- void dump (void) const;
-
- /// Reset the <ACE_Unbounded_Set> to be empty.
- void reset (void);
-
- // = STL-styled unidirectional iterator factory.
- ACE_Unbounded_Set_Iterator<T> begin (void);
- ACE_Unbounded_Set_Iterator<T> end (void);
-
- /// Declare the dynamic allocation hooks.
- ACE_ALLOC_HOOK_DECLARE;
-
-private:
- /// Insert <item> at the tail of the set (doesn't check for
- /// duplicates).
- int insert_tail (const T &item);
-
- /// Delete all the nodes in the Set.
- void delete_nodes (void);
-
- /// Copy nodes into this set.
- void copy_nodes (const ACE_Unbounded_Set<T> &);
-
- /// Head of the linked list of Nodes.
- ACE_Node<T> *head_;
-
- /// Current size of the set.
- size_t cur_size_;
-
- /// Allocation strategy of the set.
- ACE_Allocator *allocator_;
-};
-
// Forward declaration.
template <class T, size_t ACE_SIZE>
class ACE_Fixed_Set;
@@ -1744,130 +1411,6 @@ private:
// ****************************************************************
-// Forward declaration.
-template <class T> class ACE_Array_Iterator;
-
-/**
- * @class ACE_Array_Base
- *
- * @brief Implement a simple dynamic array
- *
- * This parametric class implements a simple dynamic array;
- * resizing must be controlled by the user. No comparison or find
- * operations are implemented.
- */
-template<class T>
-class ACE_Array_Base
-{
-public:
-
- // Define a "trait"
- typedef T TYPE;
- typedef ACE_Array_Iterator<T> ITERATOR;
-
- // = Initialization and termination methods.
-
- /// Dynamically create an uninitialized array.
- ACE_Array_Base (size_t size = 0,
- ACE_Allocator *alloc = 0);
-
- /// Dynamically initialize the entire array to the <default_value>.
- ACE_Array_Base (size_t size,
- const T &default_value,
- ACE_Allocator *alloc = 0);
-
- /**
- * The copy constructor performs initialization by making an exact
- * copy of the contents of parameter <s>, i.e., *this == s will
- * return true.
- */
- ACE_Array_Base (const ACE_Array_Base<T> &s);
-
- /**
- * Assignment operator performs an assignment by making an exact
- * copy of the contents of parameter <s>, i.e., *this == s will
- * return true. Note that if the <max_size_> of <array_> is >= than
- * <s.max_size_> we can copy it without reallocating. However, if
- * <max_size_> is < <s.max_size_> we must delete the <array_>,
- * reallocate a new <array_>, and then copy the contents of <s>.
- */
- void operator= (const ACE_Array_Base<T> &s);
-
- /// Clean up the array (e.g., delete dynamically allocated memory).
- ~ACE_Array_Base (void);
-
- // = Set/get methods.
-
- /// Set item in the array at location <slot>. Doesn't
- /// perform range checking.
- T &operator [] (size_t slot);
-
- /// Get item in the array at location <slot>. Doesn't
- /// perform range checking.
- const T &operator [] (size_t slot) const;
-
- /// Set an item in the array at location <slot>. Returns
- /// -1 if <slot> is not in range, else returns 0.
- int set (const T &new_item, size_t slot);
-
- /**
- * Get an item in the array at location <slot>. Returns -1 if
- * <slot> is not in range, else returns 0. Note that this function
- * copies the item. If you want to avoid the copy, you can use
- * the const operator [], but then you'll be responsible for range checking.
- */
- int get (T &item, size_t slot) const;
-
- /// Returns the <cur_size_> of the array.
- size_t size (void) const;
-
- /**
- * Changes the size of the array to match <new_size>.
- * It copies the old contents into the new array.
- * Return -1 on failure.
- */
- int size (size_t new_size);
-
- /// Returns the <max_size_> of the array.
- size_t max_size (void) const;
-
- /**
- * Changes the size of the array to match <new_size>.
- * It copies the old contents into the new array.
- * Return -1 on failure.
- * It does not affect new_size
- */
- int max_size (size_t new_size);
-
-private:
- /// Returns 1 if <slot> is within range, i.e., 0 >= <slot> <
- /// <cur_size_>, else returns 0.
- int in_range (size_t slot) const;
-
- /// Maximum size of the array, i.e., the total number of <T> elements
- /// in <array_>.
- size_t max_size_;
-
- /**
- * Current size of the array. This starts out being == to
- * <max_size_>. However, if we are assigned a smaller array, then
- * <cur_size_> will become less than <max_size_>. The purpose of
- * keeping track of both sizes is to avoid reallocating memory if we
- * don't have to.
- */
- size_t cur_size_;
-
- /// Pointer to the array's storage buffer.
- T *array_;
-
- /// Allocation strategy of the ACE_Array_Base.
- ACE_Allocator *allocator_;
-
- friend class ACE_Array_Iterator<T>;
-};
-
-// ****************************************************************
-
/**
* @class ACE_Array
*
@@ -1932,50 +1475,6 @@ public:
int operator!= (const ACE_Array<T> &s) const;
};
-/**
- * @class ACE_Array_Iterator
- *
- * @brief Implement an iterator over an ACE_Array.
- *
- * This iterator is safe in the face of array element deletions.
- * But it is NOT safe if the array is resized (via the ACE_Array
- * assignment operator) during iteration. That would be very
- * odd, and dangerous.
- */
-template <class T>
-class ACE_Array_Iterator
-{
-public:
- // = Initialization method.
- ACE_Array_Iterator (ACE_Array_Base<T> &);
-
- // = Iteration methods.
-
- /// Pass back the <next_item> that hasn't been seen in the Array.
- /// Returns 0 when all items have been seen, else 1.
- int next (T *&next_item);
-
- /// Move forward by one element in the Array. Returns 0 when all the
- /// items in the Array have been seen, else 1.
- int advance (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;
-
- /// Declare the dynamic allocation hooks.
- ACE_ALLOC_HOOK_DECLARE;
-
-private:
- /// Pointer to the current item in the iteration.
- u_int current_;
-
- /// Pointer to the Array we're iterating over.
- ACE_Array_Base<T> &array_;
-};
-
#if defined (__ACE_INLINE__)
#include "ace/Containers_T.i"
#endif /* __ACE_INLINE__ */