SNAP Library 2.2, User 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
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 316 of file xmath.h.


Constructor & Destructor Documentation

TComb::TComb ( ) [inline]

Definition at line 323 of file xmath.h.

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

Definition at line 324 of file xmath.h.

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

Definition at line 329 of file xmath.h.

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

Definition at line 330 of file xmath.h.

{Fail;}

Member Function Documentation

int TComb::GetCombN ( ) const [inline]

Definition at line 338 of file xmath.h.

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

Definition at line 759 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 337 of file xmath.h.

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

Definition at line 735 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 331 of file xmath.h.

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

Definition at line 327 of file xmath.h.

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

Definition at line 334 of file xmath.h.

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

Definition at line 332 of file xmath.h.

{Fail;}
void TComb::Wr ( )

Definition at line 767 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 316 of file xmath.h.


Member Data Documentation

Definition at line 320 of file xmath.h.

TCRef TComb::CRef [private]

Definition at line 316 of file xmath.h.

Definition at line 318 of file xmath.h.

Definition at line 321 of file xmath.h.

Definition at line 319 of file xmath.h.


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