vtf-logo

ads::ArrayWithNullHoles< T > Class Template Reference

A 1-D array with holes. More...

#include <ArrayWithNullHoles.h>

List of all members.

Public Types

typedef T ValueType
 The element type of the array.
typedef Loki::TypeTraits<
ValueType >::ParameterType 
ParameterType
 The parameter type.
typedef ValueContainer::pointer Pointer
 A pointer to an element.
typedef ValueContainer::const_pointer ConstPointer
 A pointer to a constant element.
typedef ValueContainer::reference Reference
 A reference to an array element.
typedef ValueContainer::const_reference ConstReference
 A reference to a constant array element.
typedef int SizeType
 The size type is a signed integer.
typedef ValueContainer::difference_type DifferenceType
 Pointer difference type.

Public Member Functions

Constructors etc.
 ArrayWithNullHoles (ParameterType null)
 Construct from the null value.
 ArrayWithNullHoles (const ArrayWithNullHoles &other)
 Copy constructor. Deep copy.
ArrayWithNullHolesoperator= (const ArrayWithNullHoles &other)
 Assignment operator.
 ~ArrayWithNullHoles ()
 Destructor.
Accessors.
int size () const
 Return the size of the array (non-null elements and holes combined).
int sizeNull () const
 Return the number of null elements (holes).
int sizeNonNull () const
 Return the number of non-null elements.
bool isNull (int index) const
 Return true if the specified element is null.
bool isNonNull (int index) const
 Return true if the specified element is non-null.
ParameterType get (int index) const
 Return the specified element.
Manipulators.
int insert (ParameterType value)
 Insert an element into a hole (or at the end if there are no holes).
void erase (int index)
 Erase the specified element.
template<typename IntInputIterator>
void erase (IntInputIterator begin, IntInputIterator end)
 Erase a range of elements.
void set (int index, ParameterType value)
 Set the specified element.
Validity.
bool isValid () const
 Return true if the data structure is valid.


Detailed Description

template<typename T>
class ads::ArrayWithNullHoles< T >

A 1-D array with holes.

Parameters:
T is the value type.


Member Typedef Documentation

template<typename T>
typedef Loki::TypeTraits<ValueType>::ParameterType ads::ArrayWithNullHoles< T >::ParameterType

The parameter type.

This is used for passing the value type as an argument.

template<typename T>
typedef int ads::ArrayWithNullHoles< T >::SizeType

The size type is a signed integer.

Having std::size_t (which is an unsigned integer) as the size type causes minor problems. Consult "Large Scale C++ Software Design" by John Lakos for a discussion of using unsigned integers in a class interface.


Member Function Documentation

template<typename T>
template<typename IntInputIterator>
void ads::ArrayWithNullHoles< T >::erase ( IntInputIterator  begin,
IntInputIterator  end 
)

Erase a range of elements.

Precondition:
The location of each must not already be a hole.

template<typename T>
void ads::ArrayWithNullHoles< T >::erase ( int  index  ) 

Erase the specified element.

Precondition:
The location must not already be a hole.

template<typename T>
int ads::ArrayWithNullHoles< T >::insert ( ParameterType  value  ) 

Insert an element into a hole (or at the end if there are no holes).

Returns:
The index of the element.

template<typename T>
void ads::ArrayWithNullHoles< T >::set ( int  index,
ParameterType  value 
)

Set the specified element.

Precondition:
0 <= index, index < size(), and value is not null.


The documentation for this class was generated from the following file:
Generated on Fri Aug 24 12:55:38 2007 for Algorithms and Data Structures Package by  doxygen 1.4.7