SNAP Library 6.0, Developer Reference  2020-12-09 16:24:20
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
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 2702 of file ds.h.

Member Typedef Documentation

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

Definition at line 2704 of file ds.h.

Constructor & Destructor Documentation

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

Definition at line 2710 of file ds.h.

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

Definition at line 2712 of file ds.h.

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

Definition at line 2749 of file ds.h.

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

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

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

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

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

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

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

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

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

Here is the call graph for this function:

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

Definition at line 2766 of file ds.h.

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

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

Definition at line 2782 of file ds.h.

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

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

Here is the call graph for this function:

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

Definition at line 2718 of file ds.h.

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

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

Here is the caller graph for this function:

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

Definition at line 2842 of file ds.h.

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

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

Here is the caller graph for this function:

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

Definition at line 2848 of file ds.h.

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

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

Definition at line 2739 of file ds.h.

2739 { PLstNd DelNd = FirstNd; Del(DelNd); }
PLstNd FirstNd
Definition: ds.h:2707
TLstNd< TVal > * PLstNd
Definition: ds.h:2704
void Del(const TVal &Val)
Definition: ds.h:2842
template<class TVal>
void TLst< TVal >::DelLast ( )
inline

Definition at line 2740 of file ds.h.

2740 { PLstNd DelNd = LastNd; Del(DelNd); }
PLstNd LastNd
Definition: ds.h:2708
TLstNd< TVal > * PLstNd
Definition: ds.h:2704
void Del(const TVal &Val)
Definition: ds.h:2842
template<class TVal>
bool TLst< TVal >::Empty ( ) const
inline

Definition at line 2723 of file ds.h.

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

Definition at line 2725 of file ds.h.

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

Definition at line 2727 of file ds.h.

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

Definition at line 2831 of file ds.h.

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

2831  {
2832  if (Nd==NULL){return AddFront(Val);}
2833  else if (Nd->NextNd==NULL){return AddBack(Val);}
2834  else {
2835  PLstNd NewNd=new TLstNd<TVal>(Nd, Nd->NextNd, Val);
2836  Nd->NextNd=NewNd; NewNd->NextNd->PrevNd=Nd;
2837  Nds++; return Nd;
2838  }
2839 }
int Nds
Definition: ds.h:2706
TLstNd * NextNd
Definition: ds.h:2681
Definition: ds.h:2678
PLstNd AddFront(const TVal &Val)
Definition: ds.h:2766
TLstNd< TVal > * PLstNd
Definition: ds.h:2704
PLstNd AddBack(const TVal &Val)
Definition: ds.h:2774
TLstNd * PrevNd
Definition: ds.h:2680
template<class TVal>
PLstNd TLst< TVal >::Last ( ) const
inline

Definition at line 2726 of file ds.h.

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

Definition at line 2728 of file ds.h.

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

Definition at line 2724 of file ds.h.

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

Definition at line 2817 of file ds.h.

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

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

Definition at line 2803 of file ds.h.

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

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

Definition at line 2757 of file ds.h.

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

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

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

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

Here is the call graph for this function:

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

Definition at line 2858 of file ds.h.

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

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

Here is the call graph for this function:

Friends And Related Function Documentation

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

Definition at line 2745 of file ds.h.

Member Data Documentation

template<class TVal>
PLstNd TLst< TVal >::FirstNd
private

Definition at line 2707 of file ds.h.

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

template<class TVal>
PLstNd TLst< TVal >::LastNd
private

Definition at line 2708 of file ds.h.

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

template<class TVal>
int TLst< TVal >::Nds
private

Definition at line 2706 of file ds.h.

Referenced by TLst< TKey >::Len(), and TLst< TVal >::TLst().


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