Reference

ACE_Unbounded_Set(3)

Implement a simple unordered set of T of unbounded size.

NAME

ACE_Unbounded_Set - Implement a simple unordered set of T of unbounded size.

SYNOPSIS

#include <ace/Containers.h>
template<class T>
class ACE_Unbounded_Set
{
  public:
    friend class ACE_Unbounded_Set_Iterator<T>;
    typedef ACE_Unbounded_Set_Iterator<T> ITERATOR;
    typedef ACE_Unbounded_Set_Iterator<T> iterator;
    ACE_Unbounded_Set (ACE_Allocator *alloc = 0);
    ACE_Unbounded_Set (const ACE_Unbounded_Set<T> &);
    void operator= (const ACE_Unbounded_Set<T> &);
    ~ACE_Unbounded_Set (void);
    int is_empty (void) const;
    int is_full (void) const;
    int insert (const T &new_item);
    int remove (const T &item);
    int find (const T &item) const;
    size_t size (void) const;
    void dump (void) const;
    void reset (void);
    ACE_Unbounded_Set_Iterator<T> begin (void);
    ACE_Unbounded_Set_Iterator<T> end (void);
    ACE_ALLOC_HOOK_DECLARE;
  private:
    int insert_tail (const T &item);
    void delete_nodes (void);
    void copy_nodes (const ACE_Unbounded_Set<T> &);
    ACE_Node<T> *head_;
    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_Unbounded_Set (ACE_Allocator *alloc = 0);

Constructor. Use user specified allocation strategy if specified.

ACE_Unbounded_Set (const ACE_Unbounded_Set<T> &);

Copy constructor.

void operator= (const ACE_Unbounded_Set<T> &);

Assignment operator.

~ACE_Unbounded_Set (void);

Destructor.

Check boundary conditions.

int is_empty (void) const;

Returns 1 if the container is empty, otherwise returns 0.

int is_full (void) const;

Returns 1 if the container is full, otherwise returns 0.

Classic unordered set operations.

int insert (const T &new_item);

Insert new_item into the set (doesn't allow duplicates). Returns -1 if failures occur, 1 if item is already present, 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, and -1 if a failure occurs.

int find (const T &item) const;

Finds if item occurs in the set. Returns 0 if find succeeds, else -1.

size_t size (void) const;

Size of the set.

void dump (void) const;

Dump the state of an object.

void reset (void);

Reset the ACE_Unbounded_Set to be empty.

STL-styled unidirectional iterator factory.

ACE_Unbounded_Set_Iterator<T> begin (void);

ACE_Unbounded_Set_Iterator<T> end (void);

ACE_ALLOC_HOOK_DECLARE;

Declare the dynamic allocation hooks.

AUTHOR

Doug Schmidt

Initialization and termination methods.

Check boundary conditions.

Classic unordered set operations.

LIBRARY

ace