SNAP Library 2.0, Developer Reference  2013-05-13 16:33:57
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
TComb Class Reference

#include <xmath.h>

Collaboration diagram for TComb:

List of all members.

Public Member Functions

 TComb ()
 TComb (const int &_Items, const int &_Order)
 ~TComb ()
 TComb (TSIn &)
void Save (TSOut &)
TComboperator= (const TComb &)
bool GetNext ()
TIntVGetItemV ()
int GetCombN () const
int GetCombs () const
void Wr ()

Static Public Member Functions

static PComb New (const int &Items, const int &Order)
static PComb Load (TSIn &SIn)

Public Attributes

int Items
int Order
int CombN
TIntV ItemV

Private Attributes

TCRef CRef

Friends

class TPt< TComb >

Detailed Description

Definition at line 314 of file xmath.h.


Constructor & Destructor Documentation

TComb::TComb ( ) [inline]

Definition at line 321 of file xmath.h.

: Items(-1), Order(-1), CombN(-1), ItemV(){}
TComb::TComb ( const int &  _Items,
const int &  _Order 
) [inline]

Definition at line 322 of file xmath.h.

References IAssert.

                                             :
    Items(_Items), Order(_Order), CombN(0), ItemV(){
    IAssert((Order>0)&&(Order<=Items));}
TComb::~TComb ( ) [inline]

Definition at line 327 of file xmath.h.

{}
TComb::TComb ( TSIn ) [inline]

Definition at line 328 of file xmath.h.

References Fail.

{Fail;}

Member Function Documentation

int TComb::GetCombN ( ) const [inline]

Definition at line 336 of file xmath.h.

Referenced by Wr().

{return CombN;}

Here is the caller graph for this function:

int TComb::GetCombs ( ) const

Definition at line 748 of file xmath.cpp.

References Items, and Order.

                          {
  int LCombs=1; int HCombs=1;
  for (int OrderN=0; OrderN<Order; OrderN++){
    LCombs*=OrderN+1; HCombs*=Items-OrderN;}
  int Combs=HCombs/LCombs;
  return Combs;
}
TIntV& TComb::GetItemV ( ) [inline]

Definition at line 335 of file xmath.h.

{return ItemV;}
bool TComb::GetNext ( )

Definition at line 724 of file xmath.cpp.

References CombN, TVec< TVal, TSizeTy >::Gen(), Items, ItemV, TVec< TVal, TSizeTy >::Last(), TVec< TVal, TSizeTy >::Len(), and Order.

                   {
  if (ItemV.Len()==0){
    ItemV.Gen(Order, Order);
    for (int OrderN=0; OrderN<Order; OrderN++){
      ItemV[OrderN]=OrderN;}
    return true;
  } else {
    if (ItemV.Last()==Items-1){
      int OrderN=Order-1;
      while ((OrderN>=0)&&(ItemV[OrderN]==Items-(Order-OrderN-1)-1)){OrderN--;}
      if (OrderN<0){
        return false;
      } else {
        ItemV[OrderN]++;
        for (int SubOrderN=OrderN+1; SubOrderN<Order; SubOrderN++){
          ItemV[SubOrderN]=ItemV[SubOrderN-1]+1;}
        CombN++; return true;
      }
    } else {
      ItemV.Last()++; CombN++; return true;
    }
  }
}

Here is the call graph for this function:

static PComb TComb::Load ( TSIn SIn) [inline, static]

Definition at line 329 of file xmath.h.

{return new TComb(SIn);}
static PComb TComb::New ( const int &  Items,
const int &  Order 
) [inline, static]

Definition at line 325 of file xmath.h.

                                                      {
    return PComb(new TComb(Items, Order));}
TComb& TComb::operator= ( const TComb ) [inline]

Definition at line 332 of file xmath.h.

References Fail.

{Fail; return *this;}
void TComb::Save ( TSOut ) [inline]

Definition at line 330 of file xmath.h.

References Fail.

{Fail;}
void TComb::Wr ( )

Definition at line 756 of file xmath.cpp.

References GetCombN(), ItemV, and Order.

              {
  printf("%d:[", GetCombN());
  for (int OrderN=0; OrderN<Order; OrderN++){
    if (OrderN>0){printf(" ");}
    printf("%d", ItemV[OrderN]());
  }
  printf("]\n");
}

Here is the call graph for this function:


Friends And Related Function Documentation

friend class TPt< TComb > [friend]

Definition at line 314 of file xmath.h.


Member Data Documentation

Definition at line 318 of file xmath.h.

Referenced by GetNext().

TCRef TComb::CRef [private]

Definition at line 314 of file xmath.h.

Definition at line 316 of file xmath.h.

Referenced by GetCombs(), and GetNext().

Definition at line 319 of file xmath.h.

Referenced by GetNext(), and Wr().

Definition at line 317 of file xmath.h.

Referenced by GetCombs(), GetNext(), and Wr().


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