ccgsl 2.7.2
C++wrappersforGnuScientificLibrary
gsl::combination Class Reference

This class handles GSL combination objects. More...

#include <combination.hpp>

Collaboration diagram for gsl::combination:
Collaboration graph

Classes

class  const_iterator_t
 A class template for the const iterators. More...
 
class  iterator_base
 The container must have iterator types. More...
 

Public Types

typedef const_iterator_t< false > const_iterator
 The const_iterator type. More...
 
typedef const_iterator_t< true > const_reverse_iterator
 The const_reverse_iterator type. More...
 
typedef const_iterator::difference_type difference_type
 A container must have a difference_type. More...
 
typedef size_t size_type
 A container must have a size_type. More...
 

Public Member Functions

 combination ()
 The default constructor is only really useful for assigning to. More...
 
 combination (size_t const n, size_t const k, bool init=false)
 This constructor creates a new combination with n elements from which k are chosen. More...
 
 combination (gsl_combination *v)
 Could construct from a gsl_combination. More...
 
 combination (combination const &v)
 The copy constructor. More...
 
combinationoperator= (combination const &v)
 The assignment operator. More...
 
combination clone () const
 The clone function. More...
 
 ~combination ()
 The destructor only deletes the pointers if count reaches zero. More...
 
 combination (combination &&v)
 Move constructor. More...
 
combinationoperator= (combination &&v)
 Move operator. More...
 
gsl_combination * get ()
 Get the gsl_combination. More...
 
gsl_combination const * get () const
 Get the gsl_combination. More...
 
bool unique () const
 Find if this is the only object sharing the gsl_combination. More...
 
size_t use_count () const
 Find how many combination objects share this pointer. More...
 
 operator bool () const
 Allow conversion to bool. More...
 
void init_first ()
 C++ version of gsl_combination_init_first(). More...
 
void init_last ()
 C++ version of gsl_combination_init_last(). More...
 
int memcpy (combination const &src)
 C++ version of gsl_combination_memcpy(). More...
 
int fread (FILE *stream)
 C++ version of gsl_combination_fread(). More...
 
int fwrite (FILE *stream) const
 C++ version of gsl_combination_fwrite(). More...
 
int fscanf (FILE *stream)
 C++ version of gsl_combination_fscanf(). More...
 
int fprintf (FILE *stream, char const *format) const
 C++ version of gsl_combination_fprintf(). More...
 
size_t n () const
 C++ version of gsl_combination_n(): Size of set. More...
 
size_t k () const
 C++ version of gsl_combination_k(): Number of selections. More...
 
size_t * data ()
 C++ version of gsl_combination_data(). More...
 
int valid ()
 C++ version of gsl_combination_valid(). More...
 
int next ()
 C++ version of gsl_combination_next(). More...
 
int prev ()
 C++ version of gsl_combination_prev(). More...
 
size_t get (size_t const i) const
 C++ version of gsl_combination_get(). More...
 
size_t operator[] (size_t const i) const
 C++ version of gsl_combination_get(). More...
 
const_iterator begin () const
 Get iterator pointing to first combination element. More...
 
const_iterator end () const
 Get iterator pointing beyond last combination element. More...
 

Static Public Member Functions

static combination calloc (size_t const n, size_t const k)
 C++ version of gsl_combination_calloc(). More...
 

Private Attributes

gsl_combination * ccgsl_pointer
 The shared pointer. More...
 
size_t * count
 The shared reference count. More...
 

Detailed Description

This class handles GSL combination objects.

Definition at line 33 of file combination.hpp.

Member Typedef Documentation

◆ const_iterator

The const_iterator type.

Definition at line 694 of file combination.hpp.

◆ const_reverse_iterator

The const_reverse_iterator type.

Definition at line 698 of file combination.hpp.

◆ difference_type

A container must have a difference_type.

Definition at line 703 of file combination.hpp.

◆ size_type

A container must have a size_type.

Definition at line 708 of file combination.hpp.

Constructor & Destructor Documentation

◆ combination() [1/5]

gsl::combination::combination ( )
inline

The default constructor is only really useful for assigning to.

Definition at line 38 of file combination.hpp.

References ccgsl_pointer, and count.

Referenced by calloc().

◆ combination() [2/5]

gsl::combination::combination ( size_t const  n,
size_t const  k,
bool  init = false 
)
inlineexplicit

This constructor creates a new combination with n elements from which k are chosen.

Parameters
nThe number of elements in the selection set
kThe number of elements chosen
initSet to true to have the combination initialised

Definition at line 48 of file combination.hpp.

References ccgsl_pointer, count, gsl::cheb::init(), init_first(), k(), and n().

◆ combination() [3/5]

gsl::combination::combination ( gsl_combination *  v)
inlineexplicit

Could construct from a gsl_combination.

This is not usually a good idea. In this case you should not use gsl_combination_free() to deallocate the memory.

Parameters
vThe combination

Definition at line 64 of file combination.hpp.

References ccgsl_pointer, and count.

◆ combination() [4/5]

gsl::combination::combination ( combination const &  v)
inline

The copy constructor.

This shares the combination. Use clone() if you want a full copy.

Parameters
vThe combination to copy.

Definition at line 75 of file combination.hpp.

References count.

◆ ~combination()

gsl::combination::~combination ( )
inline

The destructor only deletes the pointers if count reaches zero.

Definition at line 112 of file combination.hpp.

References ccgsl_pointer, and count.

◆ combination() [5/5]

gsl::combination::combination ( combination &&  v)
inline

Move constructor.

Parameters
vThe combination to move.

Definition at line 124 of file combination.hpp.

References count.

Member Function Documentation

◆ begin()

const_iterator gsl::combination::begin ( ) const
inline

Get iterator pointing to first combination element.

Returns
iterator pointing to first combination element

Definition at line 714 of file combination.hpp.

◆ calloc()

static combination gsl::combination::calloc ( size_t const  n,
size_t const  k 
)
inlinestatic

C++ version of gsl_combination_calloc().

Parameters
nThe number of elements in the selection set
kThe number of elements chosen
Returns
A new combination, initialised to \(1,2,\ldots,k\).

Definition at line 188 of file combination.hpp.

References combination(), k(), and n().

◆ clone()

combination gsl::combination::clone ( ) const
inline

The clone function.

Use this if you want a copy of the combination that does not share the underlying data.

Returns
a new copy of this.

Definition at line 101 of file combination.hpp.

References get(), k(), and n().

◆ data()

size_t * gsl::combination::data ( )
inline

C++ version of gsl_combination_data().

Returns
Pointer to the array of elements

Definition at line 244 of file combination.hpp.

References get().

◆ end()

const_iterator gsl::combination::end ( ) const
inline

Get iterator pointing beyond last combination element.

Returns
iterator pointing beyond last combination element

Definition at line 722 of file combination.hpp.

References ccgsl_pointer, and k().

◆ fprintf()

int gsl::combination::fprintf ( FILE *  stream,
char const *  format 
) const
inline

C++ version of gsl_combination_fprintf().

Parameters
streamAn output stream
formatA print format: typically "%zu\n"
Returns
Error code on failure

Definition at line 228 of file combination.hpp.

References get().

◆ fread()

int gsl::combination::fread ( FILE *  stream)
inline

C++ version of gsl_combination_fread().

Parameters
streamAn output stream
Returns
Error code on failure

Definition at line 209 of file combination.hpp.

References get().

◆ fscanf()

int gsl::combination::fscanf ( FILE *  stream)
inline

C++ version of gsl_combination_fscanf().

Parameters
streamAn output stream
Returns
Error code on failure

Definition at line 221 of file combination.hpp.

References get().

◆ fwrite()

int gsl::combination::fwrite ( FILE *  stream) const
inline

C++ version of gsl_combination_fwrite().

Parameters
streamAn output stream
Returns
Error code on failure

Definition at line 215 of file combination.hpp.

References get().

◆ get() [1/3]

gsl_combination * gsl::combination::get ( )
inline

Get the gsl_combination.

Returns
the gsl_combination

Definition at line 154 of file combination.hpp.

References ccgsl_pointer.

Referenced by clone(), data(), fprintf(), fread(), fscanf(), fwrite(), init_first(), init_last(), k(), memcpy(), n(), next(), operator[](), prev(), and valid().

◆ get() [2/3]

gsl_combination const * gsl::combination::get ( ) const
inline

Get the gsl_combination.

Returns
the gsl_combination

Definition at line 159 of file combination.hpp.

References ccgsl_pointer.

◆ get() [3/3]

size_t gsl::combination::get ( size_t const  i) const
inline

C++ version of gsl_combination_get().

Parameters
iindex of element
Returns
Element at index i

Definition at line 265 of file combination.hpp.

References get().

Referenced by get().

◆ init_first()

void gsl::combination::init_first ( )
inline

C++ version of gsl_combination_init_first().

Definition at line 193 of file combination.hpp.

References get().

Referenced by combination().

◆ init_last()

void gsl::combination::init_last ( )
inline

C++ version of gsl_combination_init_last().

Definition at line 197 of file combination.hpp.

References get().

◆ k()

size_t gsl::combination::k ( ) const
inline

C++ version of gsl_combination_k(): Number of selections.

Returns
The size

Definition at line 239 of file combination.hpp.

References get().

Referenced by calloc(), clone(), combination(), and end().

◆ memcpy()

int gsl::combination::memcpy ( combination const &  src)
inline

C++ version of gsl_combination_memcpy().

Parameters
srcThe combination to copy
Returns
Error code on failure

Definition at line 203 of file combination.hpp.

References get().

◆ n()

◆ next()

int gsl::combination::next ( )
inline

C++ version of gsl_combination_next().

Returns
Error code on failure

Definition at line 254 of file combination.hpp.

References get().

◆ operator bool()

gsl::combination::operator bool ( ) const
inlineexplicit

Allow conversion to bool.

Returns
true or false according as this contains a pointer to a gsl_combination

Definition at line 179 of file combination.hpp.

References ccgsl_pointer.

◆ operator=() [1/2]

combination & gsl::combination::operator= ( combination &&  v)
inline

Move operator.

Parameters
vThe combination to move.
Returns
A reference to this.

Definition at line 133 of file combination.hpp.

References ccgsl_pointer, and count.

◆ operator=() [2/2]

combination & gsl::combination::operator= ( combination const &  v)
inline

The assignment operator.

This makes a shared copy.

Parameters
vThe combination to copy

Definition at line 83 of file combination.hpp.

References ccgsl_pointer, and count.

◆ operator[]()

size_t gsl::combination::operator[] ( size_t const  i) const
inline

C++ version of gsl_combination_get().

Parameters
iindex of element
Returns
Element at index i

Definition at line 271 of file combination.hpp.

References get().

◆ prev()

int gsl::combination::prev ( )
inline

C++ version of gsl_combination_prev().

Returns
Error code on failure

Definition at line 259 of file combination.hpp.

References get().

◆ unique()

bool gsl::combination::unique ( ) const
inline

Find if this is the only object sharing the gsl_combination.

Returns
true or falses according as this is the only combination object sharing the gsl_combination

Definition at line 165 of file combination.hpp.

References count.

◆ use_count()

size_t gsl::combination::use_count ( ) const
inline

Find how many combination objects share this pointer.

Returns
the number of combination objects that share this pointer

Definition at line 170 of file combination.hpp.

References count.

◆ valid()

int gsl::combination::valid ( )
inline

C++ version of gsl_combination_valid().

Returns
Error code for valid

Definition at line 249 of file combination.hpp.

References get().

Member Data Documentation

◆ ccgsl_pointer

gsl_combination* gsl::combination::ccgsl_pointer
private

◆ count

size_t* gsl::combination::count
private

The shared reference count.

Definition at line 147 of file combination.hpp.

Referenced by combination(), operator=(), unique(), use_count(), and ~combination().


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