SNAP Library 2.2, Developer Reference  2014-03-11 19:15:55
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TTuple< TVal, NVals > Class Template Reference

#include <ds.h>

Collaboration diagram for TTuple< TVal, NVals >:

List of all members.

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


Constructor & Destructor Documentation

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

Definition at line 266 of file ds.h.

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

Definition at line 267 of file ds.h.

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

{ for (int i=0; i<Len(); i++) ValV[i]=InitVal; }

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

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

{ for (int i=0; i<Len(); i++) ValV[i]=Tup[i]; }

Here is the call graph for this function:

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

Definition at line 269 of file ds.h.

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

{ for (int i=0; i<Len(); i++) ValV[i].Load(SIn); }

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

                                      {
  TVal MnVal = ValV[0];
  int ValN = 0;
  for (int i = 1; i < NVals; i++) {
    if (MnVal>ValV[i]) {
      MnVal=ValV[i]; ValN=i;
    }
  }
  return ValN;
}
template<class TVal , int NVals>
int TTuple< TVal, NVals >::FindMx ( ) const

Definition at line 310 of file ds.h.

                                      {
  TVal MxVal = ValV[0];
  int ValN = 0;
  for (int i = 1; i < NVals; i++) {
    if (MxVal<ValV[i]) {
      MxVal=ValV[i]; ValN=i;
    }
  }
  return ValN;
}
template<class TVal, int NVals>
int TTuple< TVal, NVals >::GetPrimHashCd ( ) const [inline]

Definition at line 288 of file ds.h.

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

                            { int hc = 0;
    for (int i = 0; i < NVals; i++) { hc = TPairHashImpl::GetHashCd(hc, ValV[i].GetPrimHashCd()); }
    return hc; }

Here is the call graph for this function:

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

Definition at line 291 of file ds.h.

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

                           { int hc = 0;
    for (int i = 1; i < NVals; i++) { hc = TPairHashImpl::GetHashCd(hc, ValV[i].GetSecHashCd()); }
    if (NVals > 0) { hc = TPairHashImpl::GetHashCd(hc, ValV[0].GetSecHashCd()); }
    return hc; }

Here is the call graph for this function:

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

Definition at line 296 of file ds.h.

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

                      { TChA ValsStr;
    for (int i=0; i<Len(); i++) { ValsStr+=" "+ValV[i].GetStr(); }
    return TStr::Fmt("Tuple(%d):", Len())+ValsStr; }

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

{ for (int i=0; i<Len(); i++) ValV[i].Load(SIn); }

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

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

                                            {
    if (Len() == Tup.Len()) { for (int i=0; i<Len(); i++) {
      if(ValV[i]<Tup[i]){return true;} else if(ValV[i]>Tup[i]){return false;} } return false; }
    else { return Len() < Tup.Len(); } }

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

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

                                         { if (this != & Tup) {
    for (int i=0; i<Len(); i++) ValV[i]=Tup[i]; } return *this; }

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

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

                                             {
    if (Len()!=Tup.Len()) { return false; }  if (&Tup==this) { return true; }
    for (int i=0; i<Len(); i++) if(ValV[i]!=Tup[i]){return false;} return true; }

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

References TTuple< TVal, NVals >::ValV.

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

Definition at line 275 of file ds.h.

References TTuple< TVal, NVals >::ValV.

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

Definition at line 270 of file ds.h.

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

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

{ for (int i=0; i<Len(); i++) ValV[i].Save(SOut); }

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

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

                                              {
  TVec<TVal, int> V(NVals);
  for (int i=0; i<NVals; i++) { V.Add(ValV[i]); }
  V.Sort(Asc);
  for (int i=0; i<NVals; i++) { ValV[i] = V[i]; }
}

Here is the call graph for this function:


Member Data Documentation


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