Overview
Examples
Screenshots
Comparisons
Applications
Download
Manual
Status & Roadmap
FAQ
Authors & License
Forums
Wiki
Funding Ultimate++
Search on this site











SourceForge.net Logo



template <class T, class HashFn = StdHash<T> >  class ArrayIndex : private MoveableAndDeepCopyOption< ArrayIndex<T, HashFn > >, public AIndex<T, Array<T>, HashFn

template <class T, class HashFn = StdHash<T> >

 

template <class T, class HashFn = StdHash<T> >  class ArrayIndex : private MoveableAndDeepCopyOption< ArrayIndex<T, HashFn > >, public AIndex<T, Array<T>, HashFn

 

T    Type or base class of elements stored in Array. There is no common requirement for T.

HashFn    Hashing class. Must have defined unsigned operator()(const T& x) method returning hash value for elements. Defaults to StdHash<T> which requires unsigned GetHashValue(const T&) function returning hash value of elements to be defined.

Base class

AIndex<T, Array<T>, HashFn>

 

Array flavor of index. Inherits most of its functionality from AIndex and adds only members specific for its flavor.

Like any other NTL container, ArrayIndex is a moveable type with pick and optional deep copy transfer semantics. Calling methods of a picked ArrayIndex is logic error with the exceptions of

void operator=(pick_ ArrayIndex& v) (defined by composition)

void operator<<=(const AIndex& v) (defined in AIndex)

void Clear()

bool IsPicked() const

Optional deep copy operator is inherited from AIndex class. Pick operator is implicitly defined by composition.

 

void Add(const T& x, unsigned _hash)

Adds a new element with a precomputed hash value. The precomputed hash value must be the same as the hash value that would be the result of HashFn. The benefit of using a precomputed hash value is that sometimes you can compute hash-value as the part of an other process, like fetching a string from an input stream. This method has to be reimplemented in ArrayIndex (using simple forwarding) due to overloading of Add in other forms.

Requires T to have deep copy constructor.

Invalidates iterators to the ArrayIndex.

x

Element to add.

_hash

Precomputed hash value.

 

void Add(const T& x)

Adds a new element to Index. This method has to be reimplemented in ArrayIndex (using simple forwarding) due to overloading of Add in other forms.

Requires T to have deep copy constructor.

Invalidates iterators to the ArrayIndex.

x

Element to add.

 

void Set(int i, const T& x, unsigned _hash)

Replaces the element at the specified position with a new element with the specified value, using a precomputed hash-value. Speed of this operation depends on the total number of elements with the same value as the specified one in ArrayIndex. This method has to be reimplemented in ArrayIndex (using simple redirection) due to overloading of Set in other forms.

Requires T to have deep copy constructor.

Invalidates iterators to the ArrayIndex.

i

Position of element.

x

Value to set.

_hash

Precomputed hash value.

 

void Set(int i, const T& x)

Replaces element at specified position with new element with specified value. Speed of this operation depends on the total number of elements with the same value as the specified one in ArrayIndex. This method has to be reimplemented in ArrayIndex (using simple redirection) due to overloading of Set in other forms.

Requires T to have deep copy constructor.

Invalidates iterators to the ArrayIndex.

i

Position of element.

x

Value to set.

 

void Add(T *newt, unsigned _hash)

Adds a new element created on the heap to the ArrayIndex using a precomputed hash value. The element is specified by a pointer to the object. ArrayIndex takes over ownership of the pointed element. This variant allows the use of an ArrayIndex as a polymorphic container, because the type of the added element can be either T or a type derived from T. No constructor is applied.

newt

Element created on the heap.

 

void Add(T *newt)

Adds a new element to the ArrayIndex. The element is specified by a pointer to the object. ArrayIndex takes over ownership of the pointed element. This variant allows the use of an ArrayIndex as a polymorphic container, because the type of the added element can be either T or a type derived from T. No constructor is applied.

newt

Object to be added.

 

void Set(int i, T *newt, unsigned _hash)

 

i

Position.

newt

New element created on heap.

_hash

Hash value

 

void Set(int i, T *newt)

Replaces the element at the specified position by an element previously created on the heap. ArrayIndex takes over ownership of the element.

 

i

Position.

newt

New element created on heap.

Return value

 

ArrayIndex()

Constructor. Constructs an empty ArrayIndex.

 

ArrayIndex(pick_ ArrayIndex& s)

Pick constructor. Transfers source Index in low constant time, but destroys it by picking.

s

Source ArrayIndex.

 

ArrayIndex(const ArrayIndex& s, int)

Optional deep copy constructor.

Requires T to have deep copy constructor or optional deep copy constructor.

s

Source ArrayIndex.

 

ArrayIndex(pick_ Array<T>& s)

Pick-constructs ArrayIndex from an Array. Transfers source container in low constant time, but destroys it by picking.

s

Source Array.

 

ArrayIndex(const Array<T>& s, int)

Deep-copy constructs ArrayIndex from Array.

Requires T to have deep copy constructor or optional deep copy constructor.

s

Source Vector.

 

ArrayIndex& operator=(pick_ Array<T>& x)

Pick operator. Transfers source Array to the ArrayIndex, but destroys it by picking.

x

Source Array.