SNAP Library 4.0, Developer 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
TPackVec< TVal > Class Template Reference

#include <shash.h>

Public Types

typedef TVal * TIter
 

Public Member Functions

 TPackVec ()
 
 TPackVec (const TPackVec &Vec)
 
 TPackVec (const int &_Vals)
 
 ~TPackVec ()
 
 TPackVec (TSIn &SIn)
 
void Load (TSIn &SIn)
 
void Save (TSOut &SOut) const
 
const TVal & operator[] (const int &ValN) const
 
TVal & operator[] (const int &ValN)
 
TPackVec< TVal > & operator= (const TPackVec< TVal > &Vec)
 
TVec< TVal > & operator= (const TVec< TVal > &Vec)
 
void Gen (const int &_Vals)
 
void Clr ()
 
bool Empty () const
 
int Len () const
 
const TVal & Last () const
 
TVal & Last ()
 
TIter BegI () const
 
TIter EndI () const
 
TIter GetI (const int &ValN) const
 
void Add (const TVal &Val)
 
void AddV (const TPackVec< TVal > &ValV)
 
void AddV (const TVec< TVal > &ValV)
 
void AddV (TSIn &FIn)
 
void Sort (const bool &Asc=true)
 

Private Member Functions

void ResizeDelta (const int &ValsToAdd=1)
 

Private Attributes

int Vals
 
TVal * ValT
 

Detailed Description

template<class TVal>
class TPackVec< TVal >

Definition at line 1393 of file shash.h.

Member Typedef Documentation

template<class TVal>
typedef TVal* TPackVec< TVal >::TIter

Definition at line 1395 of file shash.h.

Constructor & Destructor Documentation

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

Definition at line 1401 of file shash.h.

1401 : Vals(0), ValT(NULL) { }
int Vals
Definition: shash.h:1397
TVal * ValT
Definition: shash.h:1398
template<class TVal>
TPackVec< TVal >::TPackVec ( const TPackVec< TVal > &  Vec)
inline

Definition at line 1402 of file shash.h.

References TPackVec< TVal >::Gen(), TPackVec< TVal >::Len(), TPackVec< TVal >::Vals, and TPackVec< TVal >::ValT.

1402  : Vals(0), ValT(NULL) {
1403  Gen(Vec.Len());
1404  memcpy(ValT, Vec.ValT, sizeof(TVal)*Vals);
1405  }
int Len() const
Definition: shash.h:1426
int Vals
Definition: shash.h:1397
void Gen(const int &_Vals)
Definition: shash.h:1420
TVal * ValT
Definition: shash.h:1398

Here is the call graph for this function:

template<class TVal>
TPackVec< TVal >::TPackVec ( const int &  _Vals)
inlineexplicit

Definition at line 1406 of file shash.h.

References TPackVec< TVal >::Vals, and TPackVec< TVal >::ValT.

1406  : Vals(_Vals) {
1407  if (Vals==0) { ValT=NULL; } else { ValT = (TVal *) realloc(ValT, sizeof(TVal)*Vals); } }
int Vals
Definition: shash.h:1397
TVal * ValT
Definition: shash.h:1398
template<class TVal>
TPackVec< TVal >::~TPackVec ( )
inline

Definition at line 1408 of file shash.h.

References TPackVec< TVal >::ValT.

1408 { if (ValT != NULL) { free(ValT); } }
TVal * ValT
Definition: shash.h:1398
template<class TVal>
TPackVec< TVal >::TPackVec ( TSIn SIn)
inlineexplicit

Definition at line 1409 of file shash.h.

References TPackVec< TVal >::Load().

1409 : Vals(0), ValT(NULL) { Load(SIn); }
int Vals
Definition: shash.h:1397
void Load(TSIn &SIn)
Definition: shash.h:1457
TVal * ValT
Definition: shash.h:1398

Here is the call graph for this function:

Member Function Documentation

template<class TVal>
void TPackVec< TVal >::Add ( const TVal &  Val)
inline

Definition at line 1434 of file shash.h.

References TPackVec< TVal >::ResizeDelta(), TPackVec< TVal >::Vals, and TPackVec< TVal >::ValT.

1434 { ResizeDelta(1); ValT[Vals-1]=Val; }
int Vals
Definition: shash.h:1397
void ResizeDelta(const int &ValsToAdd=1)
Definition: shash.h:1449
TVal * ValT
Definition: shash.h:1398

Here is the call graph for this function:

template<class TVal>
void TPackVec< TVal >::AddV ( const TPackVec< TVal > &  ValV)
inline

Definition at line 1435 of file shash.h.

References TPackVec< TVal >::BegI(), TPackVec< TVal >::Len(), TPackVec< TVal >::ResizeDelta(), TPackVec< TVal >::Vals, and TPackVec< TVal >::ValT.

1435  { ResizeDelta(ValV.Len());
1436  memcpy(ValT+Vals-ValV.Len(), ValV.BegI(), sizeof(TVal)*ValV.Len()); }
TIter BegI() const
Definition: shash.h:1430
int Len() const
Definition: shash.h:1426
int Vals
Definition: shash.h:1397
void ResizeDelta(const int &ValsToAdd=1)
Definition: shash.h:1449
TVal * ValT
Definition: shash.h:1398

Here is the call graph for this function:

template<class TVal>
void TPackVec< TVal >::AddV ( const TVec< TVal > &  ValV)
inline

Definition at line 1437 of file shash.h.

References TVec< TVal, TSizeTy >::BegI(), TVec< TVal, TSizeTy >::Len(), TPackVec< TVal >::ResizeDelta(), TPackVec< TVal >::Vals, and TPackVec< TVal >::ValT.

1437  { ResizeDelta(ValV.Len());
1438  memcpy(ValT+Vals-ValV.Len(), ValV.BegI(), sizeof(TVal)*ValV.Len()); }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
int Vals
Definition: shash.h:1397
void ResizeDelta(const int &ValsToAdd=1)
Definition: shash.h:1449
TIter BegI() const
Returns an iterator pointing to the first element in the vector.
Definition: ds.h:593
TVal * ValT
Definition: shash.h:1398

Here is the call graph for this function:

template<class TVal>
void TPackVec< TVal >::AddV ( TSIn FIn)
inline

Definition at line 1439 of file shash.h.

References TSIn::Load(), TSIn::LoadBf(), TPackVec< TVal >::ResizeDelta(), TPackVec< TVal >::Vals, and TPackVec< TVal >::ValT.

1439  { int NVals; FIn.Load(NVals);
1440  ResizeDelta(NVals); FIn.LoadBf(ValT+Vals-NVals, sizeof(TVal)*NVals); }
void Load(bool &Bool)
Definition: fl.h:84
int Vals
Definition: shash.h:1397
void ResizeDelta(const int &ValsToAdd=1)
Definition: shash.h:1449
void LoadBf(const void *Bf, const TSize &BfL)
Definition: fl.h:81
TVal * ValT
Definition: shash.h:1398

Here is the call graph for this function:

template<class TVal>
TIter TPackVec< TVal >::BegI ( ) const
inline

Definition at line 1430 of file shash.h.

References TPackVec< TVal >::ValT.

Referenced by TPackVec< TVal >::AddV(), and TPackVec< TVal >::Sort().

1430 {return ValT; }
TVal * ValT
Definition: shash.h:1398

Here is the caller graph for this function:

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

Definition at line 1423 of file shash.h.

References TPackVec< TVal >::Vals, and TPackVec< TVal >::ValT.

1423 { if (ValT != NULL) { free(ValT); ValT=NULL; } Vals = 0; }
int Vals
Definition: shash.h:1397
TVal * ValT
Definition: shash.h:1398
template<class TVal>
bool TPackVec< TVal >::Empty ( ) const
inline

Definition at line 1425 of file shash.h.

References TPackVec< TVal >::Vals.

1425 {return Vals==0; }
int Vals
Definition: shash.h:1397
template<class TVal>
TIter TPackVec< TVal >::EndI ( ) const
inline

Definition at line 1431 of file shash.h.

References TPackVec< TVal >::Vals, and TPackVec< TVal >::ValT.

Referenced by TPackVec< TVal >::Sort().

1431 {return ValT+Vals; }
int Vals
Definition: shash.h:1397
TVal * ValT
Definition: shash.h:1398

Here is the caller graph for this function:

template<class TVal>
void TPackVec< TVal >::Gen ( const int &  _Vals)
inline

Definition at line 1420 of file shash.h.

References TPackVec< TVal >::Vals, and TPackVec< TVal >::ValT.

Referenced by TPackVec< TVal >::operator=(), and TPackVec< TVal >::TPackVec().

1420  {
1421  if (ValT != NULL) { free(ValT); } Vals = _Vals;
1422  if (Vals==0) { ValT=NULL; } else { ValT = (TVal *) realloc(ValT, sizeof(TVal)*Vals); } }
int Vals
Definition: shash.h:1397
TVal * ValT
Definition: shash.h:1398

Here is the caller graph for this function:

template<class TVal>
TIter TPackVec< TVal >::GetI ( const int &  ValN) const
inline

Definition at line 1432 of file shash.h.

References TPackVec< TVal >::ValT.

1432 { return ValT+ValN; }
TVal * ValT
Definition: shash.h:1398
template<class TVal>
const TVal& TPackVec< TVal >::Last ( ) const
inline

Definition at line 1427 of file shash.h.

References TPackVec< TVal >::Len(), and TPackVec< TVal >::ValT.

1427 { return ValT[Len()-1]; }
int Len() const
Definition: shash.h:1426
TVal * ValT
Definition: shash.h:1398

Here is the call graph for this function:

template<class TVal>
TVal& TPackVec< TVal >::Last ( )
inline

Definition at line 1428 of file shash.h.

References TPackVec< TVal >::Len(), and TPackVec< TVal >::ValT.

1428 { return ValT[Len()-1]; }
int Len() const
Definition: shash.h:1426
TVal * ValT
Definition: shash.h:1398

Here is the call graph for this function:

template<class TVal>
int TPackVec< TVal >::Len ( ) const
inline

Definition at line 1426 of file shash.h.

References TPackVec< TVal >::Vals.

Referenced by TPackVec< TVal >::AddV(), TPackVec< TVal >::Last(), TPackVec< TVal >::operator=(), and TPackVec< TVal >::TPackVec().

1426 {return Vals; }
int Vals
Definition: shash.h:1397

Here is the caller graph for this function:

template<class TVal >
void TPackVec< TVal >::Load ( TSIn SIn)

Definition at line 1457 of file shash.h.

References TSIn::Load(), and TSIn::LoadBf().

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

1457  {
1458  SIn.Load(Vals);
1459  if (Vals==0) {
1460  if (ValT != NULL) { free(ValT); }
1461  ValT = NULL; }
1462  else {
1463  ValT = (TVal *) realloc(ValT, sizeof(TVal)*Vals);
1464  }
1465  SIn.LoadBf(ValT, sizeof(TVal)*Vals);
1466 }
void Load(bool &Bool)
Definition: fl.h:84
int Vals
Definition: shash.h:1397
void LoadBf(const void *Bf, const TSize &BfL)
Definition: fl.h:81
TVal * ValT
Definition: shash.h:1398

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TVal>
TPackVec<TVal>& TPackVec< TVal >::operator= ( const TPackVec< TVal > &  Vec)
inline

Definition at line 1415 of file shash.h.

References TPackVec< TVal >::Gen(), TPackVec< TVal >::Len(), TPackVec< TVal >::Vals, and TPackVec< TVal >::ValT.

1415  { Gen(Vec.Len());
1416  memcpy(ValT, Vec.ValT, sizeof(TVal)*Vals); return *this; }
int Len() const
Definition: shash.h:1426
int Vals
Definition: shash.h:1397
void Gen(const int &_Vals)
Definition: shash.h:1420
TVal * ValT
Definition: shash.h:1398

Here is the call graph for this function:

template<class TVal>
TVec<TVal>& TPackVec< TVal >::operator= ( const TVec< TVal > &  Vec)
inline

Definition at line 1417 of file shash.h.

References TPackVec< TVal >::Gen(), TVec< TVal, TSizeTy >::Len(), TPackVec< TVal >::Vals, TVec< TVal, TSizeTy >::ValT, and TPackVec< TVal >::ValT.

1417  { Gen(Vec.Len());
1418  memcpy(ValT, Vec.ValT, sizeof(TVal)*Vals); return *this; }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
int Vals
Definition: shash.h:1397
void Gen(const int &_Vals)
Definition: shash.h:1420
TVal * ValT
Definition: shash.h:1398
TVal * ValT
Pointer to the memory where the elements of the vector are stored.
Definition: ds.h:436

Here is the call graph for this function:

template<class TVal>
const TVal& TPackVec< TVal >::operator[] ( const int &  ValN) const
inline

Definition at line 1413 of file shash.h.

References TPackVec< TVal >::ValT.

1413 { return ValT[ValN]; }
TVal * ValT
Definition: shash.h:1398
template<class TVal>
TVal& TPackVec< TVal >::operator[] ( const int &  ValN)
inline

Definition at line 1414 of file shash.h.

References TPackVec< TVal >::ValT.

1414 { return ValT[ValN]; }
TVal * ValT
Definition: shash.h:1398
template<class TVal >
void TPackVec< TVal >::ResizeDelta ( const int &  ValsToAdd = 1)
private

Definition at line 1449 of file shash.h.

References EAssert.

Referenced by TPackVec< TVal >::Add(), and TPackVec< TVal >::AddV().

1449  {
1450  if (ValsToAdd == 0) return;
1451  Vals += ValsToAdd;
1452  ValT = (TVal *) realloc(ValT, sizeof(TVal)*Vals);
1453  EAssert(ValT != NULL);
1454 }
int Vals
Definition: shash.h:1397
#define EAssert(Cond)
Definition: bd.h:280
TVal * ValT
Definition: shash.h:1398

Here is the caller graph for this function:

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

Definition at line 1469 of file shash.h.

References TSOut::Save(), and TSOut::SaveBf().

1469  {
1470  SOut.Save(Vals);
1471  if (Vals != 0) {
1472  SOut.SaveBf(ValT, sizeof(TVal)*Vals); }
1473 }
int Vals
Definition: shash.h:1397
void SaveBf(const void *Bf, const TSize &BfL)
Definition: fl.h:172
void Save(const bool &Bool)
Definition: fl.h:173
TVal * ValT
Definition: shash.h:1398

Here is the call graph for this function:

template<class TVal>
void TPackVec< TVal >::Sort ( const bool &  Asc = true)
inline

Definition at line 1442 of file shash.h.

References TPackVec< TVal >::BegI(), TPackVec< TVal >::EndI(), and TVec< TVal, TSizeTy >::QSortCmp().

1442  {
1443  if (Asc) { TVec<TVal>::QSortCmp(BegI(), EndI(), TLss<TVal>()); }
1444  else { TVec<TVal>::QSortCmp(BegI(), EndI(), TGtr<TVal>()); }
1445  }
TIter BegI() const
Definition: shash.h:1430
TIter EndI() const
Definition: shash.h:1431
Definition: bd.h:368
Definition: bd.h:385
static void QSortCmp(TIter BI, TIter EI, const TCmp &Cmp)
Quick sorts the values between positions BI...EI under the comparator Cmp.
Definition: ds.h:762

Here is the call graph for this function:

Member Data Documentation


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