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

This class handles vectors as shared handles. More...

#include <block.hpp>

Collaboration diagram for gsl::block:
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...
 
class  iterator_t
 A class template for the two non-const iterators. More...
 

Public Types

typedef double value_type
 A container must have a value_type. More...
 
typedef value_typereference
 A container must have a reference type. More...
 
typedef value_type const & const_reference
 A container must have a constant reference type. More...
 
typedef value_typepointer
 A container must have a pointer type. More...
 
typedef value_type const * const_pointer
 A container must have a constant pointer type. More...
 
typedef const_iterator_t< false > const_iterator
 The const_iterator type. More...
 
typedef iterator_t< false > iterator
 The iterator type. More...
 
typedef const_iterator_t< true > const_reverse_iterator
 The const_reverse_iterator type. More...
 
typedef iterator_t< true > reverse_iterator
 The 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

 block ()
 The default constructor is only really useful for assigning to. More...
 
 block (size_t const n)
 The default constructor creates a new block with n elements. More...
 
 block (gsl_block *v)
 Could construct from a gsl_block. More...
 
 block (std::initializer_list< double > initializer_list)
 Could construct from a std::initializer_list in C++11. More...
 
 block (block const &v)
 The copy constructor. More...
 
blockoperator= (block const &v)
 The assignment operator. More...
 
block clone () const
 The clone function. More...
 
 ~block ()
 The destructor only deletes the pointers if count reaches zero. More...
 
void reset ()
 Stop sharing ownership of the shared pointer. More...
 
 block (block &&v)
 Move constructor. More...
 
blockoperator= (block &&v)
 Move operator. More...
 
bool operator== (block const &v) const
 Two block objects are identically equal if their elements are identical. More...
 
bool operator!= (block const &v) const
 Two block objects are different equal if their elements are not identical. More...
 
bool operator< (block const &v) const
 A container needs to define an ordering for sorting. More...
 
bool operator> (block const &v) const
 A container needs to define an ordering for sorting. More...
 
bool operator<= (block const &v) const
 A container needs to define an ordering for sorting. More...
 
bool operator>= (block const &v) const
 A container needs to define an ordering for sorting. More...
 
iterator begin ()
 Get iterator pointing to first block element. More...
 
const_iterator begin () const
 Get iterator pointing to first block element. More...
 
iterator end ()
 Get iterator pointing beyond last block element. More...
 
const_iterator end () const
 Get iterator pointing beyond last block element. More...
 
size_type size () const
 The size (number of elements) of the block. More...
 
double * data ()
 Give access to the data block. More...
 
double const * data () const
 Give access to the data block. More...
 
size_type max_size () const
 The max size (number of elements) of the block. More...
 
bool empty () const
 Find if the block is empty. More...
 
void swap (block &v)
 Swap two block objects. More...
 
reverse_iterator rbegin ()
 Get iterator pointing to first block element. More...
 
const_reverse_iterator rbegin () const
 Get iterator pointing to first block element. More...
 
reverse_iterator rend ()
 Get iterator pointing beyond last block element. More...
 
const_reverse_iterator rend () const
 Get iterator pointing beyond last block element. More...
 
double & operator[] (size_t const n)
 Get element at position n by reference ([] operator). More...
 
double const & operator[] (size_t const n) const
 Get element at position n by reference ([] operator). More...
 
gsl_block * get () const
 Get the gsl_block. More...
 
bool unique () const
 Find if this is the only object sharing the gsl_block. More...
 
size_t use_count () const
 Find how many block objects share this pointer. More...
 
 operator bool () const
 Allow conversion to bool. More...
 

Private Attributes

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

Detailed Description

This class handles vectors as shared handles.

It models a random access container so that STL functions work with block.

Definition at line 42 of file block.hpp.

Member Typedef Documentation

◆ const_iterator

The const_iterator type.

Definition at line 983 of file block.hpp.

◆ const_pointer

A container must have a constant pointer type.

Definition at line 315 of file block.hpp.

◆ const_reference

A container must have a constant reference type.

Definition at line 305 of file block.hpp.

◆ const_reverse_iterator

The const_reverse_iterator type.

Definition at line 991 of file block.hpp.

◆ difference_type

A container must have a difference_type.

Definition at line 1000 of file block.hpp.

◆ iterator

The iterator type.

Definition at line 987 of file block.hpp.

◆ pointer

A container must have a pointer type.

Definition at line 310 of file block.hpp.

◆ reference

A container must have a reference type.

Definition at line 300 of file block.hpp.

◆ reverse_iterator

The reverse_iterator type.

Definition at line 995 of file block.hpp.

◆ size_type

typedef size_t gsl::block::size_type

A container must have a size_type.

Definition at line 1005 of file block.hpp.

◆ value_type

typedef double gsl::block::value_type

A container must have a value_type.

Definition at line 295 of file block.hpp.

Constructor & Destructor Documentation

◆ block() [1/6]

gsl::block::block ( )
inline

The default constructor is only really useful for assigning to.

Definition at line 47 of file block.hpp.

References ccgsl_pointer, and count.

Referenced by operator=(), and reset().

◆ block() [2/6]

gsl::block::block ( size_t const  n)
inlineexplicit

The default constructor creates a new block with n elements.

Parameters
nThe number of elements in the block

Definition at line 57 of file block.hpp.

References ccgsl_pointer, count, and gsl::rstat::n().

◆ block() [3/6]

gsl::block::block ( gsl_block *  v)
inlineexplicit

Could construct from a gsl_block.

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

Parameters
vThe block

Definition at line 79 of file block.hpp.

References ccgsl_pointer, and count.

◆ block() [4/6]

gsl::block::block ( std::initializer_list< double >  initializer_list)
inline

Could construct from a std::initializer_list in C++11.

Parameters
initializer_listThe initializer_list.

Definition at line 90 of file block.hpp.

References begin(), ccgsl_pointer, count, and gsl::rstat::n().

◆ block() [5/6]

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

The copy constructor.

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

Parameters
vThe block to copy.

Definition at line 111 of file block.hpp.

References count.

◆ ~block()

gsl::block::~block ( )
inline

The destructor only deletes the pointers if count reaches zero.

Definition at line 150 of file block.hpp.

References ccgsl_pointer, and count.

◆ block() [6/6]

gsl::block::block ( block &&  v)
inline

Move constructor.

Parameters
vThe block to move.

Definition at line 168 of file block.hpp.

References count.

Member Function Documentation

◆ begin() [1/2]

iterator gsl::block::begin ( )
inline

Get iterator pointing to first block element.

Returns
iterator pointing to first block element

Definition at line 1011 of file block.hpp.

Referenced by block().

◆ begin() [2/2]

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

Get iterator pointing to first block element.

Returns
iterator pointing to first block element

Definition at line 1018 of file block.hpp.

◆ clone()

block gsl::block::clone ( ) const
inline

The clone function.

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

Returns
a new copy of this.

Definition at line 139 of file block.hpp.

References ccgsl_pointer.

◆ data() [1/2]

double * gsl::block::data ( )
inline

Give access to the data block.

The data() and size() functions mimic the functions of std::array<T> and std::vector<T>.

Returns
The data block.

Definition at line 1049 of file block.hpp.

References ccgsl_pointer.

◆ data() [2/2]

double const * gsl::block::data ( ) const
inline

Give access to the data block.

The data() and size() functions mimic the functions of std::array<T> and std::vector<T>.

Returns
The data block.

Definition at line 1057 of file block.hpp.

References ccgsl_pointer.

◆ empty()

bool gsl::block::empty ( ) const
inline

Find if the block is empty.

Returns
true if has size zero; otherwise false

Definition at line 1072 of file block.hpp.

References ccgsl_pointer.

◆ end() [1/2]

iterator gsl::block::end ( )
inline

Get iterator pointing beyond last block element.

Returns
iterator pointing beyond last block element

Definition at line 1026 of file block.hpp.

References ccgsl_pointer, and size().

◆ end() [2/2]

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

Get iterator pointing beyond last block element.

Returns
iterator pointing beyond last block element

Definition at line 1034 of file block.hpp.

References ccgsl_pointer, and size().

◆ get()

gsl_block * gsl::block::get ( ) const
inline

Get the gsl_block.

Returns
the gsl_block

Definition at line 1178 of file block.hpp.

References ccgsl_pointer.

◆ max_size()

size_type gsl::block::max_size ( ) const
inline

The max size (number of elements) of the block.

Identical to size but required for a container.

Returns
The size of the block

Definition at line 1066 of file block.hpp.

References ccgsl_pointer.

◆ operator bool()

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

Allow conversion to bool.

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

Definition at line 1198 of file block.hpp.

References ccgsl_pointer.

◆ operator!=()

bool gsl::block::operator!= ( block const &  v) const
inline

Two block objects are different equal if their elements are not identical.

Parameters
vThe block to be compared with this
Returns
false or true according as this and v have identical elements or not

Definition at line 209 of file block.hpp.

References operator==().

◆ operator<()

bool gsl::block::operator< ( block const &  v) const
inline

A container needs to define an ordering for sorting.

This uses standard lexicographical ordering and so is not useful, for example, for checking, that a block is nonnegative.

Parameters
vThe block to be compared with this
Returns
false or true according as this is less than v lexicographically

Definition at line 221 of file block.hpp.

References ccgsl_pointer, gsl::movstat::min(), and size().

Referenced by operator<=().

◆ operator<=()

bool gsl::block::operator<= ( block const &  v) const
inline

A container needs to define an ordering for sorting.

This uses standard lexicographical ordering and so is not useful, for example, for checking, that a block is nonnegative.

Parameters
vThe block to be compared with this
Returns
false or true according as this is less than or equal to v lexicographically

Definition at line 275 of file block.hpp.

References operator<(), and operator==().

◆ operator=() [1/2]

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

Move operator.

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

Definition at line 177 of file block.hpp.

References block().

◆ operator=() [2/2]

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

The assignment operator.

This makes a shared copy.

Parameters
vThe block to copy

Definition at line 119 of file block.hpp.

References ccgsl_pointer, and count.

◆ operator==()

bool gsl::block::operator== ( block const &  v) const
inline

Two block objects are identically equal if their elements are identical.

Parameters
vThe block to be compared with this
Returns
true or false according as this and v have identical elements or not

Definition at line 190 of file block.hpp.

References ccgsl_pointer.

Referenced by operator!=(), operator<=(), and operator>=().

◆ operator>()

bool gsl::block::operator> ( block const &  v) const
inline

A container needs to define an ordering for sorting.

This uses standard lexicographical ordering and so is not useful, for example, for checking, that a block is nonnegative.

Parameters
vThe block to be compared with this
Returns
false or true according as this is greater than v lexicographically

Definition at line 248 of file block.hpp.

References ccgsl_pointer, gsl::movstat::min(), and size().

Referenced by operator>=().

◆ operator>=()

bool gsl::block::operator>= ( block const &  v) const
inline

A container needs to define an ordering for sorting.

This uses standard lexicographical ordering and so is not useful, for example, for checking, that a block is nonnegative.

Parameters
vThe block to be compared with this
Returns
false or true according as this is no less than v lexicographically

Definition at line 287 of file block.hpp.

References operator==(), and operator>().

◆ operator[]() [1/2]

double & gsl::block::operator[] ( size_t const  n)
inline

Get element at position n by reference ([] operator).

Parameters
nThe position of the element
Returns
a reference to a double

Definition at line 1122 of file block.hpp.

References ccgsl_pointer, gsl::exception::GSL_EFAULT, gsl::exception::GSL_EINVAL, gsl::rstat::n(), and size().

◆ operator[]() [2/2]

double const & gsl::block::operator[] ( size_t const  n) const
inline

Get element at position n by reference ([] operator).

Parameters
nThe position of the element
Returns
a reference to a double

Definition at line 1145 of file block.hpp.

References ccgsl_pointer, gsl::exception::GSL_EFAULT, gsl::exception::GSL_EINVAL, gsl::rstat::n(), and size().

◆ rbegin() [1/2]

reverse_iterator gsl::block::rbegin ( )
inline

Get iterator pointing to first block element.

Returns
iterator pointing to first block element

Definition at line 1089 of file block.hpp.

References ccgsl_pointer, and size().

◆ rbegin() [2/2]

const_reverse_iterator gsl::block::rbegin ( ) const
inline

Get iterator pointing to first block element.

Returns
iterator pointing to first block element

Definition at line 1097 of file block.hpp.

References ccgsl_pointer, and size().

◆ rend() [1/2]

reverse_iterator gsl::block::rend ( )
inline

Get iterator pointing beyond last block element.

Returns
iterator pointing beyond last block element

Definition at line 1106 of file block.hpp.

◆ rend() [2/2]

const_reverse_iterator gsl::block::rend ( ) const
inline

Get iterator pointing beyond last block element.

Returns
iterator pointing beyond last block element

Definition at line 1113 of file block.hpp.

◆ reset()

void gsl::block::reset ( )
inline

Stop sharing ownership of the shared pointer.

Definition at line 162 of file block.hpp.

References block().

◆ size()

size_type gsl::block::size ( ) const
inline

The size (number of elements) of the block.

Returns
The size of the block

Definition at line 1043 of file block.hpp.

References ccgsl_pointer.

Referenced by end(), operator<(), operator>(), operator[](), and rbegin().

◆ swap()

void gsl::block::swap ( block v)
inline

Swap two block objects.

This works even if the block objects have different sizes because it swaps pointers.

Parameters
vThe block to swap with this.

Definition at line 1079 of file block.hpp.

References ccgsl_pointer, and count.

◆ unique()

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

Find if this is the only object sharing the gsl_block.

Returns
true or falses according as this is the only block object sharing the gsl_block

Definition at line 1184 of file block.hpp.

References count.

◆ use_count()

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

Find how many block objects share this pointer.

Returns
the number of block objects that share this pointer

Definition at line 1189 of file block.hpp.

References count.

Member Data Documentation

◆ ccgsl_pointer

◆ count

size_t* gsl::block::count
private

The shared reference count.

Definition at line 1171 of file block.hpp.

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


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