SNAP Library 4.0, Developer Reference  2017-07-27 13:18:06
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 2701 of file ds.h.

Member Typedef Documentation

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

Definition at line 2703 of file ds.h.

Constructor & Destructor Documentation

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

Definition at line 2709 of file ds.h.

2709 : Nds(0), FirstNd(NULL), LastNd(NULL){}
int Nds
Definition: ds.h:2705
PLstNd LastNd
Definition: ds.h:2707
PLstNd FirstNd
Definition: ds.h:2706
template<class TVal>
TLst< TVal >::TLst ( const TLst< TVal > &  )
template<class TVal>
TLst< TVal >::~TLst ( )
inline

Definition at line 2711 of file ds.h.

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

Definition at line 2748 of file ds.h.

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

2748  :
2749  Nds(0), FirstNd(NULL), LastNd(NULL){
2750  int CheckNds=0; SIn.Load(CheckNds);
2751  for (int NdN=0; NdN<CheckNds; NdN++){AddBack(TVal(SIn));}
2752  Assert(Nds==CheckNds);
2753 }
int Nds
Definition: ds.h:2705
PLstNd LastNd
Definition: ds.h:2707
PLstNd FirstNd
Definition: ds.h:2706
void Load(bool &Bool)
Definition: fl.h:84
#define Assert(Cond)
Definition: bd.h:251
PLstNd AddBack(const TVal &Val)
Definition: ds.h:2773

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 2773 of file ds.h.

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

Referenced by TLst< TVal >::TLst().

2773  {
2774  PLstNd Nd=new TLstNd<TVal>(LastNd, NULL, Val);
2775  if (LastNd!=NULL){LastNd->NextNd=Nd; LastNd=Nd;}
2776  else {FirstNd=Nd; LastNd=Nd;}
2777  Nds++; return Nd;
2778 }
int Nds
Definition: ds.h:2705
TLstNd * NextNd
Definition: ds.h:2680
Definition: ds.h:2677
PLstNd LastNd
Definition: ds.h:2707
PLstNd FirstNd
Definition: ds.h:2706
TLstNd< TVal > * PLstNd
Definition: ds.h:2703

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 2794 of file ds.h.

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

2794  {
2795  PLstNd Nd=Last();
2796  while ((Nd!=NULL)&&((Asc&&(Val<Nd->Val))||(!Asc&&(Val>Nd->Val)))){
2797  Nd=Nd->Prev();}
2798  return Ins(Nd, Val);
2799 }
PLstNd Ins(const PLstNd &Nd, const TVal &Val)
Definition: ds.h:2830
TLstNd< TVal > * PLstNd
Definition: ds.h:2703
PLstNd Last() const
Definition: ds.h:2725

Here is the call graph for this function:

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

Definition at line 2765 of file ds.h.

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

2765  {
2766  PLstNd Nd=new TLstNd<TVal>(NULL, FirstNd, Val);
2767  if (FirstNd!=NULL){FirstNd->PrevNd=Nd; FirstNd=Nd;}
2768  else {FirstNd=Nd; LastNd=Nd;}
2769  Nds++; return Nd;
2770 }
int Nds
Definition: ds.h:2705
Definition: ds.h:2677
PLstNd LastNd
Definition: ds.h:2707
PLstNd FirstNd
Definition: ds.h:2706
TLstNd< TVal > * PLstNd
Definition: ds.h:2703
TLstNd * PrevNd
Definition: ds.h:2679
template<class TVal>
TLstNd< TVal > * TLst< TVal >::AddFrontSorted ( const TVal &  Val,
const bool &  Asc = true 
)

Definition at line 2781 of file ds.h.

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

2781  {
2782  PLstNd Nd=First();
2783  if (Nd==NULL){
2784  return Ins(Nd, Val);
2785  } else {
2786  while ((Nd!=NULL)&&((Asc&&(Val>Nd()))||(!Asc&&(Val<Nd())))){
2787  Nd=Nd->Next();}
2788  if (Nd==NULL){return Ins(Nd->Last(), Val);}
2789  else {return Ins(Nd->Prev(), Val);}
2790  }
2791 }
PLstNd Ins(const PLstNd &Nd, const TVal &Val)
Definition: ds.h:2830
TLstNd< TVal > * PLstNd
Definition: ds.h:2703
PLstNd First() const
Definition: ds.h:2724

Here is the call graph for this function:

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

Definition at line 2717 of file ds.h.

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

2717  {
2718  PLstNd Nd=FirstNd;
2719  while (Nd!=NULL){PLstNd NextNd=Nd->NextNd; delete Nd; Nd=NextNd;}
2720  Nds=0; FirstNd=NULL; LastNd=NULL;}
int Nds
Definition: ds.h:2705
PLstNd LastNd
Definition: ds.h:2707
PLstNd FirstNd
Definition: ds.h:2706
TLstNd< TVal > * PLstNd
Definition: ds.h:2703

Here is the caller graph for this function:

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

Definition at line 2841 of file ds.h.

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

2841  {
2842  PLstNd Nd=SearchForw(Val);
2843  if (Nd!=NULL){Del(Nd);}
2844 }
TLstNd< TVal > * PLstNd
Definition: ds.h:2703
void Del(const TVal &Val)
Definition: ds.h:2841
PLstNd SearchForw(const TVal &Val)
Definition: ds.h:2857

Here is the caller graph for this function:

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

Definition at line 2847 of file ds.h.

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

2847  {
2848  Assert(Nd!=NULL);
2849  if (Nd->PrevNd==NULL){FirstNd=Nd->NextNd;}
2850  else {Nd->PrevNd->NextNd=Nd->NextNd;}
2851  if (Nd->NextNd==NULL){LastNd=Nd->PrevNd;}
2852  else {Nd->NextNd->PrevNd=Nd->PrevNd;}
2853  Nds--; delete Nd;
2854 }
int Nds
Definition: ds.h:2705
TLstNd * NextNd
Definition: ds.h:2680
PLstNd LastNd
Definition: ds.h:2707
PLstNd FirstNd
Definition: ds.h:2706
#define Assert(Cond)
Definition: bd.h:251
TLstNd * PrevNd
Definition: ds.h:2679
template<class TVal>
void TLst< TVal >::DelFirst ( )
inline

Definition at line 2738 of file ds.h.

2738 { PLstNd DelNd = FirstNd; Del(DelNd); }
PLstNd FirstNd
Definition: ds.h:2706
TLstNd< TVal > * PLstNd
Definition: ds.h:2703
void Del(const TVal &Val)
Definition: ds.h:2841
template<class TVal>
void TLst< TVal >::DelLast ( )
inline

Definition at line 2739 of file ds.h.

2739 { PLstNd DelNd = LastNd; Del(DelNd); }
PLstNd LastNd
Definition: ds.h:2707
TLstNd< TVal > * PLstNd
Definition: ds.h:2703
void Del(const TVal &Val)
Definition: ds.h:2841
template<class TVal>
bool TLst< TVal >::Empty ( ) const
inline

Definition at line 2722 of file ds.h.

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

Definition at line 2724 of file ds.h.

2724 {return FirstNd;}
PLstNd FirstNd
Definition: ds.h:2706
template<class TVal>
TVal& TLst< TVal >::FirstVal ( ) const
inline

Definition at line 2726 of file ds.h.

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

Definition at line 2830 of file ds.h.

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

2830  {
2831  if (Nd==NULL){return AddFront(Val);}
2832  else if (Nd->NextNd==NULL){return AddBack(Val);}
2833  else {
2834  PLstNd NewNd=new TLstNd<TVal>(Nd, Nd->NextNd, Val);
2835  Nd->NextNd=NewNd; NewNd->NextNd->PrevNd=Nd;
2836  Nds++; return Nd;
2837  }
2838 }
int Nds
Definition: ds.h:2705
TLstNd * NextNd
Definition: ds.h:2680
Definition: ds.h:2677
PLstNd AddFront(const TVal &Val)
Definition: ds.h:2765
TLstNd< TVal > * PLstNd
Definition: ds.h:2703
PLstNd AddBack(const TVal &Val)
Definition: ds.h:2773
TLstNd * PrevNd
Definition: ds.h:2679
template<class TVal>
PLstNd TLst< TVal >::Last ( ) const
inline

Definition at line 2725 of file ds.h.

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

Definition at line 2727 of file ds.h.

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

Definition at line 2723 of file ds.h.

2723 {return Nds;}
int Nds
Definition: ds.h:2705
template<class TVal>
TLst& TLst< TVal >::operator= ( const TLst< TVal > &  )
template<class TVal >
void TLst< TVal >::PutBack ( const PLstNd Nd)

Definition at line 2816 of file ds.h.

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

2816  {
2817  Assert(Nd!=NULL);
2818  // unchain
2819  if (Nd->PrevNd==NULL){FirstNd=Nd->NextNd;}
2820  else {Nd->PrevNd->NextNd=Nd->NextNd;}
2821  if (Nd->NextNd==NULL){LastNd=Nd->PrevNd;}
2822  else {Nd->NextNd->PrevNd=Nd->PrevNd;}
2823  // add to back
2824  Nd->PrevNd=LastNd; Nd->NextNd=NULL;
2825  if (LastNd!=NULL){LastNd->NextNd=Nd; LastNd=Nd;}
2826  else {FirstNd=Nd; LastNd=Nd;}
2827 }
TLstNd * NextNd
Definition: ds.h:2680
PLstNd LastNd
Definition: ds.h:2707
PLstNd FirstNd
Definition: ds.h:2706
#define Assert(Cond)
Definition: bd.h:251
TLstNd * PrevNd
Definition: ds.h:2679
template<class TVal >
void TLst< TVal >::PutFront ( const PLstNd Nd)

Definition at line 2802 of file ds.h.

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

2802  {
2803  Assert(Nd!=NULL);
2804  // unchain
2805  if (Nd->PrevNd==NULL){FirstNd=Nd->NextNd;}
2806  else {Nd->PrevNd->NextNd=Nd->NextNd;}
2807  if (Nd->NextNd==NULL){LastNd=Nd->PrevNd;}
2808  else {Nd->NextNd->PrevNd=Nd->PrevNd;}
2809  // add to front
2810  Nd->PrevNd=NULL; Nd->NextNd=FirstNd;
2811  if (FirstNd!=NULL){FirstNd->PrevNd=Nd; FirstNd=Nd;}
2812  else {FirstNd=Nd; LastNd=Nd;}
2813 }
TLstNd * NextNd
Definition: ds.h:2680
PLstNd LastNd
Definition: ds.h:2707
PLstNd FirstNd
Definition: ds.h:2706
#define Assert(Cond)
Definition: bd.h:251
TLstNd * PrevNd
Definition: ds.h:2679
template<class TVal >
void TLst< TVal >::Save ( TSOut SOut) const

Definition at line 2756 of file ds.h.

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

2756  {
2757  SOut.Save(Nds);
2758  PLstNd Nd=FirstNd; int CheckNds=0;
2759  while (Nd!=NULL){
2760  Nd->Val.Save(SOut); Nd=Nd->NextNd; CheckNds++;}
2761  IAssert(Nds==CheckNds);
2762 }
#define IAssert(Cond)
Definition: bd.h:262
int Nds
Definition: ds.h:2705
TVal Val
Definition: ds.h:2681
PLstNd FirstNd
Definition: ds.h:2706
TLstNd< TVal > * PLstNd
Definition: ds.h:2703
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 2867 of file ds.h.

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

2867  {
2868  PLstNd Nd=Last();
2869  while (Nd!=NULL){
2870  if (Nd->GetVal()==Val){return Nd;}
2871  Nd=Nd->Prev();
2872  }
2873  return NULL;
2874 }
TLstNd< TVal > * PLstNd
Definition: ds.h:2703
PLstNd Last() const
Definition: ds.h:2725

Here is the call graph for this function:

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

Definition at line 2857 of file ds.h.

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

2857  {
2858  PLstNd Nd=First();
2859  while (Nd!=NULL){
2860  if (Nd->GetVal()==Val){return Nd;}
2861  Nd=Nd->Next();
2862  }
2863  return NULL;
2864 }
TLstNd< TVal > * PLstNd
Definition: ds.h:2703
PLstNd First() const
Definition: ds.h:2724

Here is the call graph for this function:

Friends And Related Function Documentation

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

Definition at line 2744 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: