SNAP Library 2.3, Developer Reference  2014-06-16 11:58:46
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TLst< TVal > Class Template Reference

#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
 
TLstoperator= (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 >
 

Detailed Description

template<class TVal>
class TLst< TVal >

Definition at line 3579 of file ds.h.

Member Typedef Documentation

template<class TVal>
typedef TLstNd<TVal>* TLst< TVal >::PLstNd

Definition at line 3581 of file ds.h.

Constructor & Destructor Documentation

template<class TVal>
TLst< TVal >::TLst ( )
inline

Definition at line 3587 of file ds.h.

3587 : Nds(0), FirstNd(NULL), LastNd(NULL){}
int Nds
Definition: ds.h:3583
PLstNd LastNd
Definition: ds.h:3585
PLstNd FirstNd
Definition: ds.h:3584
template<class TVal>
TLst< TVal >::TLst ( const TLst< TVal > &  )
template<class TVal>
TLst< TVal >::~TLst ( )
inline

Definition at line 3589 of file ds.h.

3589 {Clr();}
void Clr()
Definition: ds.h:3595
template<class TVal >
TLst< TVal >::TLst ( TSIn SIn)
explicit

Definition at line 3626 of file ds.h.

References TLst< TVal >::AddBack(), Assert, TSIn::Load(), and TLst< TVal >::Nds.

3626  :
3627  Nds(0), FirstNd(NULL), LastNd(NULL){
3628  int CheckNds=0; SIn.Load(CheckNds);
3629  for (int NdN=0; NdN<CheckNds; NdN++){AddBack(TVal(SIn));}
3630  Assert(Nds==CheckNds);
3631 }
int Nds
Definition: ds.h:3583
PLstNd LastNd
Definition: ds.h:3585
PLstNd FirstNd
Definition: ds.h:3584
void Load(bool &Bool)
Definition: fl.h:84
#define Assert(Cond)
Definition: bd.h:251
PLstNd AddBack(const TVal &Val)
Definition: ds.h:3651

Here is the call graph for this function:

Member Function Documentation

template<class TVal>
TLstNd< TVal > * TLst< TVal >::AddBack ( const TVal &  Val)

Definition at line 3651 of file ds.h.

References TLstNd< TVal >::NextNd, and TLstNd< TVal >::Val.

Referenced by TExpVal::MkClone(), and TLst< TVal >::TLst().

3651  {
3652  PLstNd Nd=new TLstNd<TVal>(LastNd, NULL, Val);
3653  if (LastNd!=NULL){LastNd->NextNd=Nd; LastNd=Nd;}
3654  else {FirstNd=Nd; LastNd=Nd;}
3655  Nds++; return Nd;
3656 }
int Nds
Definition: ds.h:3583
TLstNd * NextNd
Definition: ds.h:3558
Definition: ds.h:3555
PLstNd LastNd
Definition: ds.h:3585
PLstNd FirstNd
Definition: ds.h:3584
TLstNd< TVal > * PLstNd
Definition: ds.h:3581

Here is the caller graph for this function:

template<class TVal>
TLstNd< TVal > * TLst< TVal >::AddBackSorted ( const TVal &  Val,
const bool &  Asc = true 
)

Definition at line 3672 of file ds.h.

References TLstNd< TVal >::Prev(), and TLstNd< TVal >::Val.

3672  {
3673  PLstNd Nd=Last();
3674  while ((Nd!=NULL)&&((Asc&&(Val<Nd->Val))||(!Asc&&(Val>Nd->Val)))){
3675  Nd=Nd->Prev();}
3676  return Ins(Nd, Val);
3677 }
PLstNd Ins(const PLstNd &Nd, const TVal &Val)
Definition: ds.h:3708
TLstNd< TVal > * PLstNd
Definition: ds.h:3581
PLstNd Last() const
Definition: ds.h:3603

Here is the call graph for this function:

template<class TVal>
TLstNd< TVal > * TLst< TVal >::AddFront ( const TVal &  Val)

Definition at line 3643 of file ds.h.

References TLstNd< TVal >::PrevNd, and TLstNd< TVal >::Val.

3643  {
3644  PLstNd Nd=new TLstNd<TVal>(NULL, FirstNd, Val);
3645  if (FirstNd!=NULL){FirstNd->PrevNd=Nd; FirstNd=Nd;}
3646  else {FirstNd=Nd; LastNd=Nd;}
3647  Nds++; return Nd;
3648 }
int Nds
Definition: ds.h:3583
Definition: ds.h:3555
PLstNd LastNd
Definition: ds.h:3585
PLstNd FirstNd
Definition: ds.h:3584
TLstNd< TVal > * PLstNd
Definition: ds.h:3581
TLstNd * PrevNd
Definition: ds.h:3557
template<class TVal>
TLstNd< TVal > * TLst< TVal >::AddFrontSorted ( const TVal &  Val,
const bool &  Asc = true 
)

Definition at line 3659 of file ds.h.

References TLstNd< TVal >::Next(), TLstNd< TVal >::Prev(), and TLstNd< TVal >::Val.

3659  {
3660  PLstNd Nd=First();
3661  if (Nd==NULL){
3662  return Ins(Nd, Val);
3663  } else {
3664  while ((Nd!=NULL)&&((Asc&&(Val>Nd()))||(!Asc&&(Val<Nd())))){
3665  Nd=Nd->Next();}
3666  if (Nd==NULL){return Ins(Nd->Last(), Val);}
3667  else {return Ins(Nd->Prev(), Val);}
3668  }
3669 }
PLstNd Ins(const PLstNd &Nd, const TVal &Val)
Definition: ds.h:3708
TLstNd< TVal > * PLstNd
Definition: ds.h:3581
PLstNd First() const
Definition: ds.h:3602

Here is the call graph for this function:

template<class TVal>
void TLst< TVal >::Clr ( )
inline

Definition at line 3595 of file ds.h.

Referenced by TLst< TKey >::~TLst().

3595  {
3596  PLstNd Nd=FirstNd;
3597  while (Nd!=NULL){PLstNd NextNd=Nd->NextNd; delete Nd; Nd=NextNd;}
3598  Nds=0; FirstNd=NULL; LastNd=NULL;}
int Nds
Definition: ds.h:3583
PLstNd LastNd
Definition: ds.h:3585
PLstNd FirstNd
Definition: ds.h:3584
TLstNd< TVal > * PLstNd
Definition: ds.h:3581

Here is the caller graph for this function:

template<class TVal>
void TLst< TVal >::Del ( const TVal &  Val)

Definition at line 3719 of file ds.h.

Referenced by TLst< TKey >::DelFirst(), and TLst< TKey >::DelLast().

3719  {
3720  PLstNd Nd=SearchForw(Val);
3721  if (Nd!=NULL){Del(Nd);}
3722 }
TLstNd< TVal > * PLstNd
Definition: ds.h:3581
void Del(const TVal &Val)
Definition: ds.h:3719
PLstNd SearchForw(const TVal &Val)
Definition: ds.h:3735

Here is the caller graph for this function:

template<class TVal>
void TLst< TVal >::Del ( const PLstNd Nd)

Definition at line 3725 of file ds.h.

References Assert, TLstNd< TVal >::NextNd, and TLstNd< TVal >::PrevNd.

3725  {
3726  Assert(Nd!=NULL);
3727  if (Nd->PrevNd==NULL){FirstNd=Nd->NextNd;}
3728  else {Nd->PrevNd->NextNd=Nd->NextNd;}
3729  if (Nd->NextNd==NULL){LastNd=Nd->PrevNd;}
3730  else {Nd->NextNd->PrevNd=Nd->PrevNd;}
3731  Nds--; delete Nd;
3732 }
int Nds
Definition: ds.h:3583
TLstNd * NextNd
Definition: ds.h:3558
PLstNd LastNd
Definition: ds.h:3585
PLstNd FirstNd
Definition: ds.h:3584
#define Assert(Cond)
Definition: bd.h:251
TLstNd * PrevNd
Definition: ds.h:3557
template<class TVal>
void TLst< TVal >::DelFirst ( )
inline

Definition at line 3616 of file ds.h.

3616 { PLstNd DelNd = FirstNd; Del(DelNd); }
PLstNd FirstNd
Definition: ds.h:3584
TLstNd< TVal > * PLstNd
Definition: ds.h:3581
void Del(const TVal &Val)
Definition: ds.h:3719
template<class TVal>
void TLst< TVal >::DelLast ( )
inline

Definition at line 3617 of file ds.h.

3617 { PLstNd DelNd = LastNd; Del(DelNd); }
PLstNd LastNd
Definition: ds.h:3585
TLstNd< TVal > * PLstNd
Definition: ds.h:3581
void Del(const TVal &Val)
Definition: ds.h:3719
template<class TVal>
bool TLst< TVal >::Empty ( ) const
inline

Definition at line 3600 of file ds.h.

3600 {return Nds==0;}
int Nds
Definition: ds.h:3583
template<class TVal>
PLstNd TLst< TVal >::First ( ) const
inline

Definition at line 3602 of file ds.h.

Referenced by TExpVal::MkClone(), TExpVal::operator<(), TExpVal::operator==(), and TExpVal::SaveTxt().

3602 {return FirstNd;}
PLstNd FirstNd
Definition: ds.h:3584

Here is the caller graph for this function:

template<class TVal>
TVal& TLst< TVal >::FirstVal ( ) const
inline

Definition at line 3604 of file ds.h.

3604 {return FirstNd->GetVal();}
PLstNd FirstNd
Definition: ds.h:3584
TVal & GetVal()
Definition: ds.h:3572
template<class TVal>
TLstNd< TVal > * TLst< TVal >::Ins ( const PLstNd Nd,
const TVal &  Val 
)

Definition at line 3708 of file ds.h.

References TLstNd< TVal >::NextNd, TLstNd< TVal >::PrevNd, and TLstNd< TVal >::Val.

3708  {
3709  if (Nd==NULL){return AddFront(Val);}
3710  else if (Nd->NextNd==NULL){return AddBack(Val);}
3711  else {
3712  PLstNd NewNd=new TLstNd<TVal>(Nd, Nd->NextNd, Val);
3713  Nd->NextNd=NewNd; NewNd->NextNd->PrevNd=Nd;
3714  Nds++; return Nd;
3715  }
3716 }
int Nds
Definition: ds.h:3583
TLstNd * NextNd
Definition: ds.h:3558
Definition: ds.h:3555
PLstNd AddFront(const TVal &Val)
Definition: ds.h:3643
TLstNd< TVal > * PLstNd
Definition: ds.h:3581
PLstNd AddBack(const TVal &Val)
Definition: ds.h:3651
TLstNd * PrevNd
Definition: ds.h:3557
template<class TVal>
PLstNd TLst< TVal >::Last ( ) const
inline

Definition at line 3603 of file ds.h.

3603 {return LastNd;}
PLstNd LastNd
Definition: ds.h:3585
template<class TVal>
TVal& TLst< TVal >::LastVal ( ) const
inline

Definition at line 3605 of file ds.h.

3605 {return LastNd->GetVal();}
PLstNd LastNd
Definition: ds.h:3585
TVal & GetVal()
Definition: ds.h:3572
template<class TVal>
int TLst< TVal >::Len ( ) const
inline

Definition at line 3601 of file ds.h.

Referenced by TExpVal::operator<(), TExpVal::operator==(), and TExpVal::SaveTxt().

3601 {return Nds;}
int Nds
Definition: ds.h:3583

Here is the caller graph for this function:

template<class TVal>
TLst& TLst< TVal >::operator= ( const TLst< TVal > &  )
template<class TVal >
void TLst< TVal >::PutBack ( const PLstNd Nd)

Definition at line 3694 of file ds.h.

References Assert, TLstNd< TVal >::NextNd, and TLstNd< TVal >::PrevNd.

3694  {
3695  Assert(Nd!=NULL);
3696  // unchain
3697  if (Nd->PrevNd==NULL){FirstNd=Nd->NextNd;}
3698  else {Nd->PrevNd->NextNd=Nd->NextNd;}
3699  if (Nd->NextNd==NULL){LastNd=Nd->PrevNd;}
3700  else {Nd->NextNd->PrevNd=Nd->PrevNd;}
3701  // add to back
3702  Nd->PrevNd=LastNd; Nd->NextNd=NULL;
3703  if (LastNd!=NULL){LastNd->NextNd=Nd; LastNd=Nd;}
3704  else {FirstNd=Nd; LastNd=Nd;}
3705 }
TLstNd * NextNd
Definition: ds.h:3558
PLstNd LastNd
Definition: ds.h:3585
PLstNd FirstNd
Definition: ds.h:3584
#define Assert(Cond)
Definition: bd.h:251
TLstNd * PrevNd
Definition: ds.h:3557
template<class TVal >
void TLst< TVal >::PutFront ( const PLstNd Nd)

Definition at line 3680 of file ds.h.

References Assert, TLstNd< TVal >::NextNd, and TLstNd< TVal >::PrevNd.

3680  {
3681  Assert(Nd!=NULL);
3682  // unchain
3683  if (Nd->PrevNd==NULL){FirstNd=Nd->NextNd;}
3684  else {Nd->PrevNd->NextNd=Nd->NextNd;}
3685  if (Nd->NextNd==NULL){LastNd=Nd->PrevNd;}
3686  else {Nd->NextNd->PrevNd=Nd->PrevNd;}
3687  // add to front
3688  Nd->PrevNd=NULL; Nd->NextNd=FirstNd;
3689  if (FirstNd!=NULL){FirstNd->PrevNd=Nd; FirstNd=Nd;}
3690  else {FirstNd=Nd; LastNd=Nd;}
3691 }
TLstNd * NextNd
Definition: ds.h:3558
PLstNd LastNd
Definition: ds.h:3585
PLstNd FirstNd
Definition: ds.h:3584
#define Assert(Cond)
Definition: bd.h:251
TLstNd * PrevNd
Definition: ds.h:3557
template<class TVal >
void TLst< TVal >::Save ( TSOut SOut) const

Definition at line 3634 of file ds.h.

References IAssert, TLstNd< TVal >::NextNd, TSOut::Save(), and TLstNd< TVal >::Val.

3634  {
3635  SOut.Save(Nds);
3636  PLstNd Nd=FirstNd; int CheckNds=0;
3637  while (Nd!=NULL){
3638  Nd->Val.Save(SOut); Nd=Nd->NextNd; CheckNds++;}
3639  IAssert(Nds==CheckNds);
3640 }
#define IAssert(Cond)
Definition: bd.h:262
int Nds
Definition: ds.h:3583
TVal Val
Definition: ds.h:3559
PLstNd FirstNd
Definition: ds.h:3584
TLstNd< TVal > * PLstNd
Definition: ds.h:3581
void Save(const bool &Bool)
Definition: fl.h:173

Here is the call graph for this function:

template<class TVal>
TLstNd< TVal > * TLst< TVal >::SearchBack ( const TVal &  Val)

Definition at line 3745 of file ds.h.

References TLstNd< TVal >::GetVal(), TLstNd< TVal >::Prev(), and TLstNd< TVal >::Val.

3745  {
3746  PLstNd Nd=Last();
3747  while (Nd!=NULL){
3748  if (Nd->GetVal()==Val){return Nd;}
3749  Nd=Nd->Prev();
3750  }
3751  return NULL;
3752 }
TLstNd< TVal > * PLstNd
Definition: ds.h:3581
PLstNd Last() const
Definition: ds.h:3603

Here is the call graph for this function:

template<class TVal>
TLstNd< TVal > * TLst< TVal >::SearchForw ( const TVal &  Val)

Definition at line 3735 of file ds.h.

References TLstNd< TVal >::GetVal(), TLstNd< TVal >::Next(), and TLstNd< TVal >::Val.

3735  {
3736  PLstNd Nd=First();
3737  while (Nd!=NULL){
3738  if (Nd->GetVal()==Val){return Nd;}
3739  Nd=Nd->Next();
3740  }
3741  return NULL;
3742 }
TLstNd< TVal > * PLstNd
Definition: ds.h:3581
PLstNd First() const
Definition: ds.h:3602

Here is the call graph for this function:

Friends And Related Function Documentation

template<class TVal>
friend class TLstNd< TVal >
friend

Definition at line 3622 of file ds.h.

Member Data Documentation

template<class TVal>
PLstNd TLst< TVal >::FirstNd
private
template<class TVal>
PLstNd TLst< TVal >::LastNd
private
template<class TVal>
int TLst< TVal >::Nds
private

The documentation for this class was generated from the following file: