SNAP Library , Developer Reference  2013-01-07 14:03:36
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TLst< TVal > Class Template Reference

#include <ds.h>

List of all members.

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


Member Typedef Documentation

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

Definition at line 2200 of file ds.h.


Constructor & Destructor Documentation

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

Definition at line 2206 of file ds.h.

: Nds(0), FirstNd(NULL), LastNd(NULL){}
template<class TVal>
TLst< TVal >::TLst ( const TLst< TVal > &  )
template<class TVal>
TLst< TVal >::~TLst ( ) [inline]

Definition at line 2208 of file ds.h.

{Clr();}
template<class TVal >
TLst< TVal >::TLst ( TSIn SIn) [explicit]

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);
}

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 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;
}

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 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);
}

Here is the call graph for this function:

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

Definition at line 2262 of file ds.h.

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

                                                 {
  PLstNd Nd=new TLstNd<TVal>(NULL, FirstNd, Val);
  if (FirstNd!=NULL){FirstNd->PrevNd=Nd; FirstNd=Nd;}
  else {FirstNd=Nd; LastNd=Nd;}
  Nds++; return Nd;
}
template<class TVal>
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);}
  }
}

Here is the call graph for this function:

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

Definition at line 2214 of file ds.h.

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

            {
    PLstNd Nd=FirstNd;
    while (Nd!=NULL){PLstNd NextNd=Nd->NextNd; delete Nd; Nd=NextNd;}
    Nds=0; FirstNd=NULL; LastNd=NULL;}

Here is the caller graph for this function:

template<class TVal>
void TLst< TVal >::Del ( const TVal &  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);}
}

Here is the caller graph for this function:

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

Definition at line 2344 of file ds.h.

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

                                    {
  Assert(Nd!=NULL);
  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;}
  Nds--; delete Nd;
}
template<class TVal>
void TLst< TVal >::DelFirst ( ) [inline]

Definition at line 2235 of file ds.h.

{ PLstNd DelNd = FirstNd; Del(DelNd); }
template<class TVal>
void TLst< TVal >::DelLast ( ) [inline]

Definition at line 2236 of file ds.h.

{ PLstNd DelNd = LastNd; Del(DelNd); }
template<class TVal>
bool TLst< TVal >::Empty ( ) const [inline]

Definition at line 2219 of file ds.h.

{return Nds==0;}
template<class TVal>
PLstNd TLst< TVal >::First ( ) const [inline]

Definition at line 2221 of file ds.h.

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

{return FirstNd;}

Here is the caller graph for this function:

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

Definition at line 2223 of file ds.h.

{return FirstNd->GetVal();}
template<class TVal>
TLstNd< TVal > * TLst< TVal >::Ins ( const PLstNd Nd,
const TVal &  Val 
)

Definition at line 2327 of file ds.h.

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

                                                              {
  if (Nd==NULL){return AddFront(Val);}
  else if (Nd->NextNd==NULL){return AddBack(Val);}
  else {
    PLstNd NewNd=new TLstNd<TVal>(Nd, Nd->NextNd, Val);
    Nd->NextNd=NewNd; NewNd->NextNd->PrevNd=Nd;
    Nds++; return Nd;
  }
}
template<class TVal>
PLstNd TLst< TVal >::Last ( ) const [inline]

Definition at line 2222 of file ds.h.

{return LastNd;}
template<class TVal>
TVal& TLst< TVal >::LastVal ( ) const [inline]

Definition at line 2224 of file ds.h.

{return LastNd->GetVal();}
template<class TVal>
int TLst< TVal >::Len ( ) const [inline]

Definition at line 2220 of file ds.h.

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

{return Nds;}

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 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;}
}
template<class TVal >
void TLst< TVal >::PutFront ( const PLstNd 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;}
}
template<class TVal >
void TLst< TVal >::Save ( TSOut SOut) const

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);
}

Here is the call graph for this function:

template<class TVal>
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;
}

Here is the call graph for this function:

template<class TVal>
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;
}

Here is the call graph for this function:


Friends And Related Function Documentation

template<class TVal>
friend class TLstNd< TVal > [friend]

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