3 //=============================================================================
7 * $Id: Containers_T.h 82588 2008-08-11 13:37:41Z johnnyw $
9 * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
11 //=============================================================================
13 #ifndef ACE_CONTAINERS_T_H
14 #define ACE_CONTAINERS_T_H
16 #include /**/ "ace/pre.h"
18 #include /**/ "ace/config-all.h"
20 #if !defined (ACE_LACKS_PRAGMA_ONCE)
22 #endif /* ACE_LACKS_PRAGMA_ONCE */
24 // Need by ACE_DLList_Node.
25 #include "ace/Containers.h"
27 // Shared with "ace/Unbounded_Set.h"
30 // Backwards compatibility, please include "ace/Array_Base.h" directly.
31 #include "ace/Array_Base.h"
33 // Backwards compatibility, please include "ace/Unbounded_Set.h" directly.
34 #include "ace/Unbounded_Set.h"
36 // Backwards compatibility, please include "ace/Unbounded_Queue.h" directly.
37 #include "ace/Unbounded_Queue.h"
39 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
45 * @class ACE_Bounded_Stack
47 * @brief Implement a generic LIFO abstract data type.
49 * This implementation of a Stack uses a bounded array
50 * that is allocated dynamically. The Stack interface
51 * provides the standard constant time push, pop, and top
54 * <b> Requirements and Performance Characteristics</b>
55 * - Internal Structure
57 * - Duplicates allowed?
59 * - Random access allowed?
63 * - Insert/replace speed
65 * - Iterator still valid after change to container?
67 * - Frees memory for removed elements?
71 * - Requirements for contained type
72 * -# Default constructor
78 class ACE_Bounded_Stack
81 // = Initialization, assignment, and termination methods.
83 /// Initialize a new empty stack with the provided size..
85 * Initialize and allocate space for a new Bounded_Stack with the provided
88 ACE_Bounded_Stack (size_t size
);
90 /// Initialize the stack to be a copy of the stack provided.
92 * Initialize the stack to be an exact copy of the Bounded_Stack provided
95 ACE_Bounded_Stack (const ACE_Bounded_Stack
<T
> &s
);
97 /// Assignment operator
99 * Perform a deep copy operation using the Bounded_Stack parameter. If the
100 * capacity of the lhs isn't sufficient for the rhs, then the underlying data
101 * structure will be reallocated to accomadate the larger number of elements.
103 void operator= (const ACE_Bounded_Stack
<T
> &s
);
105 /// Perform actions needed when stack goes out of scope.
107 * Deallocate the memory used by the Bounded_Stack.
109 ~ACE_Bounded_Stack (void);
111 // = Classic Stack operations.
113 ///Add an element to the top of the stack.
115 * Place a new item on top of the stack. Returns -1 if the stack
116 * is already full, 0 if the stack is not already full, and -1 if
119 int push (const T
&new_item
);
121 ///Remove an item from the top of stack.
123 * Remove and return the top stack item. Returns -1 if the stack is
124 * already empty, 0 if the stack is not already empty, and -1 if
129 ///Examine the contents of the top of stack.
131 * Return top stack item without removing it. Returns -1 if the
132 * stack is already empty, 0 if the stack is not already empty, and
133 * -1 if failure occurs.
135 int top (T
&item
) const;
137 // = Check boundary conditions.
139 /// Returns 1 if the container is empty, otherwise returns 0.
141 * Performs constant time check to determine if the stack is empty.
143 int is_empty (void) const;
145 /// Returns 1 if the container is full, otherwise returns 0.
147 * Performs constant time check to determine if the stack is at capacity.
149 int is_full (void) const;
151 /// The number of items in the stack.
153 * Return the number of items currently in the stack.
155 size_t size (void) const;
157 /// Dump the state of an object.
158 void dump (void) const;
160 /// Declare the dynamic allocation hooks.
161 ACE_ALLOC_HOOK_DECLARE
;
164 /// Size of the dynamically allocated data.
167 /// Keeps track of the current top of stack.
170 /// Holds the stack's contents.
174 //----------------------------------------
178 * @class ACE_Fixed_Stack
180 * @brief Implement a generic LIFO abstract data type.
182 * This implementation of a Stack uses a fixed array
183 * with the size fixed at instantiation time.
185 * <b> Requirements and Performance Characteristics</b>
186 * - Internal Structure
188 * - Duplicates allowed?
190 * - Random access allowed?
194 * - Insert/replace speed
196 * - Iterator still valid after change to container?
198 * - Frees memory for removed elements?
200 * - Items inserted by
202 * - Requirements for contained type
203 * -# Default constructor
204 * -# Copy constructor
208 template <class T
, size_t ACE_SIZE
>
209 class ACE_Fixed_Stack
212 // = Initialization, assignment, and termination methods.
213 /// Initialize a new stack so that it is empty.
215 * Initialize an empty stack.
217 ACE_Fixed_Stack (void);
219 /// The copy constructor (performs initialization).
221 * Initialize the stack and copy the provided stack into the current stack.
223 ACE_Fixed_Stack (const ACE_Fixed_Stack
<T
, ACE_SIZE
> &s
);
225 /// Assignment operator (performs assignment).
227 * Perform a deep copy of the provided stack.
229 void operator= (const ACE_Fixed_Stack
<T
, ACE_SIZE
> &s
);
231 /// Perform actions needed when stack goes out of scope.
235 ~ACE_Fixed_Stack (void);
237 // = Classic Stack operations.
239 ///Constant time placement of element on top of stack.
241 * Place a new item on top of the stack. Returns -1 if the stack
242 * is already full, 0 if the stack is not already full, and -1 if
245 int push (const T
&new_item
);
247 ///Constant time removal of top of stack.
249 * Remove and return the top stack item. Returns -1 if the stack is
250 * already empty, 0 if the stack is not already empty, and -1 if
255 ///Constant time examination of top of stack.
257 * Return top stack item without removing it. Returns -1 if the
258 * stack is already empty, 0 if the stack is not already empty, and
259 * -1 if failure occurs.
261 int top (T
&item
) const;
263 // = Check boundary conditions.
265 /// Returns 1 if the container is empty, otherwise returns 0.
267 * Performs constant time check to see if stack is empty.
269 int is_empty (void) const;
271 /// Returns 1 if the container is full, otherwise returns 0.
273 * Performs constant time check to see if stack is full.
275 int is_full (void) const;
277 /// The number of items in the stack.
279 * Constant time access to the current size of the stack.
281 size_t size (void) const;
283 /// Dump the state of an object.
284 void dump (void) const;
286 /// Declare the dynamic allocation hooks.
287 ACE_ALLOC_HOOK_DECLARE
;
290 /// Size of the allocated data.
293 /// Keeps track of the current top of stack.
296 /// Holds the stack's contents.
300 //----------------------------------------
302 template<class T
> class ACE_Ordered_MultiSet
;
303 template<class T
> class ACE_Ordered_MultiSet_Iterator
;
308 * @brief Implementation element in a bilinked list.
313 friend class ACE_Ordered_MultiSet
<T
>;
314 friend class ACE_Ordered_MultiSet_Iterator
<T
>;
318 /// This isn't necessary, but it keeps some compilers happy.
323 // = Initialization methods
324 ACE_DNode (const T
&i
, ACE_DNode
<T
> *n
= 0, ACE_DNode
<T
> *p
= 0);
326 /// Pointer to next element in the list of {ACE_DNode}s.
329 /// Pointer to previous element in the list of {ACE_DNode}s.
332 /// Current value of the item in this node.
339 * @class ACE_Unbounded_Stack
341 * @brief Implement a generic LIFO abstract data type.
343 * This implementation of an unbounded Stack uses a linked list.
344 * If you use the {insert} or {remove} methods you should keep
345 * in mind that duplicate entries aren't allowed. In general,
346 * therefore, you should avoid the use of these methods since
347 * they aren't really part of the ADT stack. The stack is implemented
348 * as a doubly linked list.
350 * <b> Requirements and Performance Characteristics</b>
351 * - Internal Structure
353 * - Duplicates allowed?
355 * - Random access allowed?
359 * - Insert/replace speed
361 * - Iterator still valid after change to container?
363 * - Frees memory for removed elements?
365 * - Items inserted by
367 * - Requirements for contained type
368 * -# Default constructor
369 * -# Copy constructor
374 class ACE_Unbounded_Stack
377 friend class ACE_Unbounded_Stack_Iterator
<T
>;
380 typedef ACE_Unbounded_Stack_Iterator
<T
> ITERATOR
;
382 // = Initialization, assignment, and termination methods.
383 /// Initialize a new stack so that it is empty. Use user defined
384 /// allocation strategy if specified.
386 * Initialize an empty stack using the user specified allocation strategy
389 ACE_Unbounded_Stack (ACE_Allocator
*the_allocator
= 0);
391 /// The copy constructor (performs initialization).
393 * Initialize this stack to be an exact copy of {s}.
395 ACE_Unbounded_Stack (const ACE_Unbounded_Stack
<T
> &s
);
397 /// Assignment operator (performs assignment).
399 * Perform a deep copy of the rhs into the lhs.
401 void operator= (const ACE_Unbounded_Stack
<T
> &s
);
403 /// Perform actions needed when stack goes out of scope.
405 * Destroy the underlying list for the stack.
407 ~ACE_Unbounded_Stack (void);
409 // = Classic Stack operations.
412 ///Push an element onto the top of stack.
414 * Place a new item on top of the stack. Returns -1 if the stack
415 * is already full, 0 if the stack is not already full, and -1 if
418 int push (const T
&new_item
);
420 ///Pop the top element of the stack.
422 * Remove and return the top stack item. Returns -1 if the stack is
423 * already empty, 0 if the stack is not already empty, and -1 if
428 ///Examine the top of the stack.
430 * Return top stack item without removing it. Returns -1 if the
431 * stack is already empty, 0 if the stack is not already empty, and
432 * -1 if failure occurs.
434 int top (T
&item
) const;
436 // = Check boundary conditions.
438 /// Returns 1 if the container is empty, otherwise returns 0.
440 * Constant time check to see if the stack is empty.
442 int is_empty (void) const;
444 /// Returns 1 if the container is full, otherwise returns 0.
446 * Always resturns 0 since the stack is unbounded.
448 int is_full (void) const;
450 // = Auxiliary methods (not strictly part of the Stack ADT).
452 ///Linear Insert of an item.
454 * Insert {new_item} into the Stack at the head (but doesn't allow
455 * duplicates). Returns -1 if failures occur, 1 if item is already
456 * present (i.e., no duplicates are allowed), else 0.
458 int insert (const T
&new_item
);
460 /// Remove @a item from the Stack. Returns 0 if it removes the item,
461 /// -1 if it can't find the item, and -1 if a failure occurs.
463 * Linear remove operation.
465 int remove (const T
&item
);
467 /// Finds if @a item occurs the set. Returns 0 if finds, else -1.
469 * Linear find operation.
471 int find (const T
&item
) const;
473 /// The number of items in the stack.
475 * Constant time access to the current stack size.
477 size_t size (void) const;
479 /// Dump the state of an object.
480 void dump (void) const;
482 /// Declare the dynamic allocation hooks.
483 ACE_ALLOC_HOOK_DECLARE
;
486 /// Delete all the nodes in the stack.
487 void delete_all_nodes (void);
489 /// Copy all nodes from {s} to {this}.
490 void copy_all_nodes (const ACE_Unbounded_Stack
<T
> &s
);
492 /// Head of the linked list of Nodes.
495 /// Current size of the stack.
498 /// Allocation strategy of the stack.
499 ACE_Allocator
*allocator_
;
503 * @class ACE_Unbounded_Stack_Iterator
505 * @brief Implement an iterator over an unbounded Stack.
508 class ACE_Unbounded_Stack_Iterator
511 // = Initialization method.
512 /// Move to the first element in the {stack}.
513 ACE_Unbounded_Stack_Iterator (ACE_Unbounded_Stack
<T
> &stack
);
515 // = Iteration methods.
517 /// Pass back the @a next_item that hasn't been seen in the Stack.
518 /// Returns 0 when all items have been seen, else 1.
519 int next (T
*&next_item
);
521 /// Move forward by one element in the Stack. Returns 0 when all the
522 /// items in the Stack have been seen, else 1.
525 /// Move to the first element in the Stack. Returns 0 if the
526 /// Stack is empty, else 1.
529 /// Returns 1 when all items have been seen, else 0.
530 int done (void) const;
532 /// Dump the state of an object.
533 void dump (void) const;
535 /// Declare the dynamic allocation hooks.
536 ACE_ALLOC_HOOK_DECLARE
;
539 /// Pointer to the current node in the iteration.
540 ACE_Node
<T
> *current_
;
542 /// Pointer to the Stack we're iterating over.
543 ACE_Unbounded_Stack
<T
> &stack_
;
547 class ACE_Double_Linked_List
;
550 * @class ACE_Double_Linked_List_Iterator_Base
552 * @brief Implements a common base class for iterators for a double
556 class ACE_Double_Linked_List_Iterator_Base
559 // = Iteration methods.
561 /// Passes back the {entry} under the iterator. Returns 0 if the
562 /// iteration has completed, otherwise 1
563 int next (T
*&) const;
566 * @deprecated Return the address of next (current) unvisited item in
567 * the list. 0 if there is no more element available.
569 T
*next (void) const;
571 /// Returns 1 when all items have been seen, else 0.
572 int done (void) const;
574 /// STL-like iterator dereference operator: returns a reference
575 /// to the node underneath the iterator.
576 T
& operator* (void) const ;
579 * Retasks the iterator to iterate over a new
580 * Double_Linked_List. This allows clients to reuse an iterator
581 * without incurring the constructor overhead. If you do use this,
582 * be aware that if there are more than one reference to this
583 * iterator, the other "clients" may be very bothered when their
584 * iterator changes. @@ Here be dragons. Comments?
586 void reset (ACE_Double_Linked_List
<T
> &);
588 /// Declare the dynamic allocation hooks.
589 ACE_ALLOC_HOOK_DECLARE
;
592 // = Initialization methods.
595 ACE_Double_Linked_List_Iterator_Base (const ACE_Double_Linked_List
<T
> &);
597 /// Copy constructor.
598 ACE_Double_Linked_List_Iterator_Base (const
599 ACE_Double_Linked_List_Iterator_Base
<T
>
602 // = Iteration methods.
604 * Move to the first element of the list. Returns 0 if the list is
606 * @note the head of the ACE_DLList is actually a null entry, so the
607 * first element is actually the 2n'd entry
611 /// Move to the last element of the list. Returns 0 if the list is
616 * Check if we reach the end of the list. Can also be used to get
617 * the *current* element in the list. Return the address of the
618 * current item if there are still elements left , 0 if we run out
621 T
*not_done (void) const ;
623 /// Advance to the next element in the list. Return the address of the
624 /// next element if there are more, 0 otherwise.
625 T
*do_advance (void);
627 /// Retreat to the previous element in the list. Return the address
628 /// of the previous element if there are more, 0 otherwise.
629 T
*do_retreat (void);
631 /// Dump the state of an object.
632 void dump_i (void) const;
634 /// Remember where we are.
637 const ACE_Double_Linked_List
<T
> *dllist_
;
641 * @class ACE_Double_Linked_List_Iterator
643 * @brief Implements an iterator for a double linked list ADT
645 * Iterate thru the double-linked list. This class provides
646 * an interface that let users access the internal element
647 * addresses directly. Notice {class T} must declare
648 * ACE_Double_Linked_List<T>,
649 * ACE_Double_Linked_List_Iterator_Base <T> and
650 * ACE_Double_Linked_List_Iterator as friend classes and class T
651 * should also have data members T* next_ and T* prev_.
654 class ACE_Double_Linked_List_Iterator
: public ACE_Double_Linked_List_Iterator_Base
<T
>
657 // = Initialization method.
658 ACE_Double_Linked_List_Iterator (const ACE_Double_Linked_List
<T
> &);
661 * Retasks the iterator to iterate over a new
662 * Double_Linked_List. This allows clients to reuse an iterator
663 * without incurring the constructor overhead. If you do use this,
664 * be aware that if there are more than one reference to this
665 * iterator, the other "clients" may be very bothered when their
667 * @@ Here be dragons. Comments?
669 void reset (ACE_Double_Linked_List
<T
> &);
671 /// Move to the first element in the list. Returns 0 if the
672 /// list is empty, else 1.
675 /// Move forward by one element in the list. Returns 0 when all the
676 /// items in the list have been seen, else 1.
680 * Advance the iterator while removing the original item from the
681 * list. Return a pointer points to the original (removed) item.
682 * If @a dont_remove equals false, this function behaves like {advance}
683 * but return 0 (NULL) instead.
685 T
* advance_and_remove (bool dont_remove
);
687 // = STL-style iteration methods
690 ACE_Double_Linked_List_Iterator
<T
> & operator++ (void);
693 ACE_Double_Linked_List_Iterator
<T
> operator++ (int);
696 ACE_Double_Linked_List_Iterator
<T
> & operator-- (void);
699 ACE_Double_Linked_List_Iterator
<T
> operator-- (int);
701 /// Dump the state of an object.
702 void dump (void) const;
704 /// Declare the dynamic allocation hooks.
705 ACE_ALLOC_HOOK_DECLARE
;
709 * @class ACE_Double_Linked_List_Reverse_Iterator
711 * @brief Implements a reverse iterator for a double linked list ADT
713 * Iterate backwards over the double-linked list. This class
714 * provide an interface that let users access the internal
715 * element addresses directly, which seems to break the
716 * encapsulation. Notice {class T} must declare
717 * ACE_Double_Linked_List<T>,
718 * ACE_Double_Linked_List_Iterator_Base <T> and
719 * ACE_Double_Linked_List_Iterator as friend classes and class T
720 * should also have data members T* next_ and T* prev_.
723 class ACE_Double_Linked_List_Reverse_Iterator
: public ACE_Double_Linked_List_Iterator_Base
<T
>
726 // = Initialization method.
727 ACE_Double_Linked_List_Reverse_Iterator (ACE_Double_Linked_List
<T
> &);
730 * Retasks the iterator to iterate over a new
731 * Double_Linked_List. This allows clients to reuse an iterator
732 * without incurring the constructor overhead. If you do use this,
733 * be aware that if there are more than one reference to this
734 * iterator, the other "clients" may be very bothered when their
736 * @@ Here be dragons. Comments?
738 void reset (ACE_Double_Linked_List
<T
> &);
740 /// Move to the first element in the list. Returns 0 if the
741 /// list is empty, else 1.
744 /// Move forward by one element in the list. Returns 0 when all the
745 /// items in the list have been seen, else 1.
749 * Advance the iterator while removing the original item from the
750 * list. Return a pointer points to the original (removed) item.
751 * If @a dont_remove equals false, this function behaves like {advance}
752 * but return 0 (NULL) instead.
754 T
* advance_and_remove (bool dont_remove
);
756 // = STL-style iteration methods
759 ACE_Double_Linked_List_Reverse_Iterator
<T
> & operator++ (void);
762 ACE_Double_Linked_List_Reverse_Iterator
<T
> operator++ (int);
765 ACE_Double_Linked_List_Reverse_Iterator
<T
> & operator-- (void);
768 ACE_Double_Linked_List_Reverse_Iterator
<T
> operator-- (int);
770 /// Dump the state of an object.
771 void dump (void) const;
773 /// Declare the dynamic allocation hooks.
774 ACE_ALLOC_HOOK_DECLARE
;
779 * @class ACE_Double_Linked_List
781 * @brief A double-linked list implementation.
783 * This implementation of an unbounded double-linked list uses a
784 * circular linked list with a dummy node. It is pretty much
785 * like the {ACE_Unbounded_Queue} except that it allows removing
786 * of a specific element from a specific location.
787 * Notice that this class is an implementation of a very simple
788 * data structure. This is *NOT* a container class. You can use the
789 * class to implement other contains classes but it is *NOT* a
790 * general purpose container class.
791 * The parameter class *MUST* have members T* prev and T* next
792 * and users of this class are responsible to follow the general
793 * rules of using double-linked lists to maintaining the list
795 * If you need a double linked container class, use the DLList
796 * class which is a container but delegates to the Double_Linked_List
799 * <b> Requirements and Performance Characteristics</b>
800 * - Internal Structure
802 * - Duplicates allowed?
804 * - Random access allowed?
808 * - Insert/replace speed
810 * - Iterator still valid after change to container?
812 * - Frees memory for removed elements?
814 * - Items inserted by
816 * - Requirements for contained type
817 * -# Default constructor
818 * -# Copy constructor
823 class ACE_Double_Linked_List
826 friend class ACE_Double_Linked_List_Iterator_Base
<T
>;
827 friend class ACE_Double_Linked_List_Iterator
<T
>;
828 friend class ACE_Double_Linked_List_Reverse_Iterator
<T
>;
831 typedef ACE_Double_Linked_List_Iterator
<T
> ITERATOR
;
832 typedef ACE_Double_Linked_List_Reverse_Iterator
<T
> REVERSE_ITERATOR
;
834 // = Initialization and termination methods.
835 /// construction. Use user specified allocation strategy
838 * Initialize an empy list using the allocation strategy specified by the user.
839 * If none is specified, then use default allocation strategy.
841 ACE_Double_Linked_List (ACE_Allocator
*the_allocator
= 0);
843 /// Copy constructor.
845 * Create a double linked list that is a copy of the provided
848 ACE_Double_Linked_List (const ACE_Double_Linked_List
<T
> &);
850 /// Assignment operator.
852 * Perform a deep copy of the provided list by first deleting the nodes of the
853 * lhs and then copying the nodes of the rhs.
855 void operator= (const ACE_Double_Linked_List
<T
> &);
859 * Clean up the memory allocated for the nodes of the list.
861 ~ACE_Double_Linked_List (void);
863 // = Check boundary conditions.
865 /// Returns 1 if the container is empty, 0 otherwise.
867 * Performs constant time check to determine if the list is empty.
869 int is_empty (void) const;
871 /// The list is unbounded, so this always returns 0.
873 * Since the list is unbounded, the method simply returns 0.
875 int is_full (void) const;
877 // = Classic queue operations.
879 /// Adds @a new_item to the tail of the list. Returns the new item
880 /// that was inserted.
882 * Provides constant time insertion at the end of the list structure.
884 T
*insert_tail (T
*new_item
);
886 /// Adds @a new_item to the head of the list.Returns the new item that
889 * Provides constant time insertion at the head of the list.
891 T
*insert_head (T
*new_item
);
893 /// Removes the head of the list and returns a pointer to that item.
895 * Removes and returns the first {item} in the list. Returns
896 * internal node's address on success, 0 if the queue was empty.
897 * This method will *not* free the internal node.
899 T
* delete_head (void);
901 /// Removes the tail of the list and returns a pointer to that item.
903 * Removes and returns the last {item} in the list. Returns
904 * internal nodes's address on success, 0 if the queue was
905 * empty. This method will *not* free the internal node.
907 T
*delete_tail (void);
909 // = Additional utility methods.
913 * Reset the {ACE_Double_Linked_List} to be empty.
914 * Notice that since no one is interested in the items within,
915 * This operation will delete all items.
919 /// Get the {slot}th element in the set. Returns -1 if the element
920 /// isn't in the range {0..{size} - 1}, else 0.
922 * Iterates through the list to the desired index and assigns the provides pointer
923 * with the address of the node occupying that index.
925 int get (T
*&item
, size_t slot
= 0);
927 /// The number of items in the queue.
929 * Constant time call to return the current size of the list.
931 size_t size (void) const;
933 /// Dump the state of an object.
934 void dump (void) const;
936 /// Use DNode address directly.
938 * Constant time removal of an item from the list using it's address.
942 /// Declare the dynamic allocation hooks.
943 ACE_ALLOC_HOOK_DECLARE
;
946 /// Delete all the nodes in the list.
948 * Removes and deallocates memory for all of the list nodes.
950 void delete_nodes (void);
952 /// Copy nodes from {rhs} into this list.
954 * Copy the elements of the provided list by allocated new nodes and assigning
955 * them with the proper data.
957 void copy_nodes (const ACE_Double_Linked_List
<T
> &rhs
);
959 /// Setup header pointer. Called after we create the head node in ctor.
961 * Initialize the head pointer so that the list has a dummy node.
963 void init_head (void);
965 ///Constant time insert a new item into the list structure.
967 * Insert a @a new_item into the list. It will be added before
968 * or after @a old_item. Default is to insert the new item *after*
969 * {head_}. Return 0 if succeed, -1 if error occured.
971 int insert_element (T
*new_item
,
975 ///Constant time delete an item from the list structure.
977 * Remove @a item from the list. Return 0 if succeed, -1 otherwise.
978 * Notice that this function checks if item is {head_} and either its
979 * {next_} or {prev_} is NULL. The function resets item's {next_} and
980 * {prev_} to 0 to prevent clobbering the double-linked list if a user
981 * tries to remove the same node again.
983 int remove_element (T
*item
);
985 /// Head of the circular double-linked list.
988 /// Size of this list.
991 /// Allocation Strategy of the queue.
992 ACE_Allocator
*allocator_
;
996 template <class T
> class ACE_DLList
;
997 template <class T
> class ACE_DLList_Iterator
;
998 template <class T
> class ACE_DLList_Reverse_Iterator
;
1000 typedef ACE_Double_Linked_List
<ACE_DLList_Node
> ACE_DLList_Base
;
1002 //typedef ACE_Double_Linked_List_Iterator <ACE_DLList_Node>
1003 // ACE_DLList_Iterator_Base;
1004 //typedef ACE_Double_Linked_List_Reverse_Iterator <ACE_DLList_Node>
1005 // ACE_DLList_Reverse_Iterator_Base;
1006 //@@ These two typedefs (inherited from James Hu's original design)
1007 // have been removed because Sun CC 4.2 had problems with it. I guess
1008 // having the DLList_Iterators inheriting from a class which is
1009 // actually a typedef leads to problems. #define'ing rather than
1010 // typedef'ing worked, but as per Carlos's reccomendation, I'm just
1011 // replacing all references to the base classes with their actual
1012 // type. Matt Braun (6/15/99)
1017 * @brief A double-linked list container class.
1019 * ACE_DLList is a simple, unbounded container implemented using a
1020 * double-linked list. It is critical to remember that ACE_DLList inherits
1021 * from ACE_Double_Linked_List, wrapping each T pointer in a ACE_DLList_Node
1022 * object which satisfies the next/prev pointer requirements imposed by
1023 * ACE_Double_Linked_List.
1025 * Each item inserted to an ACE_DLList is a pointer to a T object. The
1026 * caller is responsible for lifetime of the T object. ACE_DLList takes no
1027 * action on the T object; it is not copied on insertion and it is not
1028 * deleted on removal from the ACE_DLList.
1031 class ACE_DLList
: public ACE_DLList_Base
1033 friend class ACE_DLList_Node
;
1034 friend class ACE_Double_Linked_List_Iterator
<T
>;
1035 friend class ACE_DLList_Iterator
<T
>;
1036 friend class ACE_DLList_Reverse_Iterator
<T
>;
1040 /// Delegates to ACE_Double_Linked_List.
1041 void operator= (const ACE_DLList
<T
> &l
);
1044 * @name Queue-like insert and delete methods
1049 * Insert pointer for a new item at the tail of the list.
1051 * @return Pointer to item inserted; 0 on error.
1053 T
*insert_tail (T
*new_item
);
1056 * Insert pointer for a new item at the head of the list.
1058 * @return Pointer to item inserted; 0 on error.
1060 T
*insert_head (T
*new_item
);
1063 * Removes the item at the head of the list and returns its pointer.
1065 * @return Pointer to previously inserted item; 0 if the list is empty,
1066 * an error occurred, or the original pointer inserted was 0.
1068 T
*delete_head (void);
1071 * Removes the item at the tail of the list and returns its pointer.
1073 * @return Pointer to previously inserted item; 0 if the list is empty,
1074 * an error occurred, or the original pointer inserted was 0.
1076 T
*delete_tail (void);
1080 * Provide random access to any item in the list.
1082 * @param item Receives a pointer to the T object pointer held at the
1083 * specified position in the list.
1084 * @param slot Position in the list to access. The first position is 0.
1086 * @retval 0 Success; T pointer returned in item.
1087 * @retval -1 Error, most likely slot is outside the range of the list.
1089 int get (T
*&item
, size_t slot
= 0);
1091 /// Delegates to ACE_Double_Linked_List.
1092 void dump (void) const;
1094 /// Delegates to ACE_Double_Linked_List.
1095 int remove (ACE_DLList_Node
*n
);
1100 * @param the_allocator Allocator to use for allocating ACE_DLList_Node
1101 * objects that wrap T objects for inclusion in the
1102 * list. If 0, ACE_Allocator::instance() is used.
1104 ACE_DLList (ACE_Allocator
*the_allocator
= 0);
1106 /// Delegates to ACE_Double_Linked_List.
1107 ACE_DLList (const ACE_DLList
<T
> &l
);
1110 * Deletes all ACE_DLList_Node objects in the list starting from the head.
1111 * No T objects referred to by the deleted ACE_DLList_Node objects are
1112 * modified or freed. If you desire all of the T objects in the list to
1113 * be deleted as well, code such as this should be used prior to destroying
1116 ACE_DLList<Item> list;
1117 ... // insert dynamically allocated Items...
1119 while ((p = list.delete_head()) != 0)
1127 * @class ACE_DLList_Iterator
1129 * @brief A double-linked list container class iterator.
1131 * This implementation uses ACE_Double_Linked_List_Iterator to
1132 * perform the logic behind this container class. It delegates
1133 * all of its calls to ACE_Double_Linked_List_Iterator.
1136 class ACE_DLList_Iterator
: public ACE_Double_Linked_List_Iterator
<ACE_DLList_Node
>
1139 friend class ACE_DLList
<T
>;
1140 friend class ACE_DLList_Node
;
1144 // = Initialization method.
1145 ACE_DLList_Iterator (ACE_DLList
<T
> &l
);
1148 * Retasks the iterator to iterate over a new
1149 * Double_Linked_List. This allows clients to reuse an iterator
1150 * without incurring the constructor overhead. If you do use this,
1151 * be aware that if there are more than one reference to this
1152 * iterator, the other "clients" may be very bothered when their
1154 * @@ Here be dragons. Comments?
1156 void reset (ACE_DLList
<T
> &l
);
1158 // = Iteration methods.
1159 /// Move forward by one element in the list. Returns 0 when all the
1160 /// items in the list have been seen, else 1.
1163 /// Pass back the {next_item} that hasn't been seen in the list.
1164 /// Returns 0 when all items have been seen, else 1.
1168 * @deprecated Delegates to ACE_Double_Linked_List_Iterator, except that
1169 * whereas the Double_Linked_List version of next returns the node, this next
1170 * returns the contents of the node
1172 T
*next (void) const;
1175 * Removes the current item (i.e., {next}) from the list.
1176 * Note that DLList iterators do not support {advance_and_remove}
1177 * directly (defined in its base class) and you will need to
1178 * release the element returned by it.
1182 /// Delegates to ACE_Double_Linked_List_Iterator.
1183 void dump (void) const;
1186 ACE_DLList
<T
> *list_
;
1190 * @class ACE_DLList_Reverse_Iterator
1192 * @brief A double-linked list container class iterator.
1194 * This implementation uses ACE_Double_Linked_List_Iterator to
1195 * perform the logic behind this container class. It delegates
1196 * all of its calls to ACE_Double_Linked_List_Iterator.
1199 class ACE_DLList_Reverse_Iterator
: public ACE_Double_Linked_List_Reverse_Iterator
<ACE_DLList_Node
>
1202 friend class ACE_DLList
<T
>;
1203 friend class ACE_DLList_Node
;
1207 // = Initialization method.
1208 ACE_DLList_Reverse_Iterator (ACE_DLList
<T
> &l
);
1211 * Retasks the iterator to iterate over a new
1212 * Double_Linked_List. This allows clients to reuse an iterator
1213 * without incurring the constructor overhead. If you do use this,
1214 * be aware that if there are more than one reference to this
1215 * iterator, the other "clients" may be very bothered when their
1217 * @@ Here be dragons. Comments?
1219 void reset (ACE_DLList
<T
> &l
);
1221 // = Iteration methods.
1222 /// Move forward by one element in the list. Returns 0 when all the
1223 /// items in the list have been seen, else 1.
1226 /// Pass back the {next_item} that hasn't been seen in the list.
1227 /// Returns 0 when all items have been seen, else 1.
1230 /// @deprecated Delegates to ACE_Double_Linked_List_Iterator.
1231 T
*next (void) const;
1233 /// Removes the current item (i.e., {next}) from the list.
1234 /// Note that DLList iterators do not support {advance_and_remove}
1235 /// directly (defined in its base class) and you will need to
1236 /// release the element returned by it.
1239 /// Delegates to ACE_Double_Linked_List_Iterator.
1240 void dump (void) const;
1243 ACE_DLList
<T
> *list_
;
1246 // Forward declaration.
1247 template <class T
, size_t ACE_SIZE
>
1248 class ACE_Fixed_Set
;
1251 * @class ACE_Fixed_Set_Iterator_Base
1253 * @brief Implements a common base class for iterators for a unordered set.
1255 template <class T
, size_t ACE_SIZE
>
1256 class ACE_Fixed_Set_Iterator_Base
1259 // = Iteration methods.
1261 /// Pass back the {next_item} that hasn't been seen in the Set.
1262 /// Returns 0 when all items have been seen, else 1.
1263 int next (T
*&next_item
);
1265 /// Move forward by one element in the set. Returns 0 when all the
1266 /// items in the set have been seen, else 1.
1269 /// Move to the first element in the set. Returns 0 if the
1270 /// set is empty, else 1.
1273 /// Returns 1 when all items have been seen, else 0.
1274 int done (void) const;
1276 /// Declare the dynamic allocation hooks.
1277 ACE_ALLOC_HOOK_DECLARE
;
1280 // = Initialization method.
1281 ACE_Fixed_Set_Iterator_Base (ACE_Fixed_Set
<T
, ACE_SIZE
> &s
);
1283 /// Set we are iterating over.
1284 ACE_Fixed_Set
<T
, ACE_SIZE
> &s_
;
1286 /// How far we've advanced over the set.
1289 /// The number of non free items that the iterator had pointed at.
1290 size_t iterated_items_
;
1292 /// Dump the state of an object.
1293 void dump_i (void) const;
1295 /// Pass back the {next_item} that hasn't been seen in the Set.
1296 /// Returns 0 when all items have been seen, else 1.
1297 int next_i (T
*&next_item
);
1301 * @class ACE_Fixed_Set_Iterator
1303 * @brief Iterates through an unordered set.
1305 * This implementation of an unordered set uses a fixed array.
1306 * Allows deletions while iteration is occurring.
1308 template <class T
, size_t ACE_SIZE
>
1309 class ACE_Fixed_Set_Iterator
: public ACE_Fixed_Set_Iterator_Base
<T
, ACE_SIZE
>
1312 // = Initialization method.
1313 ACE_Fixed_Set_Iterator (ACE_Fixed_Set
<T
, ACE_SIZE
> &s
);
1315 // = Iteration methods.
1317 /// Pass back the {next_item} that hasn't been seen in the Set.
1318 /// Returns 0 when all items have been seen, else 1.
1319 int next (T
*&next_item
);
1321 /// Dump the state of an object.
1322 void dump (void) const;
1324 /// Remove the item where the itearetor is located at.
1325 /// Returns 1 if it removes a item, else 0.
1326 /// Pass back the removed {item}.
1327 int remove (T
*&item
);
1329 /// STL-like iterator dereference operator: returns a reference
1330 /// to the node underneath the iterator.
1331 T
& operator* (void);
1333 /// Declare the dynamic allocation hooks.
1334 ACE_ALLOC_HOOK_DECLARE
;
1338 * @class ACE_Fixed_Set_Const_Iterator
1340 * @brief Iterates through a const unordered set.
1342 * This implementation of an unordered set uses a fixed array.
1344 template <class T
, size_t ACE_SIZE
>
1345 class ACE_Fixed_Set_Const_Iterator
: public ACE_Fixed_Set_Iterator_Base
<T
, ACE_SIZE
>
1348 // = Initialization method.
1349 ACE_Fixed_Set_Const_Iterator (const ACE_Fixed_Set
<T
, ACE_SIZE
> &s
);
1351 // = Iteration methods.
1353 /// Pass back the {next_item} that hasn't been seen in the Set.
1354 /// Returns 0 when all items have been seen, else 1.
1355 int next (const T
*&next_item
);
1357 /// Dump the state of an object.
1358 void dump (void) const;
1360 /// STL-like iterator dereference operator: returns a reference
1361 /// to the node underneath the iterator.
1362 const T
& operator* (void) const ;
1364 /// Declare the dynamic allocation hooks.
1365 ACE_ALLOC_HOOK_DECLARE
;
1369 * @class ACE_Fixed_Set
1371 * @brief Implement a simple unordered set of {T} with maximum {ACE_SIZE}.
1373 * This implementation of an unordered set uses a fixed array.
1374 * It does not allow duplicate members. The set provides linear insertion/deletion
1377 * <b> Requirements and Performance Characteristics</b>
1378 * - Internal Structure
1380 * - Duplicates allowed?
1382 * - Random access allowed?
1386 * - Insert/replace speed
1388 * - Iterator still valid after change to container?
1390 * - Frees memory for removed elements?
1392 * - Items inserted by
1394 * - Requirements for contained type
1395 * -# Default constructor
1396 * -# Copy constructor
1401 template <class T
, size_t ACE_SIZE
>
1405 friend class ACE_Fixed_Set_Iterator_Base
<T
, ACE_SIZE
>;
1406 friend class ACE_Fixed_Set_Iterator
<T
, ACE_SIZE
>;
1407 friend class ACE_Fixed_Set_Const_Iterator
<T
, ACE_SIZE
>;
1409 // Trait definitions.
1410 typedef ACE_Fixed_Set_Iterator
<T
, ACE_SIZE
> ITERATOR
;
1411 typedef ACE_Fixed_Set_Const_Iterator
<T
, ACE_SIZE
> CONST_ITERATOR
;
1413 // = Initialization and termination methods.
1414 /// Default Constructor.
1416 * Creates an empy set
1418 ACE_Fixed_Set (void);
1420 /// Copy constructor.
1422 * Initializes a set to be a copy of the set parameter.
1424 ACE_Fixed_Set (const ACE_Fixed_Set
<T
, ACE_SIZE
> &);
1426 /// Assignment operator.
1428 * Deep copy of one set to another.
1430 void operator= (const ACE_Fixed_Set
<T
, ACE_SIZE
> &);
1436 ~ACE_Fixed_Set (void);
1438 // = Check boundary conditions.
1440 /// Returns 1 if the container is empty, otherwise returns 0.
1442 * Performs constant time check to determine if a set is empty.
1444 int is_empty (void) const;
1446 /// Returns 1 if the container is full, otherwise returns 0.
1448 * Performs a constant time check to see if the set is full.
1450 int is_full (void) const;
1452 // = Classic unordered set operations.
1454 ///Linear time insertion of an item unique to the set.
1456 * Insert @a new_item into the set (doesn't allow duplicates).
1457 * Returns -1 if failures occur, 1 if item is already present, else
1460 int insert (const T
&new_item
);
1462 ///Linear time removal operation of an item.
1464 * Remove first occurrence of {item} from the set. Returns 0 if
1465 * it removes the item, -1 if it can't find the item, and -1 if a
1466 * failure occurs. Removal doesn't reclaim memory for the @a item.
1468 int remove (const T
&item
);
1470 /// Finds if @a item occurs in the set. Returns 0 if finds, else -1.
1472 * Performs a linear find operation for the specified @a item.
1474 int find (const T
&item
) const;
1476 /// Size of the set.
1478 * Returns the current size of the set.
1480 size_t size (void) const;
1482 /// Dump the state of an object.
1483 void dump (void) const;
1485 /// Declare the dynamic allocation hooks.
1486 ACE_ALLOC_HOOK_DECLARE
;
1489 /// Holds the contents of the set.
1492 /// Item in the set.
1495 /// Keeps track of whether this item is in use or not.
1497 } search_structure_
[ACE_SIZE
];
1499 /// Current size of the set.
1502 /// Maximum size of the set.
1506 // Forward declaration.
1508 class ACE_Bounded_Set
;
1511 * @class ACE_Bounded_Set_Iterator
1513 * @brief Iterates through an unordered set.
1515 * This implementation of an unordered set uses a Bounded array.
1516 * Allows deletions while iteration is occurring.
1519 class ACE_Bounded_Set_Iterator
1522 // = Initialization method.
1523 ACE_Bounded_Set_Iterator (ACE_Bounded_Set
<T
> &s
);
1525 // = Iteration methods.
1527 /// Pass back the {next_item} that hasn't been seen in the Set.
1528 /// Returns 0 when all items have been seen, else 1.
1529 int next (T
*&next_item
);
1531 /// Move forward by one element in the set. Returns 0 when all the
1532 /// items in the set have been seen, else 1.
1535 /// Move to the first element in the set. Returns 0 if the
1536 /// set is empty, else 1.
1539 /// Returns 1 when all items have been seen, else 0.
1540 int done (void) const;
1542 /// Dump the state of an object.
1543 void dump (void) const;
1545 /// Declare the dynamic allocation hooks.
1546 ACE_ALLOC_HOOK_DECLARE
;
1549 /// Set we are iterating over.
1550 ACE_Bounded_Set
<T
> &s_
;
1552 /// How far we've advanced over the set.
1558 * @class ACE_Bounded_Set
1560 * @brief Implement a simple unordered set of {T} with maximum
1561 * set at creation time.
1563 * This implementation of an unordered set uses a Bounded array.
1564 * This implementation does not allow duplicates. It provides
1565 * linear insert/remove/find operations. Insertion/removal does not
1566 * invalidate iterators, but caution should be taken to ensure
1567 * expected behavior. Once initialized, the object has a maximum size
1568 * which can only be increased by the assignment of another larger Bounded_Set.
1570 * <b> Requirements and Performance Characteristics</b>
1571 * - Internal Structure
1572 * Bounded array which can grow via assignment
1573 * - Duplicates allowed?
1575 * - Random access allowed?
1579 * - Insert/replace speed
1581 * - Iterator still valid after change to container?
1583 * - Frees memory for removed elements?
1585 * - Items inserted by
1587 * - Requirements for contained type
1588 * -# Default constructor
1589 * -# Copy constructor
1595 class ACE_Bounded_Set
1598 friend class ACE_Bounded_Set_Iterator
<T
>;
1600 // Trait definition.
1601 typedef ACE_Bounded_Set_Iterator
<T
> ITERATOR
;
1608 // = Initialization and termination methods.
1609 /// Construct a Bounded_Set using the default size.
1611 * The default constructor initializes the Bounded_Set to a maximum size
1612 * specified by the DEFAULT_SIZE.
1614 ACE_Bounded_Set (void);
1616 /// Construct a Bounded_Set with the provided sizeB.
1618 * Initialize the Bounded_Set to have a maximum size equal to the size
1619 * parameter specified.
1621 ACE_Bounded_Set (size_t size
);
1623 /// Construct a Bounded_Set that is a copy of the provides Bounded_Set.
1625 * Initialize the Bounded_Set to be a copy of the Bounded_Set parameter.
1627 ACE_Bounded_Set (const ACE_Bounded_Set
<T
> &);
1629 /// Assignment operator.
1631 * The assignment will make a deep copy of the Bounded_Set provided. If the
1632 * rhs has more elements than the capacity of the lhs, then the lhs will be
1633 * deleted and reallocated to accomadate the larger number of elements.
1635 void operator= (const ACE_Bounded_Set
<T
> &);
1639 * Clean up the underlying dynamically allocated memory that is used by
1642 ~ACE_Bounded_Set (void);
1644 // = Check boundary conditions.
1646 /// Returns 1 if the container is empty, otherwise returns 0.
1648 * A constant time check is performed to determine if the Bounded_Set is
1651 int is_empty (void) const;
1653 /// Returns 1 if the container is full, otherwise returns 0.
1655 * Performs a constant time check to determine if the Bounded_Set is at
1658 int is_full (void) const;
1660 // = Classic unordered set operations.
1662 ///Inserts a new element unique to the set.
1664 * Insert @a new_item into the set (doesn't allow duplicates) in linear
1666 * Returns -1 if failures occur, 1 if item is already present, else
1669 int insert (const T
&new_item
);
1671 ///Finds the specified element and removes it from the set.
1673 * Remove first occurrence of @a item from the set. Returns 0 if it
1674 * removes the item, -1 if it can't find the item, and -1 if a
1675 * failure occurs. The linear remove operation does not reclaim the
1676 * memory associated with the removed item.
1678 int remove (const T
&item
);
1680 /// Finds if @a item occurs in the set. Returns 0 if finds, else -1.
1682 * find preforms a linear search for {item} and returns 0 on successful
1683 * find and -1 otherwise.
1685 int find (const T
&item
) const;
1687 /// Size of the set.
1689 * Returns a size_t representing the current size of the set.
1691 size_t size (void) const;
1693 /// Dump the state of an object.
1694 void dump (void) const;
1696 /// Declare the dynamic allocation hooks.
1697 ACE_ALLOC_HOOK_DECLARE
;
1700 struct Search_Structure
1702 /// Item in the set.
1705 /// Keeps track of whether this item is in use or not.
1709 /// Holds the contents of the set.
1710 Search_Structure
*search_structure_
;
1712 /// Current size of the set.
1715 /// Maximum size of the set.
1720 * @class ACE_Ordered_MultiSet_Iterator
1722 * @brief Implement a bidirectional iterator over an ordered multiset.
1723 * This class template requires that < operator semantics be
1724 * defined for the parameterized type {T}, but does not impose
1725 * any restriction on how that ordering operator is implemented.
1728 class ACE_Ordered_MultiSet_Iterator
1731 friend class ACE_Ordered_MultiSet
<T
>;
1733 // = Initialization method.
1734 ACE_Ordered_MultiSet_Iterator (ACE_Ordered_MultiSet
<T
> &s
);
1736 // = Iteration methods.
1738 /// Pass back the {next_item} that hasn't been seen in the ordered multiset.
1739 /// Returns 0 when all items have been seen, else 1.
1740 int next (T
*&next_item
) const;
1742 /// Repositions the iterator at the first item in the ordered multiset
1743 /// Returns 0 if the list is empty else 1.
1746 /// Repositions the iterator at the last item in the ordered multiset
1747 /// Returns 0 if the list is empty else 1.
1750 /// Move forward by one element in the set. Returns 0 when all the
1751 /// items in the set have been seen, else 1.
1754 /// Move backward by one element in the set. Returns 0 when all the
1755 /// items in the set have been seen, else 1.
1758 /// Returns 1 when all items have been seen, else 0.
1759 int done (void) const;
1761 /// Dump the state of an object.
1762 void dump (void) const;
1764 /// Returns a reference to the internal element {this} is pointing to.
1765 T
& operator* (void);
1767 /// Declare the dynamic allocation hooks.
1768 ACE_ALLOC_HOOK_DECLARE
;
1772 /// Pointer to the current node in the iteration.
1773 ACE_DNode
<T
> *current_
;
1775 /// Pointer to the set we're iterating over.
1776 ACE_Ordered_MultiSet
<T
> &set_
;
1781 * @class ACE_Ordered_MultiSet
1783 * @brief Implement a simple ordered multiset of {T} of unbounded size
1784 * that allows duplicates. This class template requires that <
1785 * operator semantics be defined for the parameterized type {T}, but
1786 * does not impose any restriction on how that ordering operator is
1787 * implemented. The set is implemented as a linked list.
1790 * <b> Requirements and Performance Characteristics</b>
1791 * - Internal Structure
1792 * Double linked list
1793 * - Duplicates allowed?
1795 * - Random access allowed?
1799 * - Insert/replace speed
1801 * - Iterator still valid after change to container?
1803 * - Frees memory for removed elements?
1805 * - Items inserted by
1807 * - Requirements for contained type
1808 * -# Default constructor
1809 * -# Copy constructor
1817 class ACE_Ordered_MultiSet
1820 friend class ACE_Ordered_MultiSet_Iterator
<T
>;
1822 // Trait definition.
1823 typedef ACE_Ordered_MultiSet_Iterator
<T
> ITERATOR
;
1825 // = Initialization and termination methods.
1826 /// Constructor. Use user specified allocation strategy
1829 * Initialize the set using the allocation strategy specified. If none, use the
1832 ACE_Ordered_MultiSet (ACE_Allocator
*the_allocator
= 0);
1834 /// Copy constructor.
1836 * Initialize the set to be a copy of the provided set.
1838 ACE_Ordered_MultiSet (const ACE_Ordered_MultiSet
<T
> &);
1842 * Delete the nodes of the set.
1844 ~ACE_Ordered_MultiSet (void);
1846 /// Assignment operator.
1848 * Delete the nodes in lhs, and copy the nodes from the rhs.
1850 void operator= (const ACE_Ordered_MultiSet
<T
> &);
1852 // = Check boundary conditions.
1854 /// Returns 1 if the container is empty, otherwise returns 0.
1856 * Constant time check to determine if the set is empty.
1858 int is_empty (void) const;
1860 /// Size of the set.
1862 * Constant time check to determine the size of the set.
1864 size_t size (void) const;
1866 // = Classic unordered set operations.
1868 /// Insert @a new_item into the ordered multiset.
1869 /// Returns -1 if failures occur, else 0.
1871 * Linear time, order preserving insert into the set beginning at the head.
1873 int insert (const T
&new_item
);
1875 ///Linear time insert beginning at the point specified by the provided iterator.
1877 * Insert @a new_item into the ordered multiset, starting its search at
1878 * the node pointed to by the iterator, and if insertion was successful,
1879 * updates the iterator to point to the newly inserted node.
1880 * Returns -1 if failures occur, else 0.
1882 int insert (const T
&new_item
, ITERATOR
&iter
);
1884 /// Remove first occurrence of @a item from the set. Returns 0 if
1885 /// it removes the item, -1 if it can't find the item.
1887 * Linear time search operation which removes the item from the set if found .
1889 int remove (const T
&item
);
1891 ///Linear find operation.
1893 * Finds first occurrence of @a item in the multiset, using the iterator's
1894 * current position as a hint to improve performance. If find succeeds,
1895 * it positions the iterator at that node and returns 0, or if it cannot
1896 * locate the node, it leaves the iterator alone and just returns -1.
1898 int find (const T
&item
, ITERATOR
&iter
) const;
1900 /// Reset the ACE_Ordered_MultiSet to be empty.
1902 * Delete the nodes inside the set.
1906 /// Dump the state of an object.
1907 void dump (void) const;
1909 /// Declare the dynamic allocation hooks.
1910 ACE_ALLOC_HOOK_DECLARE
;
1915 * Insert @a item, starting its search at the position given,
1916 * and if successful updates the passed pointer to point to
1917 * the newly inserted item's node.
1919 int insert_from (const T
&item
, ACE_DNode
<T
> *start_position
,
1920 ACE_DNode
<T
> **new_position
);
1923 * Looks for first occurance of @a item in the ordered set, using the
1924 * passed starting position as a hint: if there is such an instance, it
1925 * updates the new_position pointer to point to this node and returns 0;
1926 * if there is no such node, then if there is a node before where the
1927 * item would have been, it updates the new_position pointer to point
1928 * to this node and returns -1; if there is no such node, then if there
1929 * is a node after where the item would have been, it updates the
1930 * new_position pointer to point to this node (or 0 if there is no such
1931 * node) and returns 1;
1933 int locate (const T
&item
, ACE_DNode
<T
> *start_position
,
1934 ACE_DNode
<T
> *&new_position
) const;
1936 /// Delete all the nodes in the Set.
1937 void delete_nodes (void);
1939 /// Copy nodes into this set.
1940 void copy_nodes (const ACE_Ordered_MultiSet
<T
> &);
1942 /// Head of the bilinked list of Nodes.
1943 ACE_DNode
<T
> *head_
;
1945 /// Head of the bilinked list of Nodes.
1946 ACE_DNode
<T
> *tail_
;
1948 /// Current size of the set.
1951 /// Allocation strategy of the set.
1952 ACE_Allocator
*allocator_
;
1955 // ****************************************************************
1960 * @brief A dynamic array class.
1962 * This class extends ACE_Array_Base, adding comparison operators.
1964 * <b> Requirements and Performance Characteristics</b>
1965 * - Internal Structure
1967 * - Duplicates allowed?
1969 * - Random access allowed?
1973 * - Insert/replace speed
1975 * - Iterator still valid after change to container?
1976 * - In general, yes.
1977 * - If array size is changed during iteration, no.
1978 * - Frees memory for removed elements?
1980 * - Items inserted by
1982 * - Requirements for contained type
1983 * -# Default constructor
1984 * -# Copy constructor
1988 * @sa ACE_Array_Base. This class inherits its operations and requirements.
1991 class ACE_Array
: public ACE_Array_Base
<T
>
1997 typedef ACE_Array_Iterator
<T
> ITERATOR
;
2001 // = Initialization and termination methods.
2003 /// Dynamically create an uninitialized array.
2005 * Initialize an empty array of the specified size using the provided
2006 * allocation strategy.
2008 ACE_Array (size_t size
= 0,
2009 ACE_Allocator
* alloc
= 0);
2011 /// Dynamically initialize the entire array to the {default_value}.
2013 * Initialize an array the given size placing the default_value in each index.
2015 ACE_Array (size_t size
,
2016 const T
&default_value
,
2017 ACE_Allocator
* alloc
= 0);
2019 ///Copy constructor.
2021 * The copy constructor performs initialization by making an exact
2022 * copy of the contents of parameter {s}, i.e., *this == s will
2025 ACE_Array (const ACE_Array
<T
> &s
);
2027 ///Assignment operator
2029 * Assignment operator performs an assignment by making an exact
2030 * copy of the contents of parameter {s}, i.e., *this == s will
2031 * return true. Note that if the {max_size_} of {array_} is >= than
2032 * {s.max_size_} we can copy it without reallocating. However, if
2033 * {max_size_} is < {s.max_size_} we must delete the {array_},
2034 * reallocate a new {array_}, and then copy the contents of {s}.
2036 void operator= (const ACE_Array
<T
> &s
);
2038 // = Compare operators
2040 ///Equality comparison operator.
2042 * Compare this array with {s} for equality. Two arrays are equal
2043 * if their {size}'s are equal and all the elements from 0 .. {size}
2046 bool operator== (const ACE_Array
<T
> &s
) const;
2048 ///Inequality comparison operator.
2050 * Compare this array with {s} for inequality such that {*this} !=
2051 * {s} is always the complement of the boolean return value of
2054 bool operator!= (const ACE_Array
<T
> &s
) const;
2057 ACE_END_VERSIONED_NAMESPACE_DECL
2059 #if defined (__ACE_INLINE__)
2060 #include "ace/Containers_T.inl"
2061 #endif /* __ACE_INLINE__ */
2063 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
2064 #include "ace/Containers_T.cpp"
2065 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
2067 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
2068 #pragma implementation ("Containers_T.cpp")
2069 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
2071 #include /**/ "ace/post.h"
2073 #endif /* ACE_CONTAINERS_T_H */