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
TQQueue< TVal > Class Template Reference

#include <ds.h>

Collaboration diagram for TQQueue< TVal >:

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

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

Definition at line 2619 of file ds.h.

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

Definition at line 2622 of file ds.h.

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

Member Function Documentation

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

Definition at line 2635 of file ds.h.

Referenced by TLocClust::ApproxPageRank(), TSnap::GetBetweennessCentr(), TSnap::GetWeightedBetweennessCentr(), and TQQueue< TInt >::Shuffle().

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

Here is the caller graph for this function:

template<class TVal>
bool TQQueue< TVal >::Empty ( ) const
inline

Definition at line 2646 of file ds.h.

Referenced by TLocClust::ApproxPageRank(), TSnap::GetBetweennessCentr(), TSnap::GetWeightedBetweennessCentr(), TSnap::GlobalRelabel(), TSnap::IntFlowBiDBFS(), TSnap::TPRManager::PopActive(), and TQQueue< TInt >::Shuffle().

2646 {return First==Last;}
TInt Last
Definition: ds.h:2613
TInt First
Definition: ds.h:2613

Here is the caller graph for this function:

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

Definition at line 2636 of file ds.h.

2636  {
2637  MxLast=_MxLast; MxLen=_MxLen; First=0; Last=0; ValV.Clr();}
TInt Last
Definition: ds.h:2613
TVec< TVal > ValV
Definition: ds.h:2614
TInt First
Definition: ds.h:2613
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:2612
TInt MxLast
Definition: ds.h:2612
template<class TVal>
void TQQueue< TVal >::GetSubValV ( const int &  _BValN,
const int &  _EValN,
TVec< TVal > &  SubValV 
) const
inline

Definition at line 2638 of file ds.h.

2638  {
2639  int BValN=TInt::GetMx(0, _BValN);
2640  int EValN=TInt::GetMn(Len()-1, _EValN);
2641  SubValV.Gen(EValN-BValN+1);
2642  for (int ValN=BValN; ValN<=EValN; ValN++){
2643  SubValV[ValN-BValN]=ValV[Last+ValN];}
2644  }
TInt Last
Definition: ds.h:2613
static int GetMx(const int &Int1, const int &Int2)
Definition: dt.h:1185
TVec< TVal > ValV
Definition: ds.h:2614
static int GetMn(const int &Int1, const int &Int2)
Definition: dt.h:1183
int Len() const
Definition: ds.h:2647
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 2647 of file ds.h.

Referenced by TLocClust::ApproxPageRank(), TQQueue< TInt >::GetSubValV(), TQQueue< TInt >::operator[](), TQQueue< TInt >::Push(), and TQQueue< TInt >::Shuffle().

2647 {return First-Last;}
TInt Last
Definition: ds.h:2613
TInt First
Definition: ds.h:2613

Here is the caller graph for this function:

template<class TVal>
TQQueue& TQQueue< TVal >::operator= ( const TQQueue< TVal > &  Queue)
inline

Definition at line 2628 of file ds.h.

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

Definition at line 2632 of file ds.h.

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

Definition at line 2650 of file ds.h.

Referenced by TLocClust::ApproxPageRank(), TSnap::GetBetweennessCentr(), TSnap::GetWeightedBetweennessCentr(), TSnap::GlobalRelabel(), TSnap::IntFlowBiDBFS(), TSnap::TPRManager::PopActive(), TQQueue< TInt >::Push(), and TQQueue< TInt >::Shuffle().

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

Here is the caller graph for this function:

template<class TVal>
void TQQueue< TVal >::Push ( const TVal &  Val)
inline

Definition at line 2653 of file ds.h.

Referenced by TLocClust::ApproxPageRank(), TSnap::GetBetweennessCentr(), TSnap::GetWeightedBetweennessCentr(), TSnap::GlobalRelabel(), TSnap::IntFlowBiDBFS(), TSnap::TPRManager::PushActive(), and TQQueue< TInt >::Shuffle().

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

Here is the caller graph for this function:

template<class TVal>
void TQQueue< TVal >::Save ( TSOut SOut) const
inline

Definition at line 2624 of file ds.h.

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

Definition at line 2658 of file ds.h.

2658  {
2659  TVec<TVal> ValV(Len(), 0); while (!Empty()){ValV.Add(Top()); Pop();}
2660  ValV.Shuffle(Rnd); Clr();
2661  for (int ValN=0; ValN<ValV.Len(); ValN++){Push(ValV[ValN]);}}
bool Empty() const
Definition: ds.h:2646
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TVec< TVal > ValV
Definition: ds.h:2614
void Pop()
Definition: ds.h:2650
int Len() const
Definition: ds.h:2647
const TVal & Top() const
Definition: ds.h:2648
void Shuffle(TRnd &Rnd)
Randomly shuffles the elements of the vector.
Definition: ds.h:1335
void Push(const TVal &Val)
Definition: ds.h:2653
void Clr(const bool &DoDel=true)
Definition: ds.h:2635
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 2648 of file ds.h.

Referenced by TLocClust::ApproxPageRank(), TSnap::GetBetweennessCentr(), TSnap::GetWeightedBetweennessCentr(), TSnap::GlobalRelabel(), TSnap::IntFlowBiDBFS(), TSnap::TPRManager::PopActive(), and TQQueue< TInt >::Shuffle().

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

Here is the caller graph for this function:

Member Data Documentation

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

Definition at line 2613 of file ds.h.

Referenced by TQQueue< TInt >::operator=().

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

Definition at line 2612 of file ds.h.

Referenced by TQQueue< TInt >::operator=().

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

Definition at line 2612 of file ds.h.

Referenced by TQQueue< TInt >::operator=().

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

Definition at line 2614 of file ds.h.

Referenced by TQQueue< TInt >::operator=(), and TQQueue< TInt >::Shuffle().


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