SNAP Library , User Reference
2013-01-07 14:03:36
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#include <ds.h>
Public Types | |
typedef TVal * | TIter |
Public Member Functions | |
TVec () | |
TVec (const TVec &Vec) | |
TVec (const int &_Vals) | |
TVec (const int &_MxVals, const int &_Vals) | |
TVec (TVal *_ValT, const int &_Vals) | |
~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 > & | operator= (const TVec< TVal > &Vec) |
TVec< TVal > & | operator+ (const TVal &Val) |
bool | operator== (const TVec< TVal > &Vec) const |
bool | operator< (const TVec< TVal > &Vec) const |
const TVal & | operator[] (const int &ValN) const |
TVal & | operator[] (const int &ValN) |
int | GetMemUsed () const |
int | GetPrimHashCd () const |
int | GetSecHashCd () const |
void | Gen (const int &_Vals) |
void | Gen (const int &_MxVals, const int &_Vals) |
void | GenExt (TVal *_ValT, const int &_Vals) |
bool | IsExt () const |
void | Reserve (const int &_MxVals) |
void | Reserve (const int &_MxVals, const int &_Vals) |
void | Clr (const bool &DoDel=true, const int &NoDelLim=-1) |
void | Trunc (const int &_Vals=-1) |
void | Pack () |
void | MoveFrom (TVec< TVal > &Vec) |
void | Swap (TVec< TVal > &Vec) |
bool | Empty () const |
int | Len () const |
int | Reserved () const |
const TVal & | Last () const |
TVal & | Last () |
int | LastValN () const |
const TVal & | LastLast () const |
TVal & | LastLast () |
TIter | BegI () const |
TIter | EndI () const |
TIter | GetI (const int &ValN) const |
int | Add () |
int | Add (const TVal &Val) |
int | Add (const TVal &Val, const int &ResizeLen) |
int | AddV (const TVec< TVal > &ValV) |
int | AddSorted (const TVal &Val, const bool &Asc=true, const int &_MxVals=-1) |
int | AddBackSorted (const TVal &Val, const bool &Asc) |
int | AddMerged (const TVal &Val) |
int | AddVMerged (const TVec< TVal > &ValV) |
int | AddUnique (const TVal &Val) |
const TVal & | GetVal (const int &ValN) const |
TVal & | GetVal (const int &ValN) |
void | GetSubValV (const int &BValN, const int &EValN, TVec< TVal > &ValV) const |
void | Ins (const int &ValN, const TVal &Val) |
void | Del (const int &ValN) |
void | Del (const int &MnValN, const int &MxValN) |
void | DelLast () |
bool | DelIfIn (const TVal &Val) |
void | DelAll (const TVal &Val) |
void | PutAll (const TVal &Val) |
void | Swap (const int &ValN1, const int &ValN2) |
int | GetPivotValN (const int &LValN, const int &RValN) const |
void | BSort (const int &MnLValN, const int &MxRValN, const bool &Asc) |
void | ISort (const int &MnLValN, const int &MxRValN, const bool &Asc) |
int | Partition (const int &MnLValN, const int &MxRValN, const bool &Asc) |
void | QSort (const int &MnLValN, const int &MxRValN, const bool &Asc) |
void | Sort (const bool &Asc=true) |
bool | IsSorted (const bool &Asc=true) const |
void | Shuffle (TRnd &Rnd) |
void | Reverse () |
void | Reverse (int First, int Last) |
void | Merge () |
bool | NextPerm () |
bool | PrevPerm () |
void | MakeHeap () |
void | PushHeap (const TVal &Val) |
const TVal & | TopHeap () const |
TVal | PopHeap () |
template<class TCmp > | |
void | MakeHeap (const TCmp &Cmp) |
template<class TCmp > | |
void | PushHeap (const TVal &Val, const TCmp &Cmp) |
template<class TCmp > | |
TVal | PopHeap (const TCmp &Cmp) |
template<class TCmp > | |
void | PushHeap (const int &First, int HoleIdx, const int &Top, TVal Val, const TCmp &Cmp) |
template<class TCmp > | |
void | AdjustHeap (const int &First, int HoleIdx, const int &Len, TVal Val, const TCmp &Cmp) |
template<class TCmp > | |
void | MakeHeap (const int &First, const int &Len, const TCmp &Cmp) |
template<class TCmp > | |
void | SortCmp (const TCmp &Cmp) |
template<class TCmp > | |
bool | IsSortedCmp (const TCmp &Cmp) const |
void | Intrs (const TVec< TVal > &ValV) |
void | Union (const TVec< TVal > &ValV) |
void | Diff (const TVec< TVal > &ValV) |
void | Minus (const TVec< TVal > &ValV) |
void | Intrs (const TVec< TVal > &ValV, TVec< TVal > &DstValV) const |
void | Union (const TVec< TVal > &ValV, TVec< TVal > &DstValV) const |
void | Diff (const TVec< TVal > &ValV, TVec< TVal > &DstValV) const |
int | IntrsLen (const TVec< TVal > &ValV) const |
Get the size of the intersection (number of common elements) of two vectors. Method assumes both vectors are sorted in ascending order! | |
void | Minus (const TVec< TVal > &ValV, TVec< TVal > &DstValV) const |
int | Count (const TVal &Val) const |
int | SearchBin (const TVal &Val) const |
int | SearchBin (const TVal &Val, int &InsValN) const |
int | SearchForw (const TVal &Val, const int &BValN=0) const |
int | SearchBack (const TVal &Val) const |
int | SearchVForw (const TVec< TVal > &ValV, const int &BValN=0) const |
bool | IsIn (const TVal &Val) const |
bool | IsIn (const TVal &Val, int &ValN) const |
bool | IsInBin (const TVal &Val) const |
int | GetMxValN () const |
TVal & | GetDat (const TVal &Val) const |
TVal & | GetAddDat (const TVal &Val) |
Static Public Member Functions | |
static void | SwapI (TIter LVal, TIter RVal) |
template<class TCmp > | |
static TIter | GetPivotValNCmp (const TIter &BI, const TIter &EI, const TCmp &Cmp) |
template<class TCmp > | |
static TIter | PartitionCmp (TIter BI, TIter EI, const TVal Pivot, const TCmp &Cmp) |
template<class TCmp > | |
static void | BSortCmp (TIter BI, TIter EI, const TCmp &Cmp) |
template<class TCmp > | |
static void | ISortCmp (TIter BI, TIter EI, const TCmp &Cmp) |
template<class TCmp > | |
static void | QSortCmp (TIter BI, TIter EI, const TCmp &Cmp) |
static TVec< TVal > | GetV (const TVal &Val1) |
static TVec< TVal > | GetV (const TVal &Val1, const TVal &Val2) |
static TVec< TVal > | GetV (const TVal &Val1, const TVal &Val2, const TVal &Val3) |
static TVec< TVal > | GetV (const TVal &Val1, const TVal &Val2, const TVal &Val3, const TVal &Val4) |
static TVec< TVal > | GetV (const TVal &Val1, const TVal &Val2, const TVal &Val3, const TVal &Val4, const TVal &Val5) |
static TVec< TVal > | GetV (const TVal &Val1, const TVal &Val2, const TVal &Val3, const TVal &Val4, const TVal &Val5, const TVal &Val6) |
static TVec< TVal > | GetV (const TVal &Val1, const TVal &Val2, const TVal &Val3, const TVal &Val4, const TVal &Val5, const TVal &Val6, const TVal &Val7) |
static TVec< TVal > | 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) |
static TVec< TVal > | 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) |
Protected Member Functions | |
void | Resize (const int &_MxVals=-1) |
TStr | GetXOutOfBoundsErrMsg (const int &ValN) const |
Protected Attributes | |
int | MxVals |
int | Vals |
TVal * | ValT |
int TVec< TVal >::AddBackSorted | ( | const TVal & | Val, |
const bool & | Asc | ||
) |
int TVec< TVal >::AddSorted | ( | const TVal & | Val, |
const bool & | Asc = true , |
||
const int & | _MxVals = -1 |
||
) |
int TVec< TVal >::AddVMerged | ( | const TVec< TVal > & | ValV | ) |
void TVec< TVal >::AdjustHeap | ( | const int & | First, |
int | HoleIdx, | ||
const int & | Len, | ||
TVal | Val, | ||
const TCmp & | Cmp | ||
) | [inline] |
Definition at line 544 of file ds.h.
{ const int Top = HoleIdx; int Right = 2*HoleIdx+2; while (Right < Len) { if (Cmp(ValT[First+Right], ValT[First+Right-1])) { Right--; } ValT[First+HoleIdx] = ValT[First+Right]; HoleIdx = Right; Right = 2*(Right+1); } if (Right == Len) { ValT[First+HoleIdx] = ValT[First+Right-1]; HoleIdx = Right-1; } PushHeap(First, HoleIdx, Top, Val, Cmp); }
Definition at line 1182 of file ds.h.
{ TVec<TVal> DiffVec; Diff(ValV, DiffVec); MoveFrom(DiffVec); }
void TVec< TVal >::Diff | ( | const TVec< TVal > & | ValV, |
TVec< TVal > & | DstValV | ||
) | const |
Definition at line 1258 of file ds.h.
{ DstValV.Clr(); int ValN1=0; int ValN2=0; while (ValN1<Len() && ValN2<ValV.Len()) { const TVal& Val1 = GetVal(ValN1); while (ValN2<ValV.Len() && Val1>ValV.GetVal(ValN2)) ValN2++; if (ValN2<ValV.Len()) { if (Val1!=ValV.GetVal(ValN2)) { DstValV.Add(Val1); } ValN1++; } } for (int RestValN1=ValN1; RestValN1<Len(); RestValN1++){ DstValV.Add(GetVal(RestValN1));} }
Definition at line 675 of file ds.h.
{ Assert(MxVals!=-1); int ValN=SearchForw(Val); if (ValN==-1){Add(Val); return Last();} else {return operator[](ValN);}}
Definition at line 672 of file ds.h.
{ int ValN=SearchForw(Val); return operator[](ValN);}
int TVec< TVal >::GetMemUsed | ( | ) | const [inline] |
int TVec< TVal >::GetPivotValN | ( | const int & | LValN, |
const int & | RValN | ||
) | const |
Definition at line 1031 of file ds.h.
{ int SubVals=RValN-LValN+1; int ValN1=LValN+TInt::GetRnd(SubVals); int ValN2=LValN+TInt::GetRnd(SubVals); int ValN3=LValN+TInt::GetRnd(SubVals); const TVal& Val1=ValT[ValN1]; const TVal& Val2=ValT[ValN2]; const TVal& Val3=ValT[ValN3]; if (Val1<Val2){ if (Val2<Val3){return ValN2;} else if (Val3<Val1){return ValN1;} else {return ValN3;} } else { if (Val1<Val3){return ValN1;} else if (Val3<Val2){return ValN2;} else {return ValN3;} } }
static TIter TVec< TVal >::GetPivotValNCmp | ( | const TIter & | BI, |
const TIter & | EI, | ||
const TCmp & | Cmp | ||
) | [inline, static] |
Definition at line 566 of file ds.h.
{ const int SubVals=int(EI-BI); const int ValN1=TInt::GetRnd(SubVals); const int ValN2=TInt::GetRnd(SubVals); const int ValN3=TInt::GetRnd(SubVals); const TVal& Val1 = *(BI+ValN1); const TVal& Val2 = *(BI+ValN2); const TVal& Val3 = *(BI+ValN3); if (Cmp(Val1, Val2)) { if (Cmp(Val2, Val3)) return BI+ValN2; else if (Cmp(Val3, Val1)) return BI+ValN1; else return BI+ValN3; } else { if (Cmp(Val1, Val3)) return BI+ValN1; else if (Cmp(Val3, Val2)) return BI+ValN2; else return BI+ValN3; } }
int TVec< TVal >::GetPrimHashCd | ( | ) | const |
int TVec< TVal >::GetSecHashCd | ( | ) | const |
void TVec< TVal >::GetSubValV | ( | const int & | BValN, |
const int & | EValN, | ||
TVec< TVal > & | ValV | ||
) | const |
Definition at line 938 of file ds.h.
{ int BValN=TInt::GetInRng(_BValN, 0, Len()-1); int EValN=TInt::GetInRng(_EValN, 0, Len()-1); int SubVals=TInt::GetMx(0, EValN-BValN+1); SubValV.Gen(SubVals, 0); for (int ValN=BValN; ValN<=EValN; ValN++){ SubValV.Add(GetVal(ValN));} }
Definition at line 682 of file ds.h.
{ TVec<TVal> V(1, 0); V.Add(Val1); return V;}
static TVec<TVal> TVec< TVal >::GetV | ( | const TVal & | Val1, |
const TVal & | Val2 | ||
) | [inline, static] |
Definition at line 684 of file ds.h.
{ TVec<TVal> V(2, 0); V.Add(Val1); V.Add(Val2); return V;}
static TVec<TVal> TVec< TVal >::GetV | ( | const TVal & | Val1, |
const TVal & | Val2, | ||
const TVal & | Val3 | ||
) | [inline, static] |
Definition at line 686 of file ds.h.
{ TVec<TVal> V(3, 0); V.Add(Val1); V.Add(Val2); V.Add(Val3); return V;}
static TVec<TVal> TVec< TVal >::GetV | ( | const TVal & | Val1, |
const TVal & | Val2, | ||
const TVal & | Val3, | ||
const TVal & | Val4 | ||
) | [inline, static] |
Definition at line 688 of file ds.h.
{ TVec<TVal> V(4, 0); V.Add(Val1); V.Add(Val2); V.Add(Val3); V.Add(Val4); return V;}
static TVec<TVal> TVec< TVal >::GetV | ( | const TVal & | Val1, |
const TVal & | Val2, | ||
const TVal & | Val3, | ||
const TVal & | Val4, | ||
const TVal & | Val5 | ||
) | [inline, static] |
Definition at line 690 of file ds.h.
{ TVec<TVal> V(5, 0); V.Add(Val1); V.Add(Val2); V.Add(Val3); V.Add(Val4); V.Add(Val5); return V;}
static TVec<TVal> TVec< TVal >::GetV | ( | const TVal & | Val1, |
const TVal & | Val2, | ||
const TVal & | Val3, | ||
const TVal & | Val4, | ||
const TVal & | Val5, | ||
const TVal & | Val6 | ||
) | [inline, static] |
Definition at line 692 of file ds.h.
{ TVec<TVal> V(6, 0); V.Add(Val1); V.Add(Val2); V.Add(Val3); V.Add(Val4); V.Add(Val5); V.Add(Val6); return V;}
static TVec<TVal> TVec< TVal >::GetV | ( | const TVal & | Val1, |
const TVal & | Val2, | ||
const TVal & | Val3, | ||
const TVal & | Val4, | ||
const TVal & | Val5, | ||
const TVal & | Val6, | ||
const TVal & | Val7 | ||
) | [inline, static] |
Definition at line 694 of file ds.h.
{ TVec<TVal> V(7, 0); V.Add(Val1); V.Add(Val2); V.Add(Val3); V.Add(Val4); V.Add(Val5); V.Add(Val6); V.Add(Val7); return V;}
static TVec<TVal> TVec< TVal >::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 | ||
) | [inline, static] |
Definition at line 696 of file ds.h.
{ TVec<TVal> V(8, 0); V.Add(Val1); V.Add(Val2); V.Add(Val3); V.Add(Val4); V.Add(Val5); V.Add(Val6); V.Add(Val7); V.Add(Val8); return V;}
static TVec<TVal> TVec< TVal >::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 | ||
) | [inline, static] |
Definition at line 698 of file ds.h.
{ TVec<TVal> V(9, 0); V.Add(Val1); V.Add(Val2); V.Add(Val3); V.Add(Val4); V.Add(Val5); V.Add(Val6); V.Add(Val7); V.Add(Val8); V.Add(Val9); return V;}
Definition at line 493 of file ds.h.
{return operator[](ValN);}
Definition at line 494 of file ds.h.
{return operator[](ValN);}
TStr TVec< TVal >::GetXOutOfBoundsErrMsg | ( | const int & | ValN | ) | const [protected] |
Definition at line 733 of file ds.h.
{ return TStr()+ "Index:"+TInt::GetStr(ValN)+ " Vals:"+TInt::GetStr(Vals)+ " MxVals:"+TInt::GetStr(MxVals)+ " Type:"+GetTypeNm(*this); }
Definition at line 1168 of file ds.h.
{ TVec<TVal> IntrsVec; Intrs(ValV, IntrsVec); MoveFrom(IntrsVec); }
void TVec< TVal >::Intrs | ( | const TVec< TVal > & | ValV, |
TVec< TVal > & | DstValV | ||
) | const |
Get the size of the intersection (number of common elements) of two vectors. Method assumes both vectors are sorted in ascending order!
Definition at line 667 of file ds.h.
{return SearchForw(Val)!=-1;}
Definition at line 668 of file ds.h.
{ ValN=SearchForw(Val); return ValN!=-1;}
void TVec< TVal >::ISort | ( | const int & | MnLValN, |
const int & | MxRValN, | ||
const bool & | Asc | ||
) |
Definition at line 1013 of file ds.h.
{ if (MnLValN<MxRValN){ for (int ValN1=MnLValN+1; ValN1<=MxRValN; ValN1++){ TVal Val=ValT[ValN1]; int ValN2=ValN1; if (Asc){ while ((ValN2>MnLValN)&&(ValT[ValN2-1]>Val)){ ValT[ValN2]=ValT[ValN2-1]; ValN2--;} } else { while ((ValN2>MnLValN)&&(ValT[ValN2-1]<Val)){ ValT[ValN2]=ValT[ValN2-1]; ValN2--;} } ValT[ValN2]=Val; } } }
bool TVec< TVal >::IsSortedCmp | ( | const TCmp & | Cmp | ) | const [inline] |
Definition at line 526 of file ds.h.
{ MakeHeap(TLss<TVal>()); } // build a heap
Definition at line 1189 of file ds.h.
{ TVec<TVal> MinusVec; Minus(ValV, MinusVec); MoveFrom(MinusVec); }
Definition at line 1125 of file ds.h.
{ // start with a sorted sequence to obtain all permutations int First = 0, Last = Len(), Next = Len()-1; if (Last < 2) return false; for(; ; ) { // find rightmost element smaller than successor int Next1 = Next; if (GetVal(--Next) < GetVal(Next1)) { // swap with rightmost element that's smaller, flip suffix int Mid = Last; for (; GetVal(Next) >= GetVal(--Mid); ) { } Swap(Next, Mid); Reverse(Next1, Last); return true; } if (Next == First) { // pure descending, flip all Reverse(); return false; } } }
const TVal& TVec< TVal >::operator[] | ( | const int & | ValN | ) | const [inline] |
TVal& TVec< TVal >::operator[] | ( | const int & | ValN | ) | [inline] |
int TVec< TVal >::Partition | ( | const int & | MnLValN, |
const int & | MxRValN, | ||
const bool & | Asc | ||
) |
Definition at line 1051 of file ds.h.
{ int PivotValN=GetPivotValN(MnLValN, MxRValN); Swap(PivotValN, MnLValN); TVal PivotVal=ValT[MnLValN]; int LValN=MnLValN-1; int RValN=MxRValN+1; forever { if (Asc){ do {RValN--;} while (ValT[RValN]>PivotVal); do {LValN++;} while (ValT[LValN]<PivotVal); } else { do {RValN--;} while (ValT[RValN]<PivotVal); do {LValN++;} while (ValT[LValN]>PivotVal); } if (LValN<RValN){Swap(LValN, RValN);} else {return RValN;} }; }
Definition at line 529 of file ds.h.
{ return PopHeap(TLss<TVal>()); } // remove largest element
Definition at line 1147 of file ds.h.
{ int First = 0, Last = Len(), Next = Len()-1; if (Last < 2) return false; for(; ; ) { // find rightmost element not smaller than successor int Next1 = Next; if (GetVal(--Next) >= GetVal(Next1)) { // swap with rightmost element that's not smaller, flip suffix int Mid = Last; for (; GetVal(Next) < GetVal(--Mid); ) { } Swap(Next, Mid); Reverse(Next1, Last); return true; } if (Next == First) { // pure descending, flip all Reverse(); return false; } } }
Definition at line 527 of file ds.h.
{ PushHeap(Val, TLss<TVal>()); } // add element to the heap
static void TVec< TVal >::QSortCmp | ( | TIter | BI, |
TIter | EI, | ||
const TCmp & | Cmp | ||
) | [inline, static] |
Definition at line 617 of file ds.h.
{ if (BI + 1 < EI) { if (EI - BI < 20) { ISortCmp(BI, EI, Cmp); } else { const TVal Val = *GetPivotValNCmp(BI, EI, Cmp); TIter Split = PartitionCmp(BI, EI, Val, Cmp); QSortCmp(BI, Split, Cmp); QSortCmp(Split, EI, Cmp); } } }
Definition at line 705 of file ds.h.
{ IAssertR(MxVals!=-1, TStr::Fmt("Can not resize buffer. %s. [Program failed to allocate more memory. Solution: Get a bigger machine and a 64-bit compiler.]", GetTypeNm(*this).CStr()).CStr()); if (_MxVals==-1){ if (Vals==0){MxVals=16;} else {MxVals*=2;} } else { if (_MxVals<=MxVals){return;} else {MxVals=_MxVals;} } if (ValT==NULL){ try {ValT=new TVal[MxVals];} catch (std::exception Ex){ FailR(TStr::Fmt("TVec::Resize 1: %s, Vals:%d, MxVals:%d, _MxVals:%d, Type:%s [Program failed to allocate more memory. Solution: Get a bigger machine and a 64-bit compiler.]", Ex.what(), Vals, MxVals, _MxVals, GetTypeNm(*this).CStr()).CStr());} } else { //if (Vals > 1000000) { // printf("%s resize %d -> %d\n", GetTypeNm(*this).CStr(), Vals, MxVals); } TVal* NewValT = NULL; try { NewValT=new TVal[MxVals];} catch (std::exception Ex){ FailR(TStr::Fmt("TVec::Resize 2: %s, Vals:%d, MxVals:%d, _MxVals:%d, Type:%s [Program failed to allocate more memory. Solution: Get a bigger machine and a 64-bit compiler.]", Ex.what(), Vals, MxVals, _MxVals, GetTypeNm(*this).CStr()).CStr());} Assert(NewValT!=NULL); for (int ValN=0; ValN<Vals; ValN++){NewValT[ValN]=ValT[ValN];} delete[] ValT; ValT=NewValT; } }
Definition at line 113 of file xmlser.h.
{ XSaveHdArg(Nm, "Vals", TInt::GetStr(Vals)); for (int ValN=0; ValN<Vals; ValN++){ValT[ValN].SaveXml(SOut, TStr());} }
int TVec< TVal >::SearchBack | ( | const TVal & | Val | ) | const |
int TVec< TVal >::SearchForw | ( | const TVal & | Val, |
const int & | BValN = 0 |
||
) | const |
int TVec< TVal >::SearchVForw | ( | const TVec< TVal > & | ValV, |
const int & | BValN = 0 |
||
) | const |
Definition at line 1102 of file ds.h.
{ for (int ValN=0; ValN<Vals-1; ValN++){ Swap(ValN, ValN+Rnd.GetUniDevInt(Vals-ValN));} }
Definition at line 826 of file ds.h.
{ IAssert(MxVals!=-1); IAssert((_Vals==-1)||(_Vals>=0)); if ((_Vals!=-1)&&(_Vals>=Vals)){ return; } else if (((_Vals==-1)&&(Vals==0))||(_Vals==0)){ if (ValT!=NULL){delete[] ValT;} MxVals=Vals=0; ValT=NULL; } else { if (_Vals==-1){ if (MxVals==Vals){return;} else {MxVals=Vals;} } else { MxVals=Vals=_Vals; } TVal* NewValT=new TVal[MxVals]; IAssert(NewValT!=NULL); for (int ValN=0; ValN<Vals; ValN++){NewValT[ValN]=ValT[ValN];} delete[] ValT; ValT=NewValT; } }
Definition at line 1175 of file ds.h.
{ TVec<TVal> UnionVec; Union(ValV, UnionVec); MoveFrom(UnionVec); }
void TVec< TVal >::Union | ( | const TVec< TVal > & | ValV, |
TVec< TVal > & | DstValV | ||
) | const |
Definition at line 1210 of file ds.h.
{ DstValV.Gen(TInt::GetMx(Len(), ValV.Len()), 0); int ValN1=0; int ValN2=0; while ((ValN1<Len())&&(ValN2<ValV.Len())){ const TVal& Val1=GetVal(ValN1); const TVal& Val2=ValV.GetVal(ValN2); if (Val1<Val2){DstValV.Add(Val1); ValN1++;} else if (Val1>Val2){DstValV.Add(Val2); ValN2++;} else {DstValV.Add(Val1); ValN1++; ValN2++;} } for (int RestValN1=ValN1; RestValN1<Len(); RestValN1++){ DstValV.Add(GetVal(RestValN1));} for (int RestValN2=ValN2; RestValN2<ValV.Len(); RestValN2++){ DstValV.Add(ValV.GetVal(RestValN2));} }