SNAP Library , Developer Reference  2013-01-07 14:03:36
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 246 of file ds.h.


Constructor & Destructor Documentation

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

Definition at line 250 of file ds.h.

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

Definition at line 251 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 252 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 253 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 306 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 294 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 276 of file ds.h.

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

                            { uint HashCd = 5381;
    for (int i=0; i<Len(); i++) { HashCd = ((HashCd << 13) + HashCd) + ValV[i].GetPrimHashCd(); } return int(HashCd&0x7fffffff); }

Here is the call graph for this function:

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

Definition at line 278 of file ds.h.

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

                           { uint HashCd = 5381;
    for (int i=0; i<Len(); i++) { HashCd = ((HashCd << 19) + HashCd) + ValV[i].GetSecHashCd(); } return int(HashCd&0x7fffffff); }

Here is the call graph for this function:

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

Definition at line 280 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>
void TTuple< TVal, NVals >::Load ( TSIn SIn) [inline]

Definition at line 255 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 265 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 260 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 262 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 258 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 259 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 254 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 286 of file ds.h.

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

                                              {
  TVec<TVal> 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: