SNAP Library 3.0, Developer 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
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 271 of file ds.h.

Constructor & Destructor Documentation

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

Definition at line 275 of file ds.h.

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

Definition at line 276 of file ds.h.

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

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

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 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]=Tup[i]; }
int Len() const
Definition: ds.h:282
TVal ValV[NVals]
Definition: ds.h:273

Here is the call graph for this function:

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

Definition at line 278 of file ds.h.

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

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

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

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

Definition at line 319 of file ds.h.

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

Definition at line 297 of file ds.h.

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

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

Here is the call graph for this function:

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

Definition at line 300 of file ds.h.

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

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

Here is the call graph for this function:

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

Definition at line 305 of file ds.h.

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

305  { TChA ValsStr;
306  for (int i=0; i<Len(); i++) { ValsStr+=" "+ValV[i].GetStr(); }
307  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:282
TVal ValV[NVals]
Definition: ds.h:273

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 280 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().

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

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

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

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

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

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

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

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

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

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

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

References TTuple< TVal, NVals >::ValV.

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

Definition at line 284 of file ds.h.

References TTuple< TVal, NVals >::ValV.

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

Definition at line 279 of file ds.h.

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

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

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

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

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

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

Here is the call graph for this function:

Member Data Documentation


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