SNAP Library 2.1, User Reference  2013-09-25 10:47:25
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>

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.

                                             :
    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.

{Fail;}

Member Function Documentation

int TComb::GetCombN ( ) const [inline]

Definition at line 336 of file xmath.h.

{return CombN;}
int TComb::GetCombs ( ) const

Definition at line 748 of file xmath.cpp.

                          {
  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.

                   {
  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;
    }
  }
}
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.

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

Definition at line 330 of file xmath.h.

{Fail;}
void TComb::Wr ( )

Definition at line 756 of file xmath.cpp.

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

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.

TCRef TComb::CRef [private]

Definition at line 314 of file xmath.h.

Definition at line 316 of file xmath.h.

Definition at line 319 of file xmath.h.

Definition at line 317 of file xmath.h.


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