T
of unbounded size.
This class template requires that operator semantics be defined
for the parameterized type T
, but does not impose any restriction
on how that ordering operator is implemented.
SYNOPSIS
#include <ace/Containers.h>
template<class T>
class ACE_Ordered_MultiSet
{
public:
friend class ACE_Ordered_MultiSet_Iterator<T>;
typedef ACE_Ordered_MultiSet_Iterator<T> ITERATOR;
ACE_Ordered_MultiSet (ACE_Allocator *alloc = 0);
ACE_Ordered_MultiSet (const ACE_Ordered_MultiSet<T> &);
~ACE_Ordered_MultiSet (void);
void operator= (const ACE_Ordered_MultiSet<T> &);
int is_empty (void) const;
size_t size (void) const;
int insert (const T &new_item);
int insert (const T &new_item, ITERATOR &iter);
int remove (const T &item);
int find (const T &item, ITERATOR &iter) const;
void reset (void);
void dump (void) const;
ACE_ALLOC_HOOK_DECLARE;
private:
int insert_from (
const T &item,
ACE_DNode<T> *start_position,
ACE_DNode<T> **new_position
);
int locate (
const T &item,
ACE_DNode<T> *start_position,
ACE_DNode<T> *&new_position
) const;
void delete_nodes (void);
void copy_nodes (const ACE_Ordered_MultiSet<T> &);
ACE_DNode<T> *head_;
ACE_DNode<T> *tail_;
size_t cur_size_;
ACE_Allocator *allocator_;
};
DESCRIPTION
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.
Initialization and termination methods.
ACE_Ordered_MultiSet (ACE_Allocator *alloc = 0);
Constructor. Use user specified allocation strategy
if specified.
ACE_Ordered_MultiSet (const ACE_Ordered_MultiSet<T> &);
Copy constructor.
~ACE_Ordered_MultiSet (void);
Destructor.
void operator= (const ACE_Ordered_MultiSet<T> &);
Assignment operator.
Check boundary conditions.
int is_empty (void) const;
Returns 1 if the container is empty, otherwise returns 0.
size_t size (void) const;
Size of the set.
Classic unordered set operations.
int insert (const T &new_item);
Insert new_item
into the ordered multiset.
Returns -1 if failures occur, else 0.
int insert (const T &new_item, ITERATOR &iter);
Insert new_item
into the ordered multiset, starting its search at
the node pointed to by the iterator, and if insetion was successful,
updates the iterator to point to the newly inserted node.
Returns -1 if failures occur, else 0.
int remove (const T &item);
Remove first occurrence of item
from the set. Returns 0 if
it removes the item, -1 if it can't find the item.
int find (const T &item, ITERATOR &iter) const;
Finds first occurrance of item
in the multiset, using the iterator's
current position as a hint to improve performance. If find succeeds,
it positions the iterator at that node and returns 0, or if it cannot
locate the node, it leaves the iterator alone and just returns -1.
void reset (void);
Reset the ACE_Ordered_MultiSet
to be empty.
void dump (void) const;
Dump the state of an object.
ACE_ALLOC_HOOK_DECLARE;
Declare the dynamic allocation hooks.
AUTHOR
Doug Schmidt
LIBRARY
ace