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 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 ArrayWithNullHoles< T >::ParameterType

The parameter type.

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

template<typename T >
typedef int 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 ArrayWithNullHoles< T >::erase ( IntInputIterator  begin,
IntInputIterator  end 
) [inline]

Erase a range of elements.

Precondition:
The location of each must not already be a hole.
template<typename T >
void ArrayWithNullHoles< T >::erase ( int  index  ) 

Erase the specified element.

Precondition:
The location must not already be a hole.
template<typename T >
int 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 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 Thu Jun 30 02:14:51 2016 for Algorithms and Data Structures Package by  doxygen 1.6.3