SNAP Library 4.0, User 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
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 2609 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 2615 of file ds.h.

2615  :
2616  MxLast(_MxLast), MxLen(_MxLen), First(0), Last(0), ValV(){
2617  Assert(int(MxLast)>0); Assert((MxLen==-1)||(int(MxLen)>0));}
TInt Last
Definition: ds.h:2612
TVec< TVal > ValV
Definition: ds.h:2613
TInt First
Definition: ds.h:2612
TInt MxLen
Definition: ds.h:2611
#define Assert(Cond)
Definition: bd.h:251
TInt MxLast
Definition: ds.h:2611
template<class TVal>
TQQueue< TVal >::TQQueue ( const TQQueue< TVal > &  Queue)
inline

Definition at line 2618 of file ds.h.

2618  :
2619  MxLast(Queue.MxLast), MxLen(Queue.MxLen),
2620  First(Queue.First), Last(Queue.Last), ValV(Queue.ValV){}
TInt Last
Definition: ds.h:2612
TVec< TVal > ValV
Definition: ds.h:2613
TInt First
Definition: ds.h:2612
TInt MxLen
Definition: ds.h:2611
TInt MxLast
Definition: ds.h:2611
template<class TVal>
TQQueue< TVal >::TQQueue ( TSIn SIn)
inlineexplicit

Definition at line 2621 of file ds.h.

2621  :
2622  MxLast(SIn), MxLen(SIn), First(SIn), Last(SIn), ValV(SIn){}
TInt Last
Definition: ds.h:2612
TVec< TVal > ValV
Definition: ds.h:2613
TInt First
Definition: ds.h:2612
TInt MxLen
Definition: ds.h:2611
TInt MxLast
Definition: ds.h:2611

Member Function Documentation

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

Definition at line 2634 of file ds.h.

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

Definition at line 2645 of file ds.h.

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

Definition at line 2635 of file ds.h.

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

Definition at line 2637 of file ds.h.

2637  {
2638  int BValN=TInt::GetMx(0, _BValN);
2639  int EValN=TInt::GetMn(Len()-1, _EValN);
2640  SubValV.Gen(EValN-BValN+1);
2641  for (int ValN=BValN; ValN<=EValN; ValN++){
2642  SubValV[ValN-BValN]=ValV[Last+ValN];}
2643  }
TInt Last
Definition: ds.h:2612
static int GetMx(const int &Int1, const int &Int2)
Definition: dt.h:1182
TVec< TVal > ValV
Definition: ds.h:2613
static int GetMn(const int &Int1, const int &Int2)
Definition: dt.h:1180
int Len() const
Definition: ds.h:2646
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:523
template<class TVal>
int TQQueue< TVal >::Len ( ) const
inline

Definition at line 2646 of file ds.h.

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

Definition at line 2627 of file ds.h.

2627  {
2628  if (this!=&Queue){MxLast=Queue.MxLast; MxLen=Queue.MxLen;
2629  First=Queue.First; Last=Queue.Last; ValV=Queue.ValV;}
2630  return *this;}
TInt Last
Definition: ds.h:2612
TVec< TVal > ValV
Definition: ds.h:2613
TInt First
Definition: ds.h:2612
TInt MxLen
Definition: ds.h:2611
TInt MxLast
Definition: ds.h:2611
template<class TVal>
const TVal& TQQueue< TVal >::operator[] ( const int &  ValN) const
inline

Definition at line 2631 of file ds.h.

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

Definition at line 2649 of file ds.h.

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

Definition at line 2652 of file ds.h.

2652  {
2653  if (Last>MxLast){ValV.Del(0, Last-1); First-=Last; Last=0;}
2654  if ((MxLen!=-1)&&(MxLen==Len())){Pop();}
2655  First++; ValV.Add(Val);}
TInt Last
Definition: ds.h:2612
void Del(const TSizeTy &ValN)
Removes the element at position ValN.
Definition: ds.h:1189
TVec< TVal > ValV
Definition: ds.h:2613
TInt First
Definition: ds.h:2612
void Pop()
Definition: ds.h:2649
TInt MxLen
Definition: ds.h:2611
int Len() const
Definition: ds.h:2646
TInt MxLast
Definition: ds.h:2611
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
template<class TVal>
void TQQueue< TVal >::Save ( TSOut SOut) const
inline

Definition at line 2623 of file ds.h.

2623  {
2624  MxLast.Save(SOut); MxLen.Save(SOut);
2625  First.Save(SOut); Last.Save(SOut); ValV.Save(SOut);}
TInt Last
Definition: ds.h:2612
void Save(TSOut &SOut) const
Definition: dt.h:1150
TVec< TVal > ValV
Definition: ds.h:2613
TInt First
Definition: ds.h:2612
void Save(TSOut &SOut) const
Definition: ds.h:954
TInt MxLen
Definition: ds.h:2611
TInt MxLast
Definition: ds.h:2611
template<class TVal>
void TQQueue< TVal >::Shuffle ( TRnd Rnd)
inline

Definition at line 2657 of file ds.h.

2657  {
2658  TVec<TVal> ValV(Len(), 0); while (!Empty()){ValV.Add(Top()); Pop();}
2659  ValV.Shuffle(Rnd); Clr();
2660  for (int ValN=0; ValN<ValV.Len(); ValN++){Push(ValV[ValN]);}}
bool Empty() const
Definition: ds.h:2645
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TVec< TVal > ValV
Definition: ds.h:2613
void Pop()
Definition: ds.h:2649
int Len() const
Definition: ds.h:2646
const TVal & Top() const
Definition: ds.h:2647
void Shuffle(TRnd &Rnd)
Randomly shuffles the elements of the vector.
Definition: ds.h:1335
void Push(const TVal &Val)
Definition: ds.h:2652
void Clr(const bool &DoDel=true)
Definition: ds.h:2634
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
template<class TVal>
const TVal& TQQueue< TVal >::Top ( ) const
inline

Definition at line 2647 of file ds.h.

2647  {
2648  Assert(First!=Last); return ValV[Last];}
TInt Last
Definition: ds.h:2612
TVec< TVal > ValV
Definition: ds.h:2613
TInt First
Definition: ds.h:2612
#define Assert(Cond)
Definition: bd.h:251

Member Data Documentation

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

Definition at line 2612 of file ds.h.

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

Definition at line 2612 of file ds.h.

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

Definition at line 2611 of file ds.h.

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

Definition at line 2611 of file ds.h.

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

Definition at line 2613 of file ds.h.


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