SNAP Library , Developer 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 TLstNd< TVal > * | PLstNd |
Public Member Functions | |
TLst () | |
TLst (const TLst &) | |
~TLst () | |
TLst (TSIn &SIn) | |
void | Save (TSOut &SOut) const |
TLst & | operator= (const TLst &) |
void | Clr () |
bool | Empty () const |
int | Len () const |
PLstNd | First () const |
PLstNd | Last () const |
TVal & | FirstVal () const |
TVal & | LastVal () const |
PLstNd | AddFront (const TVal &Val) |
PLstNd | AddBack (const TVal &Val) |
PLstNd | AddFrontSorted (const TVal &Val, const bool &Asc=true) |
PLstNd | AddBackSorted (const TVal &Val, const bool &Asc=true) |
void | PutFront (const PLstNd &Nd) |
void | PutBack (const PLstNd &Nd) |
PLstNd | Ins (const PLstNd &Nd, const TVal &Val) |
void | Del (const TVal &Val) |
void | Del (const PLstNd &Nd) |
void | DelFirst () |
void | DelLast () |
PLstNd | SearchForw (const TVal &Val) |
PLstNd | SearchBack (const TVal &Val) |
Private Attributes | |
int | Nds |
PLstNd | FirstNd |
PLstNd | LastNd |
Friends | |
class | TLstNd< TVal > |
Definition at line 2245 of file ds.h.
References TLst< TVal >::AddBack(), Assert, TSIn::Load(), and TLst< TVal >::Nds.
: Nds(0), FirstNd(NULL), LastNd(NULL){ int CheckNds=0; SIn.Load(CheckNds); for (int NdN=0; NdN<CheckNds; NdN++){AddBack(TVal(SIn));} Assert(Nds==CheckNds); }
Definition at line 2270 of file ds.h.
References TLstNd< TVal >::NextNd, and TLstNd< TVal >::Val.
Referenced by TLst< TVal >::TLst().
{ PLstNd Nd=new TLstNd<TVal>(LastNd, NULL, Val); if (LastNd!=NULL){LastNd->NextNd=Nd; LastNd=Nd;} else {FirstNd=Nd; LastNd=Nd;} Nds++; return Nd; }
TLstNd< TVal > * TLst< TVal >::AddBackSorted | ( | const TVal & | Val, |
const bool & | Asc = true |
||
) |
Definition at line 2291 of file ds.h.
References TLstNd< TVal >::Prev(), and TLstNd< TVal >::Val.
{ PLstNd Nd=Last(); while ((Nd!=NULL)&&((Asc&&(Val<Nd->Val))||(!Asc&&(Val>Nd->Val)))){ Nd=Nd->Prev();} return Ins(Nd, Val); }
Definition at line 2262 of file ds.h.
References TLstNd< TVal >::PrevNd, and TLstNd< TVal >::Val.
TLstNd< TVal > * TLst< TVal >::AddFrontSorted | ( | const TVal & | Val, |
const bool & | Asc = true |
||
) |
Definition at line 2278 of file ds.h.
References TLstNd< TVal >::Next(), TLstNd< TVal >::Prev(), and TLstNd< TVal >::Val.
{ PLstNd Nd=First(); if (Nd==NULL){ return Ins(Nd, Val); } else { while ((Nd!=NULL)&&((Asc&&(Val>Nd()))||(!Asc&&(Val<Nd())))){ Nd=Nd->Next();} if (Nd==NULL){return Ins(Nd->Last(), Val);} else {return Ins(Nd->Prev(), Val);} } }
Definition at line 2338 of file ds.h.
Referenced by TLst< TKey >::DelFirst(), and TLst< TKey >::DelLast().
{ PLstNd Nd=SearchForw(Val); if (Nd!=NULL){Del(Nd);} }
Definition at line 2344 of file ds.h.
References Assert, TLstNd< TVal >::NextNd, and TLstNd< TVal >::PrevNd.
Definition at line 2221 of file ds.h.
Referenced by TExpVal::operator<(), TExpVal::operator==(), and TExpVal::SaveTxt().
{return FirstNd;}
Definition at line 2327 of file ds.h.
References TLstNd< TVal >::NextNd, TLstNd< TVal >::PrevNd, and TLstNd< TVal >::Val.
Definition at line 2220 of file ds.h.
Referenced by TExpVal::operator<(), TExpVal::operator==(), and TExpVal::SaveTxt().
{return Nds;}
Definition at line 2313 of file ds.h.
References Assert, TLstNd< TVal >::NextNd, and TLstNd< TVal >::PrevNd.
{ Assert(Nd!=NULL); // unchain if (Nd->PrevNd==NULL){FirstNd=Nd->NextNd;} else {Nd->PrevNd->NextNd=Nd->NextNd;} if (Nd->NextNd==NULL){LastNd=Nd->PrevNd;} else {Nd->NextNd->PrevNd=Nd->PrevNd;} // add to back Nd->PrevNd=LastNd; Nd->NextNd=NULL; if (LastNd!=NULL){LastNd->NextNd=Nd; LastNd=Nd;} else {FirstNd=Nd; LastNd=Nd;} }
Definition at line 2299 of file ds.h.
References Assert, TLstNd< TVal >::NextNd, and TLstNd< TVal >::PrevNd.
{ Assert(Nd!=NULL); // unchain if (Nd->PrevNd==NULL){FirstNd=Nd->NextNd;} else {Nd->PrevNd->NextNd=Nd->NextNd;} if (Nd->NextNd==NULL){LastNd=Nd->PrevNd;} else {Nd->NextNd->PrevNd=Nd->PrevNd;} // add to front Nd->PrevNd=NULL; Nd->NextNd=FirstNd; if (FirstNd!=NULL){FirstNd->PrevNd=Nd; FirstNd=Nd;} else {FirstNd=Nd; LastNd=Nd;} }
Definition at line 2253 of file ds.h.
References IAssert, TLstNd< TVal >::NextNd, TSOut::Save(), and TLstNd< TVal >::Val.
{ SOut.Save(Nds); PLstNd Nd=FirstNd; int CheckNds=0; while (Nd!=NULL){ Nd->Val.Save(SOut); Nd=Nd->NextNd; CheckNds++;} IAssert(Nds==CheckNds); }
TLstNd< TVal > * TLst< TVal >::SearchBack | ( | const TVal & | Val | ) |
Definition at line 2364 of file ds.h.
References TLstNd< TVal >::GetVal(), TLstNd< TVal >::Prev(), and TLstNd< TVal >::Val.
{ PLstNd Nd=Last(); while (Nd!=NULL){ if (Nd->GetVal()==Val){return Nd;} Nd=Nd->Prev(); } return NULL; }
TLstNd< TVal > * TLst< TVal >::SearchForw | ( | const TVal & | Val | ) |
Definition at line 2354 of file ds.h.
References TLstNd< TVal >::GetVal(), TLstNd< TVal >::Next(), and TLstNd< TVal >::Val.
{ PLstNd Nd=First(); while (Nd!=NULL){ if (Nd->GetVal()==Val){return Nd;} Nd=Nd->Next(); } return NULL; }
Definition at line 2203 of file ds.h.
Referenced by TLst< TKey >::Clr(), TLst< TKey >::DelFirst(), TLst< TKey >::First(), and TLst< TKey >::FirstVal().
Definition at line 2204 of file ds.h.
Referenced by TLst< TKey >::Clr(), TLst< TKey >::DelLast(), TLst< TKey >::Last(), and TLst< TKey >::LastVal().
Definition at line 2202 of file ds.h.
Referenced by TLst< TKey >::Clr(), TLst< TKey >::Empty(), TLst< TKey >::Len(), and TLst< TVal >::TLst().