SNAP Library 3.0, User Reference
2016-07-20 17:56:49
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
Vector is a sequence TVal
objects representing an array that can change in size.
More...
#include <ds.h>
Public Types | |
typedef TVal * | TIter |
Random access iterator to TVal . More... | |
Public Member Functions | |
TVec () | |
TVec (const TVec< TVal, TSizeTy > &Vec) | |
TVec (const TSizeTy &_Vals) | |
Constructs a vector (an array) of length _Vals . More... | |
TVec (const TSizeTy &_MxVals, const TSizeTy &_Vals) | |
Constructs a vector (an array) of length _Vals , while reserving enough memory to store _MxVals elements. More... | |
TVec (TVal *_ValT, const TSizeTy &_Vals) | |
Constructs a vector of _Vals elements of memory array _ValT . More... | |
~TVec () | |
TVec (TSIn &SIn) | |
void | Load (TSIn &SIn) |
void | Save (TSOut &SOut) const |
void | LoadXml (const PXmlTok &XmlTok, const TStr &Nm="") |
void | SaveXml (TSOut &SOut, const TStr &Nm) const |
TVec< TVal, TSizeTy > & | operator= (const TVec< TVal, TSizeTy > &Vec) |
Assigns new contents to the vector, replacing its current content. More... | |
TVec< TVal, TSizeTy > & | operator+ (const TVal &Val) |
Appends value Val to the vector. More... | |
bool | operator== (const TVec< TVal, TSizeTy > &Vec) const |
Checks that the two vectors have the same contents. More... | |
bool | operator< (const TVec< TVal, TSizeTy > &Vec) const |
Lexicographically compares two vectors. More... | |
const TVal & | operator[] (const TSizeTy &ValN) const |
Returns a reference to the element at position ValN in the vector. More... | |
TVal & | operator[] (const TSizeTy &ValN) |
Returns a reference to the element at position ValN in the vector. More... | |
TSizeTy | GetMemUsed () const |
Returns the memory footprint (the number of bytes) of the vector. More... | |
TSizeTy | GetMemSize () const |
Returns the memory size (the number of bytes) of a binary representation. More... | |
int | GetPrimHashCd () const |
Returns primary hash code of the vector. Used by THash . More... | |
int | GetSecHashCd () const |
Returns secondary hash code of the vector. Used by THash . More... | |
void | Gen (const TSizeTy &_Vals) |
Constructs a vector (an array) of _Vals elements. More... | |
void | Gen (const TSizeTy &_MxVals, const TSizeTy &_Vals) |
Constructs a vector (an array) of _Vals elements, while reserving enough memory for _MxVals elements. More... | |
void | GenExt (TVal *_ValT, const TSizeTy &_Vals) |
Constructs a vector of _Vals elements of memory array _ValT . More... | |
bool | IsExt () const |
Returns true if the vector was created using the GenExt() . More... | |
void | Reserve (const TSizeTy &_MxVals) |
Reserves enough memory for the vector to store _MxVals elements. More... | |
void | Reserve (const TSizeTy &_MxVals, const TSizeTy &_Vals) |
Reserves enough memory for the vector to store _MxVals elements and sets its length to _Vals . More... | |
void | Clr (const bool &DoDel=true, const TSizeTy &NoDelLim=-1) |
Clears the contents of the vector. More... | |
void | Trunc (const TSizeTy &_Vals=-1) |
Truncates the vector's length and capacity to _Vals elements. More... | |
void | Reduce (const TSizeTy &_Vals=-1) |
Reduces the vector's length to _Vals elements, which must be less than the current length. More... | |
void | Pack () |
Reduces vector capacity (frees memory) to match its size. More... | |
void | MoveFrom (TVec< TVal, TSizeTy > &Vec) |
Takes over the data and the capacity from Vec . More... | |
void | CopyUniqueFrom (TVec< TVal, TSizeTy > &Vec, TInt Offset, TInt Sz) |
Copy Sz values from Vec starting at Offset . More... | |
void | Swap (TVec< TVal, TSizeTy > &Vec) |
Swaps the contents of the vector with Vec . More... | |
bool | Empty () const |
Tests whether the vector is empty. More... | |
TSizeTy | Len () const |
Returns the number of elements in the vector. More... | |
TSizeTy | Reserved () const |
Returns the size of allocated storage capacity. More... | |
const TVal & | Last () const |
Returns a reference to the last element of the vector. More... | |
TVal & | Last () |
Returns a reference to the last element of the vector. More... | |
TSizeTy | LastValN () const |
Returns the position of the last element. More... | |
const TVal & | LastLast () const |
Returns a reference to the one before last element of the vector. More... | |
TVal & | LastLast () |
Returns a reference to the one before last element of the vector. More... | |
const TVal & | GetRndVal (TRnd &Rnd=TInt::Rnd) const |
Returns a reference to a random element in the vector. More... | |
TVal & | GetRndVal (TRnd &Rnd=TInt::Rnd) |
Returns a reference to a random element in the vector. More... | |
TIter | BegI () const |
Returns an iterator pointing to the first element in the vector. More... | |
TIter | EndI () const |
Returns an iterator referring to the past-the-end element in the vector. More... | |
TIter | GetI (const TSizeTy &ValN) const |
Returns an iterator an element at position ValN . More... | |
TSizeTy | Add () |
Adds a new element at the end of the vector, after its current last element. More... | |
TSizeTy | Add (const TVal &Val) |
Adds a new element at the end of the vector, after its current last element. More... | |
TSizeTy | Add (TVal &Val) |
TSizeTy | Add (const TVal &Val, const TSizeTy &ResizeLen) |
Adds element Val at the end of the vector. #TVec::Add2. More... | |
TSizeTy | AddMP (const TVal &Val) |
Adds element Val at the end of the vector in a thread safe manner, returns the element index in the vector. TVec::AddMP. More... | |
TSizeTy | MoveLastMP (const TVal &Val, int Inc) |
Reserves space after the current last element in a thread safe manner, returning the old vector size. More... | |
TSizeTy | AddV (const TVec< TVal, TSizeTy > &ValV) |
Adds the elements of the vector ValV to the to end of the vector. More... | |
TSizeTy | AddSorted (const TVal &Val, const bool &Asc=true, const TSizeTy &_MxVals=-1) |
Adds element Val to a sorted vector. More... | |
TSizeTy | AddBackSorted (const TVal &Val, const bool &Asc) |
Adds element Val to a sorted vector. More... | |
TSizeTy | AddMerged (const TVal &Val) |
Adds element Val to a sorted vector only if the element Val is not already in the vector. More... | |
TSizeTy | AddVMerged (const TVec< TVal, TSizeTy > &ValV) |
Adds elements of ValV to a sorted vector only if a particular element is not already in the vector. More... | |
TSizeTy | AddUnique (const TVal &Val) |
Adds element Val to a vector only if the element Val is not already in the vector. More... | |
const TVal & | GetVal (const TSizeTy &ValN) const |
Returns a reference to the element at position ValN in the vector. More... | |
TVal & | GetVal (const TSizeTy &ValN) |
Returns a reference to the element at position ValN in the vector. More... | |
void | SetVal (const TSizeTy &ValN, const TVal &Val) |
Sets the value of element at position ValN to Val . More... | |
void | GetSubValV (const TSizeTy &BValN, const TSizeTy &EValN, TVec< TVal, TSizeTy > &ValV) const |
Fills ValV with elements at positions BValN...EValN . More... | |
void | Ins (const TSizeTy &ValN, const TVal &Val) |
Inserts new element Val before the element at position ValN . More... | |
void | Del (const TSizeTy &ValN) |
Removes the element at position ValN . More... | |
void | Del (const TSizeTy &MnValN, const TSizeTy &MxValN) |
Removes the elements at positions MnValN...MxValN . More... | |
void | DelLast () |
Removes the last element of the vector. More... | |
bool | DelIfIn (const TVal &Val) |
Removes the first occurrence of element Val . More... | |
void | DelAll (const TVal &Val) |
Removes all occurrences of element Val . More... | |
void | PutAll (const TVal &Val) |
Sets all elements of the vector to value Val . More... | |
void | Swap (const TSizeTy &ValN1, const TSizeTy &ValN2) |
Swaps elements at positions ValN1 and ValN2 . More... | |
bool | NextPerm () |
Generates next permutation of the elements in the vector. More... | |
bool | PrevPerm () |
Generates previous permutation of the elements in the vector. More... | |
TSizeTy | GetPivotValN (const TSizeTy &LValN, const TSizeTy &RValN) const |
Picks three random elements at positions LValN...RValN and returns the middle one. More... | |
void | BSort (const TSizeTy &MnLValN, const TSizeTy &MxRValN, const bool &Asc) |
Bubble sorts the values between positions MnLValN...MxLValN . More... | |
void | ISort (const TSizeTy &MnLValN, const TSizeTy &MxRValN, const bool &Asc) |
Insertion sorts the values between positions MnLValN...MxLValN . More... | |
TSizeTy | Partition (const TSizeTy &MnLValN, const TSizeTy &MxRValN, const bool &Asc) |
Partitions the values between positions MnLValN...MxLValN . More... | |
void | QSort (const TSizeTy &MnLValN, const TSizeTy &MxRValN, const bool &Asc) |
Quick sorts the values between positions MnLValN...MxLValN . More... | |
void | Sort (const bool &Asc=true) |
Sorts the elements of the vector. More... | |
bool | IsSorted (const bool &Asc=true) const |
Checks whether the vector is sorted in ascending (if Asc=true ) or descending (if Asc=false ) order. More... | |
void | Shuffle (TRnd &Rnd) |
Randomly shuffles the elements of the vector. More... | |
void | Reverse () |
Reverses the order of the elements in the vector. More... | |
void | Reverse (TSizeTy LValN, TSizeTy RValN) |
Reverses the order of elements between LValN...RValN . More... | |
void | Merge () |
Sorts the vector and only keeps a single element of each value. More... | |
template<class TCmp > | |
void | SortCmp (const TCmp &Cmp) |
Sorts the elements of the vector using the comparator Cmp . More... | |
template<class TCmp > | |
bool | IsSortedCmp (const TCmp &Cmp) const |
Checks whether the vector is sorted according to the comparator Cmp . More... | |
void | Intrs (const TVec< TVal, TSizeTy > &ValV) |
Sets this vector to its intersection with ValV . Assumes the vectors are sorted! More... | |
void | Union (const TVec< TVal, TSizeTy > &ValV) |
Sets this vector to its union with ValV . Assumes the vectors are sorted! More... | |
void | Diff (const TVec< TVal, TSizeTy > &ValV) |
Subtracts ValV from this vector. Assumes the vectors are sorted! More... | |
void | Intrs (const TVec< TVal, TSizeTy > &ValV, TVec< TVal, TSizeTy > &DstValV) const |
Sets DstValV to the intersection of this vector and ValV . Assumes the vectors are sorted! More... | |
void | Union (const TVec< TVal, TSizeTy > &ValV, TVec< TVal, TSizeTy > &DstValV) const |
Sets DstValV to the union of this vector and ValV . Assumes the vectors are sorted! More... | |
void | Diff (const TVec< TVal, TSizeTy > &ValV, TVec< TVal, TSizeTy > &DstValV) const |
Sets DstValV to the difference between this vector and ValV . Assumes the vectors are sorted! More... | |
TSizeTy | IntrsLen (const TVec< TVal, TSizeTy > &ValV) const |
Returns the size of the intersection of vectors this and ValV . Assumes the vectors are sorted! More... | |
TSizeTy | UnionLen (const TVec< TVal, TSizeTy > &ValV) const |
Returns the size of the union of vectors this and ValV . Assumes the vectors are sorted! More... | |
TSizeTy | Count (const TVal &Val) const |
Counts the number of occurrences of Val in the vector. More... | |
TSizeTy | SearchBin (const TVal &Val) const |
Returns the position of an element with value Val . More... | |
TSizeTy | SearchBin (const TVal &Val, TSizeTy &InsValN) const |
Returns the position of an element with value Val . More... | |
TSizeTy | SearchBinLeft (const TVal &Val, TSizeTy &InsValN) const |
Returns the position of an element with value Val . More... | |
TSizeTy | SearchForw (const TVal &Val, const TSizeTy &BValN=0) const |
Returns the position of an element with value Val . More... | |
TSizeTy | SearchBack (const TVal &Val) const |
Returns the position of an element with value Val . More... | |
TSizeTy | SearchVForw (const TVec< TVal, TSizeTy > &ValV, const TSizeTy &BValN=0) const |
Returns the starting position of vector ValV . More... | |
bool | IsIn (const TVal &Val) const |
Checks whether element Val is a member of the vector. More... | |
bool | IsIn (const TVal &Val, TSizeTy &ValN) const |
Checks whether element Val is a member of the vector. More... | |
bool | IsInBin (const TVal &Val) const |
Checks whether element Val is a member of the vector. More... | |
const TVal & | GetDat (const TVal &Val) const |
Returns reference to the first occurrence of element Val . More... | |
TVal & | GetAddDat (const TVal &Val) |
Returns reference to the first occurrence of element Val . More... | |
TSizeTy | GetMxValN () const |
Returns the position of the largest element in the vector. More... | |
Static Public Member Functions | |
static void | SwapI (TIter LVal, TIter RVal) |
Swaps the elements that iterators LVal and RVal point to. More... | |
template<class TCmp > | |
static TIter | GetPivotValNCmp (const TIter &BI, const TIter &EI, const TCmp &Cmp) |
Picks three random elements at positions BI...EI and returns the middle one under the comparator Cmp . More... | |
template<class TCmp > | |
static TIter | PartitionCmp (TIter BI, TIter EI, const TVal Pivot, const TCmp &Cmp) |
Partitions the values between positions BI...EI under the comparator Cmp . More... | |
template<class TCmp > | |
static void | BSortCmp (TIter BI, TIter EI, const TCmp &Cmp) |
Bubble sorts the values between positions BI...EI under the comparator Cmp . More... | |
template<class TCmp > | |
static void | ISortCmp (TIter BI, TIter EI, const TCmp &Cmp) |
Insertion sorts the values between positions BI...EI under the comparator Cmp . More... | |
template<class TCmp > | |
static void | QSortCmp (TIter BI, TIter EI, const TCmp &Cmp) |
Quick sorts the values between positions BI...EI under the comparator Cmp . More... | |
static TVec< TVal, TSizeTy > | GetV (const TVal &Val1) |
Returns a vector on element Val1 . More... | |
static TVec< TVal, TSizeTy > | GetV (const TVal &Val1, const TVal &Val2) |
Returns a vector on elements Val1 , Val2 . More... | |
static TVec< TVal, TSizeTy > | GetV (const TVal &Val1, const TVal &Val2, const TVal &Val3) |
Returns a vector on elements Val1...Val3 . More... | |
static TVec< TVal, TSizeTy > | GetV (const TVal &Val1, const TVal &Val2, const TVal &Val3, const TVal &Val4) |
Returns a vector on elements Val1...Val4 . More... | |
static TVec< TVal, TSizeTy > | GetV (const TVal &Val1, const TVal &Val2, const TVal &Val3, const TVal &Val4, const TVal &Val5) |
Returns a vector on elements Val1...Val5 . More... | |
static TVec< TVal, TSizeTy > | GetV (const TVal &Val1, const TVal &Val2, const TVal &Val3, const TVal &Val4, const TVal &Val5, const TVal &Val6) |
Returns a vector on elements Val1...Val6 . More... | |
static TVec< TVal, TSizeTy > | GetV (const TVal &Val1, const TVal &Val2, const TVal &Val3, const TVal &Val4, const TVal &Val5, const TVal &Val6, const TVal &Val7) |
Returns a vector on elements Val1...Val7 . More... | |
static TVec< TVal, TSizeTy > | GetV (const TVal &Val1, const TVal &Val2, const TVal &Val3, const TVal &Val4, const TVal &Val5, const TVal &Val6, const TVal &Val7, const TVal &Val8) |
Returns a vector on elements Val1...Val8 . More... | |
static TVec< TVal, TSizeTy > | GetV (const TVal &Val1, const TVal &Val2, const TVal &Val3, const TVal &Val4, const TVal &Val5, const TVal &Val6, const TVal &Val7, const TVal &Val8, const TVal &Val9) |
Returns a vector on elements Val1...Val9 . More... | |
Protected Member Functions | |
void | Resize (const TSizeTy &_MxVals=-1) |
Resizes the vector so that it can store at least _MxVals . More... | |
TStr | GetXOutOfBoundsErrMsg (const TSizeTy &ValN) const |
Constructs the out of bounds error message. More... | |
Protected Attributes | |
TSizeTy | MxVals |
Vector capacity. Capacity is the size of allocated storage. If MxVals==-1 , then ValT is not owned by the vector, and it won't free it at destruction. More... | |
TSizeTy | Vals |
Vector length. Length is the number of elements stored in the vector. More... | |
TVal * | ValT |
Vector is a sequence TVal
objects representing an array that can change in size.
Internally, vectors use a dynamically allocated array to store their elements. This array may need to be reallocated in order to grow in size when new elements are inserted, which implies allocating a new array and moving all elements to it. This is a relatively expensive task in terms of processing time. Vectors may allocate some extra storage to accommodate for possible growth, and thus the container may have an actual capacity greater than the storage strictly needed to contain its elements (i.e., its size). The reallocations only happen at logarithmically growing intervals of size so that the insertion of individual elements at the end of the vector can be provided with amortized constant time complexity. Use TSizeTy=int
for vectors of maximum size of 2 billion (2^31) and TSizeTy=int64
for vectors that can store up to 2^61 elements.
TVec< TVal, TSizeTy >::TVec | ( | const TVec< TVal, TSizeTy > & | Vec | ) |
|
inlineexplicit |
Constructs a vector (an array) of length _Vals
.
|
inline |
Constructs a vector (an array) of length _Vals
, while reserving enough memory to store _MxVals
elements.
|
inlineexplicit |
Constructs a vector of _Vals
elements of memory array _ValT
.
The data is not copied and the vector does not own the memory (i.e., the vector won't free the memory at destruction).
|
inline |
Adds a new element at the end of the vector, after its current last element.
This increases the vector size by one.
Definition at line 574 of file ds.h.
|
inline |
Adds a new element at the end of the vector, after its current last element.
The content of Val
is copied to the new element.
Definition at line 580 of file ds.h.
|
inline |
Definition at line 582 of file ds.h.
|
inline |
Adds element Val
at the end of the vector. #TVec::Add2.
Definition at line 585 of file ds.h.
TSizeTy TVec< TVal, TSizeTy >::AddBackSorted | ( | const TVal & | Val, |
const bool & | Asc | ||
) |
Adds element Val
to a sorted vector.
Asc | Adds the element so that ascending (if true ) or descending (if false ) order is maintained. |
Definition at line 1078 of file ds.h.
TSizeTy TVec< TVal, TSizeTy >::AddMerged | ( | const TVal & | Val | ) |
Adds element Val
to a sorted vector only if the element Val
is not already in the vector.
Uses binary search to check whether an element is already in the vector.
Definition at line 1089 of file ds.h.
|
inline |
Adds element Val
at the end of the vector in a thread safe manner, returns the element index in the vector. TVec::AddMP.
Definition at line 589 of file ds.h.
TSizeTy TVec< TVal, TSizeTy >::AddSorted | ( | const TVal & | Val, |
const bool & | Asc = true , |
||
const TSizeTy & | _MxVals = -1 |
||
) |
Adds element Val
to a sorted vector.
Asc | Adds the element so that ascending (if true ) or descending (if false ) order is maintained. |
Definition at line 1063 of file ds.h.
TSizeTy TVec< TVal, TSizeTy >::AddUnique | ( | const TVal & | Val | ) |
Adds element Val
to a vector only if the element Val
is not already in the vector.
Does not assume the vector to be sorted and thus uses linear search to check whether Val
is already in the vector.
Definition at line 1104 of file ds.h.
TSizeTy TVec< TVal, TSizeTy >::AddV | ( | const TVec< TVal, TSizeTy > & | ValV | ) |
Adds the elements of the vector ValV
to the to end of the vector.
Definition at line 1056 of file ds.h.
TSizeTy TVec< TVal, TSizeTy >::AddVMerged | ( | const TVec< TVal, TSizeTy > & | ValV | ) |
Adds elements of ValV
to a sorted vector only if a particular element is not already in the vector.
Uses binary search to check whether an element is already in the vector.
Definition at line 1097 of file ds.h.
void TVec< TVal, TSizeTy >::BSort | ( | const TSizeTy & | MnLValN, |
const TSizeTy & | MxRValN, | ||
const bool & | Asc | ||
) |
|
inlinestatic |
void TVec< TVal, TSizeTy >::Clr | ( | const bool & | DoDel = true , |
const TSizeTy & | NoDelLim = -1 |
||
) |
Clears the contents of the vector.
Vector's memory gets deallocated only if DoDel=true
or if vector's capacity is greater than NoDelLim
.
Definition at line 971 of file ds.h.
void TVec< TVal, TSizeTy >::CopyUniqueFrom | ( | TVec< TVal, TSizeTy > & | Vec, |
TInt | Offset, | ||
TInt | Sz | ||
) |
Copy Sz
values from Vec
starting at Offset
.
TSizeTy TVec< TVal, TSizeTy >::Count | ( | const TVal & | Val | ) | const |
void TVec< TVal, TSizeTy >::Del | ( | const TSizeTy & | ValN | ) |
Removes the element at position ValN
.
Definition at line 1130 of file ds.h.
void TVec< TVal, TSizeTy >::Del | ( | const TSizeTy & | MnValN, |
const TSizeTy & | MxValN | ||
) |
Removes the elements at positions MnValN...MxValN
.
Definition at line 1139 of file ds.h.
void TVec< TVal, TSizeTy >::DelAll | ( | const TVal & | Val | ) |
Removes all occurrences of element Val
.
Definition at line 1159 of file ds.h.
bool TVec< TVal, TSizeTy >::DelIfIn | ( | const TVal & | Val | ) |
Removes the first occurrence of element Val
.
Definition at line 1151 of file ds.h.
|
inline |
void TVec< TVal, TSizeTy >::Diff | ( | const TVec< TVal, TSizeTy > & | ValV | ) |
Subtracts ValV
from this vector. Assumes the vectors are sorted!
This vector keeps only elements that do not appear in ValV
.
void TVec< TVal, TSizeTy >::Diff | ( | const TVec< TVal, TSizeTy > & | ValV, |
TVec< TVal, TSizeTy > & | DstValV | ||
) | const |
Sets DstValV
to the difference between this vector and ValV
. Assumes the vectors are sorted!
DstValV
has all the elements of this vector that do not appear in ValV
.
|
inline |
|
inline |
Constructs a vector (an array) of _Vals
elements.
|
inline |
Constructs a vector (an array) of _Vals
elements, while reserving enough memory for _MxVals
elements.
|
inline |
Constructs a vector of _Vals
elements of memory array _ValT
.
The data is not copied and the vector does not own the memory (the vector won't free the memory at destruction).
|
inline |
Returns reference to the first occurrence of element Val
.
If the element does not exist, we add it at the end of the vector.
Definition at line 811 of file ds.h.
|
inline |
Returns reference to the first occurrence of element Val
.
|
inline |
|
inline |
|
inline |
TSizeTy TVec< TVal, TSizeTy >::GetMxValN | ( | ) | const |
TSizeTy TVec< TVal, TSizeTy >::GetPivotValN | ( | const TSizeTy & | LValN, |
const TSizeTy & | RValN | ||
) | const |
|
inlinestatic |
Picks three random elements at positions BI...EI
and returns the middle one under the comparator Cmp
.
Definition at line 698 of file ds.h.
int TVec< TVal, TSizeTy >::GetPrimHashCd | ( | ) | const |
|
inline |
|
inline |
int TVec< TVal, TSizeTy >::GetSecHashCd | ( | ) | const |
Returns secondary hash code of the vector. Used by THash
.
void TVec< TVal, TSizeTy >::GetSubValV | ( | const TSizeTy & | BValN, |
const TSizeTy & | EValN, | ||
TVec< TVal, TSizeTy > & | ValV | ||
) | const |
Fills ValV
with elements at positions BValN...EValN
.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Returns a vector on elements Val1...Val5
.
Definition at line 829 of file ds.h.
|
inlinestatic |
Returns a vector on elements Val1...Val6
.
Definition at line 832 of file ds.h.
|
inlinestatic |
Returns a vector on elements Val1...Val7
.
Definition at line 835 of file ds.h.
|
inlinestatic |
Returns a vector on elements Val1...Val8
.
Definition at line 838 of file ds.h.
|
inlinestatic |
Returns a vector on elements Val1...Val9
.
Definition at line 841 of file ds.h.
|
inline |
|
inline |
|
protected |
Constructs the out of bounds error message.
void TVec< TVal, TSizeTy >::Ins | ( | const TSizeTy & | ValN, |
const TVal & | Val | ||
) |
Inserts new element Val
before the element at position ValN
.
Definition at line 1122 of file ds.h.
void TVec< TVal, TSizeTy >::Intrs | ( | const TVec< TVal, TSizeTy > & | ValV | ) |
Sets this vector to its intersection with ValV
. Assumes the vectors are sorted!
void TVec< TVal, TSizeTy >::Intrs | ( | const TVec< TVal, TSizeTy > & | ValV, |
TVec< TVal, TSizeTy > & | DstValV | ||
) | const |
Sets DstValV
to the intersection of this vector and ValV
. Assumes the vectors are sorted!
TSizeTy TVec< TVal, TSizeTy >::IntrsLen | ( | const TVec< TVal, TSizeTy > & | ValV | ) | const |
|
inline |
Returns true if the vector was created using the GenExt()
.
In this case the vector does not own the memory (and won't free the memory at destruction).
Definition at line 513 of file ds.h.
|
inline |
|
inline |
|
inline |
void TVec< TVal, TSizeTy >::ISort | ( | const TSizeTy & | MnLValN, |
const TSizeTy & | MxRValN, | ||
const bool & | Asc | ||
) |
|
inlinestatic |
bool TVec< TVal, TSizeTy >::IsSorted | ( | const bool & | Asc = true | ) | const |
|
inline |
Checks whether the vector is sorted according to the comparator Cmp
.
|
inline |
Returns a reference to the last element of the vector.
|
inline |
Returns a reference to the last element of the vector.
|
inline |
Returns a reference to the one before last element of the vector.
|
inline |
Returns a reference to the one before last element of the vector.
|
inline |
|
inline |
void TVec< TVal, TSizeTy >::LoadXml | ( | const PXmlTok & | XmlTok, |
const TStr & | Nm = "" |
||
) |
void TVec< TVal, TSizeTy >::Merge | ( | ) |
Sorts the vector and only keeps a single element of each value.
Definition at line 1292 of file ds.h.
void TVec< TVal, TSizeTy >::MoveFrom | ( | TVec< TVal, TSizeTy > & | Vec | ) |
Takes over the data and the capacity from Vec
.
No memory gets copied and Vec
gets destroyed.
|
inline |
Reserves space after the current last element in a thread safe manner, returning the old vector size.
The method assumes that the space has been preallocated. It does not perform any checks and it does not resize the vector space. The method is thread-safe.
Definition at line 594 of file ds.h.
bool TVec< TVal, TSizeTy >::NextPerm | ( | ) |
Generates next permutation of the elements in the vector.
Assuming we started with a sorted vector repeated calls to NextPerm()
will generate all permutations of the elements of the vector. Returns false
when the last permutation is reached.
Definition at line 1303 of file ds.h.
bool TVec< TVal, TSizeTy >::operator< | ( | const TVec< TVal, TSizeTy > & | Vec | ) | const |
TVec< TVal, TSizeTy > & TVec< TVal, TSizeTy >::operator= | ( | const TVec< TVal, TSizeTy > & | Vec | ) |
Assigns new contents to the vector, replacing its current content.
bool TVec< TVal, TSizeTy >::operator== | ( | const TVec< TVal, TSizeTy > & | Vec | ) | const |
|
inline |
Returns a reference to the element at position ValN
in the vector.
|
inline |
Returns a reference to the element at position ValN
in the vector.
void TVec< TVal, TSizeTy >::Pack | ( | ) |
Reduces vector capacity (frees memory) to match its size.
Definition at line 1005 of file ds.h.
TSizeTy TVec< TVal, TSizeTy >::Partition | ( | const TSizeTy & | MnLValN, |
const TSizeTy & | MxRValN, | ||
const bool & | Asc | ||
) |
Partitions the values between positions MnLValN...MxLValN
.
Helper function used by QSort()
.
Asc | Sorts the elements in ascending (if true ) or descending (if false ) order. |
|
inlinestatic |
bool TVec< TVal, TSizeTy >::PrevPerm | ( | ) |
Generates previous permutation of the elements in the vector.
Returns false
when the first permutation is reached.
Definition at line 1325 of file ds.h.
void TVec< TVal, TSizeTy >::PutAll | ( | const TVal & | Val | ) |
void TVec< TVal, TSizeTy >::QSort | ( | const TSizeTy & | MnLValN, |
const TSizeTy & | MxRValN, | ||
const bool & | Asc | ||
) |
Quick sorts the values between positions MnLValN...MxLValN
.
Helper function used by Sort()
.
Asc | Sorts the elements in ascending (if true ) or descending (if false ) order. |
Definition at line 1241 of file ds.h.
|
inlinestatic |
Quick sorts the values between positions BI...EI
under the comparator Cmp
.
Definition at line 731 of file ds.h.
|
inline |
|
inline |
|
inline |
Reserves enough memory for the vector to store _MxVals
elements and sets its length to _Vals
.
|
inline |
|
protected |
Resizes the vector so that it can store at least _MxVals
.
Definition at line 846 of file ds.h.
void TVec< TVal, TSizeTy >::Reverse | ( | ) |
|
inline |
void TVec< TVal, TSizeTy >::SaveXml | ( | TSOut & | SOut, |
const TStr & | Nm | ||
) | const |
TSizeTy TVec< TVal, TSizeTy >::SearchBack | ( | const TVal & | Val | ) | const |
TSizeTy TVec< TVal, TSizeTy >::SearchBin | ( | const TVal & | Val | ) | const |
TSizeTy TVec< TVal, TSizeTy >::SearchBin | ( | const TVal & | Val, |
TSizeTy & | InsValN | ||
) | const |
TSizeTy TVec< TVal, TSizeTy >::SearchBinLeft | ( | const TVal & | Val, |
TSizeTy & | InsValN | ||
) | const |
TSizeTy TVec< TVal, TSizeTy >::SearchForw | ( | const TVal & | Val, |
const TSizeTy & | BValN = 0 |
||
) | const |
TSizeTy TVec< TVal, TSizeTy >::SearchVForw | ( | const TVec< TVal, TSizeTy > & | ValV, |
const TSizeTy & | BValN = 0 |
||
) | const |
Returns the starting position of vector ValV
.
If the vector is not found return value is -1.
|
inline |
Sets the value of element at position ValN
to Val
.
void TVec< TVal, TSizeTy >::Sort | ( | const bool & | Asc = true | ) |
Sorts the elements of the vector.
Use a combination if quicksort and insertion sort.
Asc | Sorts the elements in ascending (if true ) or descending (if false ) order. |
Definition at line 1254 of file ds.h.
|
inline |
Sorts the elements of the vector using the comparator Cmp
.
Definition at line 739 of file ds.h.
Swaps the contents of the vector with Vec
.
Definition at line 1047 of file ds.h.
|
inline |
void TVec< TVal, TSizeTy >::Trunc | ( | const TSizeTy & | _Vals = -1 | ) |
Truncates the vector's length and capacity to _Vals
elements.
If _Vals=-1
then the capacity is reduced to match vector's length.
Definition at line 982 of file ds.h.
void TVec< TVal, TSizeTy >::Union | ( | const TVec< TVal, TSizeTy > & | ValV | ) |
Sets this vector to its union with ValV
. Assumes the vectors are sorted!
void TVec< TVal, TSizeTy >::Union | ( | const TVec< TVal, TSizeTy > & | ValV, |
TVec< TVal, TSizeTy > & | DstValV | ||
) | const |
Sets DstValV
to the union of this vector and ValV
. Assumes the vectors are sorted!
TSizeTy TVec< TVal, TSizeTy >::UnionLen | ( | const TVec< TVal, TSizeTy > & | ValV | ) | const |
|
protected |
|
protected |
|
protected |