|
| 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 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...
|
|
template<class TVal, class TSizeTy = int>
class TVec< TVal, TSizeTy >
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.
Definition at line 429 of file ds.h.