|
| SSet () |
| Default constructor.
|
| SSet (SSet< Data, Capacity > const &other) |
| Copy constructor.
|
SSet< Data, Capacity > & | operator= (SSet< Data, Capacity > const &other) |
| Assignment, element by element.
|
| ~SSet () |
| Destructor.
|
void | append (Data &data) |
| Add an object to the set.
|
void | remove (Data const &data) |
| Remove an object from the set.
|
void | clear () |
| Set logical size to zero and nullify all elements.
|
int | capacity () const |
| Return physical capacity of array.
|
int | size () const |
| Return logical size of this array.
|
bool | isElement (Data const &data) const |
| Is an object an element of the set?
|
int | index (Data const &data) const |
| Return the current index of an object within the set, if any.
|
void | begin (PArrayIterator< Data > &iterator) |
| Set a PArrayIterator to the beginning of this Array.
|
void | begin (ConstPArrayIterator< Data > &iterator) const |
| Set a ConstPArrayIterator to the beginning of this Array.
|
Data & | operator[] (int i) |
| Mimic C array subscripting.
|
Data const & | operator[] (int i) const |
| Mimic C array subscripting.
|
template<typename Data, int Capacity>
class Util::SSet< Data, Capacity >
Statically allocated array of pointers to an unordered set.
An SSet is a statically allocated array that holds pointers to a set of objects. It implements the same interface as PArray and FPArray, plus additional remove() and index() methods. As for any pointer array container, the [] operator returns an associated object by reference .
An SSet holds a set of pointers in a contiguous array. The size is the number of pointers now in the container, and the Capacity is the maximum number it can hold. The class is implemented as a wrapper for a statically allocated C array of Capacity elements.
The append method adds a pointer to the end of the sequence. The remove method removes an object from the set, or throws an exception if the object is not found in the set. As for an ArraySet, the remove method repacks the sequence of pointers by moving the last element to the position of the element that is being removed. Removal of an element thus generally changes the order in which the remaining elements are stored.
Definition at line 43 of file SSet.h.
template<typename Data, int Capacity>
int Util::SSet< Data, Capacity >::index |
( |
Data const & | data | ) |
const |
Return the current index of an object within the set, if any.
Return the current index of an element within the set, or return -1 if the element is not in the set.
This method returns the current index of the pointer to object data within this SSet, in the range 0 < index < size() - 1. The method returns -1 if data is the object is not in the set.
Throws an exception if data is not in the associated array.
- Parameters
-
- Returns
- current index of pointer to element within this SSet.
Definition at line 387 of file SSet.h.
References ptrs_, and size_.