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
TTuple< TVal, NVals > Class Template Reference

#include <ds.h>

Collaboration diagram for TTuple< TVal, NVals >:

Public Member Functions

 TTuple ()
 
 TTuple (const TVal &InitVal)
 
 TTuple (const TTuple &Tup)
 
 TTuple (TSIn &SIn)
 
void Save (TSOut &SOut) const
 
void Load (TSIn &SIn)
 
int Len () const
 
TVal & operator[] (const int &ValN)
 
const TVal & operator[] (const int &ValN) const
 
TTupleoperator= (const TTuple &Tup)
 
bool operator== (const TTuple &Tup) const
 
bool operator< (const TTuple &Tup) const
 
void Sort (const bool &Asc=true)
 
int FindMx () const
 
int FindMn () const
 
int GetPrimHashCd () const
 
int GetSecHashCd () const
 
TStr GetStr () const
 

Private Attributes

TVal ValV [NVals]
 

Detailed Description

template<class TVal, int NVals>
class TTuple< TVal, NVals >

Definition at line 272 of file ds.h.

Constructor & Destructor Documentation

template<class TVal, int NVals>
TTuple< TVal, NVals >::TTuple ( )
inline

Definition at line 276 of file ds.h.

276 {}
template<class TVal, int NVals>
TTuple< TVal, NVals >::TTuple ( const TVal &  InitVal)
inline

Definition at line 277 of file ds.h.

References TTuple< TVal, NVals >::Len(), and TTuple< TVal, NVals >::ValV.

277 { for (int i=0; i<Len(); i++) ValV[i]=InitVal; }
int Len() const
Definition: ds.h:283
TVal ValV[NVals]
Definition: ds.h:274

Here is the call graph for this function:

template<class TVal, int NVals>
TTuple< TVal, NVals >::TTuple ( const TTuple< TVal, NVals > &  Tup)
inline

Definition at line 278 of file ds.h.

References TTuple< TVal, NVals >::Len(), and TTuple< TVal, NVals >::ValV.

278 { for (int i=0; i<Len(); i++) ValV[i]=Tup[i]; }
int Len() const
Definition: ds.h:283
TVal ValV[NVals]
Definition: ds.h:274

Here is the call graph for this function:

template<class TVal, int NVals>
TTuple< TVal, NVals >::TTuple ( TSIn SIn)
inline

Definition at line 279 of file ds.h.

References TTuple< TVal, NVals >::Len(), TTuple< TVal, NVals >::Load(), and TTuple< TVal, NVals >::ValV.

279 { for (int i=0; i<Len(); i++) ValV[i].Load(SIn); }
void Load(TSIn &SIn)
Definition: ds.h:281
int Len() const
Definition: ds.h:283
TVal ValV[NVals]
Definition: ds.h:274

Here is the call graph for this function:

Member Function Documentation

template<class TVal , int NVals>
int TTuple< TVal, NVals >::FindMn ( ) const

Definition at line 332 of file ds.h.

332  {
333  TVal MnVal = ValV[0];
334  int ValN = 0;
335  for (int i = 1; i < NVals; i++) {
336  if (MnVal>ValV[i]) {
337  MnVal=ValV[i]; ValN=i;
338  }
339  }
340  return ValN;
341 }
TVal ValV[NVals]
Definition: ds.h:274
template<class TVal , int NVals>
int TTuple< TVal, NVals >::FindMx ( ) const

Definition at line 320 of file ds.h.

320  {
321  TVal MxVal = ValV[0];
322  int ValN = 0;
323  for (int i = 1; i < NVals; i++) {
324  if (MxVal<ValV[i]) {
325  MxVal=ValV[i]; ValN=i;
326  }
327  }
328  return ValN;
329 }
TVal ValV[NVals]
Definition: ds.h:274
template<class TVal, int NVals>
int TTuple< TVal, NVals >::GetPrimHashCd ( ) const
inline

Definition at line 298 of file ds.h.

References TPairHashImpl2::GetHashCd(), and TTuple< TVal, NVals >::ValV.

298  { int hc = 0;
299  for (int i = 0; i < NVals; i++) { hc = TPairHashImpl::GetHashCd(hc, ValV[i].GetPrimHashCd()); }
300  return hc; }
static int GetHashCd(const int hc1, const int hc2)
Definition: bd.h:590
TVal ValV[NVals]
Definition: ds.h:274
int GetPrimHashCd() const
Definition: ds.h:298

Here is the call graph for this function:

template<class TVal, int NVals>
int TTuple< TVal, NVals >::GetSecHashCd ( ) const
inline

Definition at line 301 of file ds.h.

References TPairHashImpl2::GetHashCd(), and TTuple< TVal, NVals >::ValV.

301  { int hc = 0;
302  for (int i = 1; i < NVals; i++) { hc = TPairHashImpl::GetHashCd(hc, ValV[i].GetSecHashCd()); }
303  if (NVals > 0) { hc = TPairHashImpl::GetHashCd(hc, ValV[0].GetSecHashCd()); }
304  return hc; }
int GetSecHashCd() const
Definition: ds.h:301
static int GetHashCd(const int hc1, const int hc2)
Definition: bd.h:590
TVal ValV[NVals]
Definition: ds.h:274

Here is the call graph for this function:

template<class TVal, int NVals>
TStr TTuple< TVal, NVals >::GetStr ( ) const
inline

Definition at line 306 of file ds.h.

References TStr::Fmt(), TTuple< TVal, NVals >::Len(), and TTuple< TVal, NVals >::ValV.

306  { TChA ValsStr;
307  for (int i=0; i<Len(); i++) { ValsStr+=" "+ValV[i].GetStr(); }
308  return TStr::Fmt("Tuple(%d):", Len())+ValsStr; }
Definition: dt.h:201
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
int Len() const
Definition: ds.h:283
TVal ValV[NVals]
Definition: ds.h:274

Here is the call graph for this function:

template<class TVal, int NVals>
int TTuple< TVal, NVals >::Len ( ) const
inline
template<class TVal, int NVals>
void TTuple< TVal, NVals >::Load ( TSIn SIn)
inline

Definition at line 281 of file ds.h.

References TTuple< TVal, NVals >::Len(), TTuple< TVal, NVals >::Load(), and TTuple< TVal, NVals >::ValV.

Referenced by TTuple< TVal, NVals >::Load(), and TTuple< TVal, NVals >::TTuple().

281 { for (int i=0; i<Len(); i++) ValV[i].Load(SIn); }
void Load(TSIn &SIn)
Definition: ds.h:281
int Len() const
Definition: ds.h:283
TVal ValV[NVals]
Definition: ds.h:274

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TVal, int NVals>
bool TTuple< TVal, NVals >::operator< ( const TTuple< TVal, NVals > &  Tup) const
inline

Definition at line 291 of file ds.h.

References TTuple< TVal, NVals >::Len(), and TTuple< TVal, NVals >::ValV.

291  {
292  if (Len() == Tup.Len()) { for (int i=0; i<Len(); i++) {
293  if(ValV[i]<Tup[i]){return true;} else if(ValV[i]>Tup[i]){return false;} } return false; }
294  else { return Len() < Tup.Len(); } }
int Len() const
Definition: ds.h:283
TVal ValV[NVals]
Definition: ds.h:274

Here is the call graph for this function:

template<class TVal, int NVals>
TTuple& TTuple< TVal, NVals >::operator= ( const TTuple< TVal, NVals > &  Tup)
inline

Definition at line 286 of file ds.h.

References TTuple< TVal, NVals >::Len(), and TTuple< TVal, NVals >::ValV.

286  { if (this != & Tup) {
287  for (int i=0; i<Len(); i++) ValV[i]=Tup[i]; } return *this; }
int Len() const
Definition: ds.h:283
TVal ValV[NVals]
Definition: ds.h:274

Here is the call graph for this function:

template<class TVal, int NVals>
bool TTuple< TVal, NVals >::operator== ( const TTuple< TVal, NVals > &  Tup) const
inline

Definition at line 288 of file ds.h.

References TTuple< TVal, NVals >::Len(), and TTuple< TVal, NVals >::ValV.

288  {
289  if (Len()!=Tup.Len()) { return false; } if (&Tup==this) { return true; }
290  for (int i=0; i<Len(); i++) if(ValV[i]!=Tup[i]){return false;} return true; }
int Len() const
Definition: ds.h:283
TVal ValV[NVals]
Definition: ds.h:274

Here is the call graph for this function:

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

Definition at line 284 of file ds.h.

References TTuple< TVal, NVals >::ValV.

284 { return ValV[ValN]; }
TVal ValV[NVals]
Definition: ds.h:274
template<class TVal, int NVals>
const TVal& TTuple< TVal, NVals >::operator[] ( const int &  ValN) const
inline

Definition at line 285 of file ds.h.

References TTuple< TVal, NVals >::ValV.

285 { return ValV[ValN]; }
TVal ValV[NVals]
Definition: ds.h:274
template<class TVal, int NVals>
void TTuple< TVal, NVals >::Save ( TSOut SOut) const
inline

Definition at line 280 of file ds.h.

References TTuple< TVal, NVals >::Len(), TTuple< TVal, NVals >::Save(), and TTuple< TVal, NVals >::ValV.

Referenced by TTuple< TVal, NVals >::Save().

280 { for (int i=0; i<Len(); i++) ValV[i].Save(SOut); }
int Len() const
Definition: ds.h:283
TVal ValV[NVals]
Definition: ds.h:274
void Save(TSOut &SOut) const
Definition: ds.h:280

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TVal , int NVals>
void TTuple< TVal, NVals >::Sort ( const bool &  Asc = true)

Definition at line 312 of file ds.h.

References TVec< TVal, TSizeTy >::Add(), and TVec< TVal, TSizeTy >::Sort().

312  {
313  TVec<TVal, int> V(NVals);
314  for (int i=0; i<NVals; i++) { V.Add(ValV[i]); }
315  V.Sort(Asc);
316  for (int i=0; i<NVals; i++) { ValV[i] = V[i]; }
317 }
TVal ValV[NVals]
Definition: ds.h:274
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:430

Here is the call graph for this function:

Member Data Documentation


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