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











SourceForge.net Logo

SortedIndex

 

template <class T, class Less = StdLess<T> >

class SortedIndex : private MoveableAndDeepCopyOptionSortedIndex<T, Less> > 

SortedIndex is a random access (vector-like) container which keeps its element sorted at all times using Less predicate. SortedIndex is relatively simple adapter over InVector - use it as reference for performace aspects.

T is required to by moveable type. Like any other NTL container, AIndex is moveable type with pick and optional deep copy transfer semantics.

 

Public Method List

 

int Add(const T& x)

Inserts a new item x into upper-bound position and returns its index.

 


 

int FindAdd(const T& key)

If there is already key in SortedIndex, returns its index. If there is not, inserts it and returns its index.

 


 

SortedIndex& operator<<(const T& x)

Same as Add(x).

 


 

int FindLowerBound(const T& xconst

Finds lower-bound index of x.

 


 

int FindUpperBound(const T& xconst

Finds upper-bound index of x.

 


 

int Find(const T& xconst

Returns the minimum index of element equal to x or negative number if not found.

 


 

int FindNext(int iconst

If the element at i + 1 is equal to the element at i , returns i + 1, otherwise returns negative number.

 


 

int FindLast(const T& xconst

Finds the maximum index equal to x or negative number if there is none.

 


 

int FindPrev(int iconst

If the element at i - 1 is equal to the element at i , returns i - 1, otherwise returns negative number.

 


 

void Remove(int i)

Removes the element at index i.

 


 

void Remove(int i, int count)

Removes the count  elements starting at index i.

 


 

int RemoveKey(const T& x)

Removes all elements equal to x.

 


 

const T& operator[](int iconst

Returns element at index i.

 


 

int GetCount() const

Returns the cound of elements.

 


 

bool IsEmpty() const

Same as GetCount() == 0.

 


 

void Clear()

Removes all elements.

 


 

void Trim(int n)

Removes all elements starting at index n.

 


 

void Drop(int n = 1)

Removes the last n elements.

 


 

const T& Top() const

Returns the last element.

 


 

void Shrink()

Drops allocation reserve (reduces memory footprint).

 


 

ConstIterator Begin() const

Returns iterator at the begin of SortedIndex.

 


 

ConstIterator End() const

Returns iterator at the end of SortedIndex.

 


 

ConstIterator GetIter(int posconst

Returns iterator at the index pos .

 


 

const InVector<T>& GetKeys() const

Retruns a reference to InVector of keys.

 


 

SortedIndex(const SortedIndex& s, int)

Deep copy constructor.

 


 

void Swap(SortedIndex& a)

Swaps contents of two SortedIndex containers.

 

Last edit by cxl on 12/17/2013. Do you want to contribute?. T++