SNAP Library 3.0, User Reference  2016-07-20 17:56:49
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
TQQueue< TVal > Class Template Reference

#include <ds.h>

Public Member Functions

 TQQueue (const int &_MxLast=64, const int &_MxLen=-1)
 
 TQQueue (const TQQueue &Queue)
 
 TQQueue (TSIn &SIn)
 
void Save (TSOut &SOut) const
 
TQQueueoperator= (const TQQueue &Queue)
 
const TVal & operator[] (const int &ValN) const
 
void Clr (const bool &DoDel=true)
 
void Gen (const int &_MxLast=64, const int &_MxLen=-1)
 
void GetSubValV (const int &_BValN, const int &_EValN, TVec< TVal > &SubValV) const
 
bool Empty () const
 
int Len () const
 
const TVal & Top () const
 
void Pop ()
 
void Push (const TVal &Val)
 
void Shuffle (TRnd &Rnd)
 

Private Attributes

TInt MxLast
 
TInt MxLen
 
TInt First
 
TInt Last
 
TVec< TVal > ValV
 

Detailed Description

template<class TVal>
class TQQueue< TVal >

Definition at line 2544 of file ds.h.

Constructor & Destructor Documentation

template<class TVal>
TQQueue< TVal >::TQQueue ( const int &  _MxLast = 64,
const int &  _MxLen = -1 
)
inline

Definition at line 2550 of file ds.h.

2550  :
2551  MxLast(_MxLast), MxLen(_MxLen), First(0), Last(0), ValV(){
2552  Assert(int(MxLast)>0); Assert((MxLen==-1)||(int(MxLen)>0));}
TInt Last
Definition: ds.h:2547
TVec< TVal > ValV
Definition: ds.h:2548
TInt First
Definition: ds.h:2547
TInt MxLen
Definition: ds.h:2546
#define Assert(Cond)
Definition: bd.h:251
TInt MxLast
Definition: ds.h:2546
template<class TVal>
TQQueue< TVal >::TQQueue ( const TQQueue< TVal > &  Queue)
inline

Definition at line 2553 of file ds.h.

2553  :
2554  MxLast(Queue.MxLast), MxLen(Queue.MxLen),
2555  First(Queue.First), Last(Queue.Last), ValV(Queue.ValV){}
TInt Last
Definition: ds.h:2547
TVec< TVal > ValV
Definition: ds.h:2548
TInt First
Definition: ds.h:2547
TInt MxLen
Definition: ds.h:2546
TInt MxLast
Definition: ds.h:2546
template<class TVal>
TQQueue< TVal >::TQQueue ( TSIn SIn)
inlineexplicit

Definition at line 2556 of file ds.h.

2556  :
2557  MxLast(SIn), MxLen(SIn), First(SIn), Last(SIn), ValV(SIn){}
TInt Last
Definition: ds.h:2547
TVec< TVal > ValV
Definition: ds.h:2548
TInt First
Definition: ds.h:2547
TInt MxLen
Definition: ds.h:2546
TInt MxLast
Definition: ds.h:2546

Member Function Documentation

template<class TVal>
void TQQueue< TVal >::Clr ( const bool &  DoDel = true)
inline

Definition at line 2569 of file ds.h.

2569 {ValV.Clr(DoDel); First=Last=0;}
TInt Last
Definition: ds.h:2547
TVec< TVal > ValV
Definition: ds.h:2548
TInt First
Definition: ds.h:2547
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:971
template<class TVal>
bool TQQueue< TVal >::Empty ( ) const
inline

Definition at line 2580 of file ds.h.

2580 {return First==Last;}
TInt Last
Definition: ds.h:2547
TInt First
Definition: ds.h:2547
template<class TVal>
void TQQueue< TVal >::Gen ( const int &  _MxLast = 64,
const int &  _MxLen = -1 
)
inline

Definition at line 2570 of file ds.h.

2570  {
2571  MxLast=_MxLast; MxLen=_MxLen; First=0; Last=0; ValV.Clr();}
TInt Last
Definition: ds.h:2547
TVec< TVal > ValV
Definition: ds.h:2548
TInt First
Definition: ds.h:2547
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:971
TInt MxLen
Definition: ds.h:2546
TInt MxLast
Definition: ds.h:2546
template<class TVal>
void TQQueue< TVal >::GetSubValV ( const int &  _BValN,
const int &  _EValN,
TVec< TVal > &  SubValV 
) const
inline

Definition at line 2572 of file ds.h.

2572  {
2573  int BValN=TInt::GetMx(0, _BValN);
2574  int EValN=TInt::GetMn(Len()-1, _EValN);
2575  SubValV.Gen(EValN-BValN+1);
2576  for (int ValN=BValN; ValN<=EValN; ValN++){
2577  SubValV[ValN-BValN]=ValV[Last+ValN];}
2578  }
TInt Last
Definition: ds.h:2547
static int GetMx(const int &Int1, const int &Int2)
Definition: dt.h:1092
TVec< TVal > ValV
Definition: ds.h:2548
static int GetMn(const int &Int1, const int &Int2)
Definition: dt.h:1090
int Len() const
Definition: ds.h:2581
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:495
template<class TVal>
int TQQueue< TVal >::Len ( ) const
inline

Definition at line 2581 of file ds.h.

2581 {return First-Last;}
TInt Last
Definition: ds.h:2547
TInt First
Definition: ds.h:2547
template<class TVal>
TQQueue& TQQueue< TVal >::operator= ( const TQQueue< TVal > &  Queue)
inline

Definition at line 2562 of file ds.h.

2562  {
2563  if (this!=&Queue){MxLast=Queue.MxLast; MxLen=Queue.MxLen;
2564  First=Queue.First; Last=Queue.Last; ValV=Queue.ValV;}
2565  return *this;}
TInt Last
Definition: ds.h:2547
TVec< TVal > ValV
Definition: ds.h:2548
TInt First
Definition: ds.h:2547
TInt MxLen
Definition: ds.h:2546
TInt MxLast
Definition: ds.h:2546
template<class TVal>
const TVal& TQQueue< TVal >::operator[] ( const int &  ValN) const
inline

Definition at line 2566 of file ds.h.

2566  {Assert((0<=ValN)&&(ValN<Len()));
2567  return ValV[Last+ValN];}
TInt Last
Definition: ds.h:2547
TVec< TVal > ValV
Definition: ds.h:2548
#define Assert(Cond)
Definition: bd.h:251
int Len() const
Definition: ds.h:2581
template<class TVal>
void TQQueue< TVal >::Pop ( )
inline

Definition at line 2584 of file ds.h.

2584  {
2585  IAssert(First!=Last); Last++;
2586  if (First==Last){ValV.Clr(); First=Last=0;}}
#define IAssert(Cond)
Definition: bd.h:262
TInt Last
Definition: ds.h:2547
TVec< TVal > ValV
Definition: ds.h:2548
TInt First
Definition: ds.h:2547
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:971
template<class TVal>
void TQQueue< TVal >::Push ( const TVal &  Val)
inline

Definition at line 2587 of file ds.h.

2587  {
2588  if (Last>MxLast){ValV.Del(0, Last-1); First-=Last; Last=0;}
2589  if ((MxLen!=-1)&&(MxLen==Len())){Pop();}
2590  First++; ValV.Add(Val);}
TInt Last
Definition: ds.h:2547
void Del(const TSizeTy &ValN)
Removes the element at position ValN.
Definition: ds.h:1130
TVec< TVal > ValV
Definition: ds.h:2548
TInt First
Definition: ds.h:2547
void Pop()
Definition: ds.h:2584
TInt MxLen
Definition: ds.h:2546
int Len() const
Definition: ds.h:2581
TInt MxLast
Definition: ds.h:2546
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:574
template<class TVal>
void TQQueue< TVal >::Save ( TSOut SOut) const
inline

Definition at line 2558 of file ds.h.

2558  {
2559  MxLast.Save(SOut); MxLen.Save(SOut);
2560  First.Save(SOut); Last.Save(SOut); ValV.Save(SOut);}
TInt Last
Definition: ds.h:2547
void Save(TSOut &SOut) const
Definition: dt.h:1060
TVec< TVal > ValV
Definition: ds.h:2548
TInt First
Definition: ds.h:2547
void Save(TSOut &SOut) const
Definition: ds.h:903
TInt MxLen
Definition: ds.h:2546
TInt MxLast
Definition: ds.h:2546
template<class TVal>
void TQQueue< TVal >::Shuffle ( TRnd Rnd)
inline

Definition at line 2592 of file ds.h.

2592  {
2593  TVec<TVal> ValV(Len(), 0); while (!Empty()){ValV.Add(Top()); Pop();}
2594  ValV.Shuffle(Rnd); Clr();
2595  for (int ValN=0; ValN<ValV.Len(); ValN++){Push(ValV[ValN]);}}
bool Empty() const
Definition: ds.h:2580
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:547
TVec< TVal > ValV
Definition: ds.h:2548
void Pop()
Definition: ds.h:2584
int Len() const
Definition: ds.h:2581
const TVal & Top() const
Definition: ds.h:2582
void Shuffle(TRnd &Rnd)
Randomly shuffles the elements of the vector.
Definition: ds.h:1271
void Push(const TVal &Val)
Definition: ds.h:2587
void Clr(const bool &DoDel=true)
Definition: ds.h:2569
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:574
template<class TVal>
const TVal& TQQueue< TVal >::Top ( ) const
inline

Definition at line 2582 of file ds.h.

2582  {
2583  Assert(First!=Last); return ValV[Last];}
TInt Last
Definition: ds.h:2547
TVec< TVal > ValV
Definition: ds.h:2548
TInt First
Definition: ds.h:2547
#define Assert(Cond)
Definition: bd.h:251

Member Data Documentation

template<class TVal>
TInt TQQueue< TVal >::First
private

Definition at line 2547 of file ds.h.

template<class TVal>
TInt TQQueue< TVal >::Last
private

Definition at line 2547 of file ds.h.

template<class TVal>
TInt TQQueue< TVal >::MxLast
private

Definition at line 2546 of file ds.h.

template<class TVal>
TInt TQQueue< TVal >::MxLen
private

Definition at line 2546 of file ds.h.

template<class TVal>
TVec<TVal> TQQueue< TVal >::ValV
private

Definition at line 2548 of file ds.h.


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