ACE  6.0.6
Classes | Public Types | Public Member Functions | Public Attributes | Private Attributes | Friends
ACE_Bounded_Set Class Reference

Implement a simple unordered set of {T} with maximum set at creation time. More...

#include <Containers_T.h>

Collaboration diagram for ACE_Bounded_Set:
Collaboration graph
[legend]

List of all members.

Classes

struct  Search_Structure

Public Types

enum  { DEFAULT_SIZE = 10 }
typedef
ACE_Bounded_Set_Iterator< T > 
ITERATOR

Public Member Functions

 ACE_Bounded_Set (void)
 Construct a Bounded_Set using the default size.
 ACE_Bounded_Set (size_t size)
 Construct a Bounded_Set with the provided sizeB.
 ACE_Bounded_Set (const ACE_Bounded_Set< T > &)
 Construct a Bounded_Set that is a copy of the provides Bounded_Set.
void operator= (const ACE_Bounded_Set< T > &)
 Assignment operator.
 ~ACE_Bounded_Set (void)
 Destructor.
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.
int insert (const T &new_item)
 Inserts a new element unique to the set.
int remove (const T &item)
 Finds the specified element and removes it from the set.
int find (const T &item) const
 Finds if item occurs in the set. Returns 0 if finds, else -1.
size_t size (void) const
 Size of the set.
void dump (void) const
 Dump the state of an object.

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.

Private Attributes

Search_Structuresearch_structure_
 Holds the contents of the set.
size_t cur_size_
 Current size of the set.
size_t max_size_
 Maximum size of the set.

Friends

class ACE_Bounded_Set_Iterator< T >

Detailed Description

Implement a simple unordered set of {T} with maximum set at creation time.

This implementation of an unordered set uses a Bounded array. This implementation does not allow duplicates. It provides linear insert/remove/find operations. Insertion/removal does not invalidate iterators, but caution should be taken to ensure expected behavior. Once initialized, the object has a maximum size which can only be increased by the assignment of another larger Bounded_Set.

Requirements and Performance Characteristics


Member Typedef Documentation


Member Enumeration Documentation

anonymous enum
Enumerator:
DEFAULT_SIZE 

Constructor & Destructor Documentation

ACE_Bounded_Set::ACE_Bounded_Set ( void  )

Construct a Bounded_Set using the default size.

The default constructor initializes the Bounded_Set to a maximum size specified by the DEFAULT_SIZE.

ACE_Bounded_Set::ACE_Bounded_Set ( size_t  size)

Construct a Bounded_Set with the provided sizeB.

Initialize the Bounded_Set to have a maximum size equal to the size parameter specified.

ACE_Bounded_Set::ACE_Bounded_Set ( const ACE_Bounded_Set< T > &  )

Construct a Bounded_Set that is a copy of the provides Bounded_Set.

Initialize the Bounded_Set to be a copy of the Bounded_Set parameter.

ACE_Bounded_Set::~ACE_Bounded_Set ( void  )

Destructor.

Clean up the underlying dynamically allocated memory that is used by the Bounded_Set.


Member Function Documentation

void ACE_Bounded_Set::dump ( void  ) const

Dump the state of an object.

int ACE_Bounded_Set::find ( const T &  item) const

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

find preforms a linear search for {item} and returns 0 on successful find and -1 otherwise.

int ACE_Bounded_Set::insert ( const T &  new_item)

Inserts a new element unique to the set.

Insert new_item into the set (doesn't allow duplicates) in linear time. Returns -1 if failures occur, 1 if item is already present, else 0.

int ACE_Bounded_Set::is_empty ( void  ) const

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

A constant time check is performed to determine if the Bounded_Set is empty.

int ACE_Bounded_Set::is_full ( void  ) const

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

Performs a constant time check to determine if the Bounded_Set is at capacity.

void ACE_Bounded_Set::operator= ( const ACE_Bounded_Set< T > &  )

Assignment operator.

The assignment will make a deep copy of the Bounded_Set provided. If the rhs has more elements than the capacity of the lhs, then the lhs will be deleted and reallocated to accomadate the larger number of elements.

int ACE_Bounded_Set::remove ( const T &  item)

Finds the specified element and removes it from the set.

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. The linear remove operation does not reclaim the memory associated with the removed item.

size_t ACE_Bounded_Set::size ( void  ) const

Size of the set.

Returns a size_t representing the current size of the set.


Friends And Related Function Documentation

friend class ACE_Bounded_Set_Iterator< T > [friend]

Member Data Documentation

Declare the dynamic allocation hooks.

size_t ACE_Bounded_Set::cur_size_ [private]

Current size of the set.

size_t ACE_Bounded_Set::max_size_ [private]

Maximum size of the set.

Holds the contents of the set.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines