20#ifndef CCGSL_BLOCK_ULONG_HPP
21#define CCGSL_BLOCK_ULONG_HPP
23#include<gsl/gsl_block.h>
28#ifdef __GXX_EXPERIMENTAL_CXX0X__
29#include<initializer_list>
65 try {
count =
new size_t; }
catch( std::bad_alloc& e ){
84#ifdef __GXX_EXPERIMENTAL_CXX0X__
89 block_ulong( std::initializer_list<unsigned long> initializer_list ){
90 size_t const n = initializer_list.size();
93 try {
count =
new size_t; }
catch( std::bad_alloc& e ){
102 for(
auto x : initializer_list ){ *p = x; ++p; }
162#ifdef __GXX_EXPERIMENTAL_CXX0X__
168 std::swap(
count, v.count );
169 v.ccgsl_pointer =
nullptr;
229 for(
size_t i = 0; i <
min; ++i ){
232 if( t < u )
return true;
233 if( u < t )
return false;
236 return size < v_size;
256 for(
size_t i = 0; i <
min; ++i ){
259 if( t > u )
return true;
260 if( u > t )
return false;
263 return size > v_size;
321 template<
typename container,
typename content,
bool reverse>
class iterator_base {
353 static content something = 0;
358 }
else if(
v->ccgsl_pointer == 0 ){
372 return *(
v->ccgsl_pointer->data +
position);
384 }
else if(
v->ccgsl_pointer == 0 ){
398 return v->ccgsl_pointer->data +
position;
408 static content something = 0;
413 }
else if(
v->ccgsl_pointer == 0 ){
428 return *(
v->ccgsl_pointer->data + p);
438 if(
v == 0 or i.
v == 0 ){
441 }
else if(
v->ccgsl_pointer == 0 or i.
v->ccgsl_pointer == 0 ){
446 if(
v->ccgsl_pointer != i.
v->ccgsl_pointer ){
447 gsl_error(
"trying to take difference of iterators for different block_ulongs", __FILE__, __LINE__,
480 if(
v == 0 or i.
v == 0 ){
485 if(
v->ccgsl_pointer != i.
v->ccgsl_pointer ){
486 gsl_error(
"trying to take difference of iterators for different block_ulongs", __FILE__, __LINE__,
502 }
else if(
v->ccgsl_pointer == 0 ){
519 }
else if(
v->ccgsl_pointer == 0 ){
536 }
else if(
v->ccgsl_pointer == 0 ){
684 if( this->
v == 0 or i.
v == 0 ){
693 gsl_error(
"trying to take difference of iterators for different block_ulongs", __FILE__, __LINE__,
722 if( this->
v == 0 or i.
v == 0 ){
728 gsl_error(
"trying to take difference of iterators for different block_ulongs", __FILE__, __LINE__,
753 :
public iterator_base<block_ulong const,unsigned long,reverse>{
870 if( this->
v == 0 or i.
v == 0 ){
879 gsl_error(
"trying to take difference of iterators for different block_ulongs", __FILE__, __LINE__,
920 if( this->
v == 0 or i.
v == 0 ){
926 gsl_error(
"trying to take difference of iterators for different block_ulongs", __FILE__, __LINE__,
955 if( this->
v == 0 or i.
v == 0 ){
961 gsl_error(
"trying to take difference of iterators for different block_ulongs", __FILE__, __LINE__,
1049 if(
ccgsl_pointer == 0 ) gsl_error(
"null block_ulong", __FILE__, __LINE__, GSL_EFAULT );
1056 unsigned long const*
data()
const {
1057 if(
ccgsl_pointer == 0 ) gsl_error(
"null block_ulong", __FILE__, __LINE__, GSL_EFAULT );
1123 static unsigned long something = 0;
1129#ifndef GSL_RANGE_CHECK_OFF
1146 static unsigned long something = 0;
1152#ifndef GSL_RANGE_CHECK_OFF
1194#ifdef __GXX_EXPERIMENTAL_CXX0X__
A class template for the const iterators.
const_iterator_t< reverse > & operator--()
The prefix – operator.
bool operator==(iterator_t< reverse > const &i) const
Comparison with non-const iterator.
difference_type operator-(iterator_t< reverse > const &i) const
The - operator: find distance between two iterators.
const_iterator_t< reverse > operator++(int)
The postfix ++ operator.
const_iterator_t< reverse > operator+(difference_type const n) const
The + operator.
const_iterator_t< reverse > & operator++()
The prefix ++ operator.
const_iterator_t(block_ulong const *v, difference_type position)
This constructor allows block_ulong to create non-default iterators.
bool operator==(const_iterator_t< reverse > const &i) const
Comparison with const iterator.
bool operator!=(const_iterator_t< reverse > const &i) const
Comparison with const iterator.
bool operator!=(iterator_t< reverse > const &i) const
Comparison with non-const iterator.
bool operator<(iterator_t< reverse > const &i) const
Comparison with non-const iterator.
const_iterator_t< reverse > operator--(int)
The postfix – operator.
const_iterator_t(iterator_t< reverse > const &i)
A copy constructor.
difference_type operator-(const_iterator_t< reverse > const &i) const
The - operator: find distance between two iterators.
const_iterator_t< reverse > & operator+=(difference_type const n)
The += operator.
bool operator<(const_iterator_t< reverse > const &i) const
Comparison with const iterator.
const_iterator_t< reverse > operator-(difference_type const n) const
The - operator: subtract distance from iterator.
const_iterator_t< reverse > & operator-=(difference_type const n)
The -= operator.
const_iterator_t()
The default constructor.
iterator_base< block_ulongconst, unsignedlong, reverse >::difference_type difference_type
Difference type.
const_iterator_t< reverse > & operator=(const_iterator_t< reverse > const &i)
We can assign one output iterator from another.
The container must have iterator types.
void decrement()
Decrement the iterator.
bool operator!=(iterator_base< container, content, reverse > const &i) const
The != operator.
value_type & reference
An iterator must have a reference type.
iterator_base()
The iterator is default constructible.
iterator_base(container *v, difference_type position)
This constructor allows block_ulong to create non-default iterators.
pointer operator->() const
Dereference the pointer.
difference_type position
Mark position of iterator within block_ulong.
void shift(difference_type const n)
Shift iterator n places.
value_type * pointer
An iterator must have a pointer typea.
difference_type operator-(iterator_base< container, content, reverse > const &i) const
The - operator: find distance between two iterators.
bool operator==(iterator_base< container, content, reverse > const &i) const
The == operator.
reference operator[](difference_type const n) const
Get element at i + n by reference ([] operator).
void increment()
Increment the iterator.
container * v
Store a pointer to a block_ulong we can iterate over: 0 if no block_ulong.
unsigned long value_type
An iterator must have a value type.
reference operator*() const
Dereference the pointer.
bool operator<(iterator_base< container, content, reverse > const &i) const
The < operator is used to compare iterators.
std::random_access_iterator_tag iterator_category
An iterator must have an iterator category.
ptrdiff_t difference_type
An iterator must have a difference_type.
A class template for the two non-const iterators.
difference_type operator-(iterator_t< reverse > const &i) const
The - operator: find distance between two iterators.
iterator_base< block_ulong, unsignedlong, reverse >::difference_type difference_type
Difference type.
iterator_t()
The default constructor.
iterator_t< reverse > & operator+=(difference_type const n)
The += operator.
iterator_t< reverse > operator+(difference_type const n) const
The + operator.
iterator_t< reverse > & operator--()
The prefix – operator.
bool operator<(const_iterator_t< reverse > const &i) const
Comparison with const iterator.
iterator_t< reverse > & operator++()
The prefix ++ operator.
difference_type operator-(const_iterator_t< reverse > const &i) const
The - operator: find distance between two iterators.
iterator_t< reverse > operator--(int)
The postfix – operator.
iterator_t< reverse > & operator=(iterator_t< reverse > const &i)
We can assign one output iterator from another.
iterator_t< reverse > & operator-=(difference_type const n)
The -= operator.
iterator_t(block_ulong *v, difference_type position)
This constructor allows block_ulong to create non-default iterators.
bool operator==(const_iterator_t< reverse > const &i) const
Comparison with const iterator.
bool operator!=(const_iterator_t< reverse > const &i) const
Comparison with const iterator.
iterator_t< reverse > operator++(int)
The postfix ++ operator.
iterator_t< reverse > operator-(difference_type const n) const
The - operator: subtract distance from iterator.
This class handles vector_ulongs as shared handles.
const_iterator begin() const
Get iterator pointing to first block_ulong element.
bool operator<=(block_ulong const &v) const
A container needs to define an ordering for sorting.
const_reverse_iterator rend() const
Get iterator pointing beyond last block_ulong element.
block_ulong(block_ulong const &v)
The copy constructor.
value_type const & const_reference
A container must have a constant reference type.
const_iterator_t< false > const_iterator
The const_iterator type.
block_ulong & operator=(block_ulong &&v)
Move operator.
iterator_t< true > reverse_iterator
The reverse_iterator type.
value_type & reference
A container must have a reference type.
size_t size_type
A container must have a size_type.
unsigned long value_type
A container must have a value_type.
gsl_block_ulong * get() const
Get the gsl_block_ulong.
size_type max_size() const
The max size (number of elements) of the block_ulong.
gsl_block_ulong * ccgsl_pointer
The shared pointer.
const_iterator_t< true > const_reverse_iterator
The const_reverse_iterator type.
unsigned long const * data() const
Give access to the data block_ulong.
bool operator<(block_ulong const &v) const
A container needs to define an ordering for sorting.
block_ulong(block_ulong &&v)
Move constructor.
bool operator>=(block_ulong const &v) const
A container needs to define an ordering for sorting.
bool unique() const
Find if this is the only object sharing the gsl_block_ulong.
const_reverse_iterator rbegin() const
Get iterator pointing to first block_ulong element.
const_iterator end() const
Get iterator pointing beyond last block_ulong element.
value_type * pointer
A container must have a pointer type.
block_ulong & operator=(block_ulong const &v)
The assignment operator.
reverse_iterator rbegin()
Get iterator pointing to first block_ulong element.
~block_ulong()
The destructor only deletes the pointers if count reaches zero.
block_ulong(gsl_block_ulong *v)
Could construct from a gsl_block_ulong.
bool operator>(block_ulong const &v) const
A container needs to define an ordering for sorting.
block_ulong()
The default constructor is only really useful for assigning to.
size_t use_count() const
Find how many block_ulong objects share this pointer.
value_type const * const_pointer
A container must have a constant pointer type.
bool operator!=(block_ulong const &v) const
Two block_ulong objects are different equal if their elements are not identical.
block_ulong(size_t const n)
The default constructor creates a new block_ulong with n elements.
void reset()
Stop sharing ownership of the shared pointer.
iterator begin()
Get iterator pointing to first block_ulong element.
unsigned long * data()
Give access to the data block_ulong.
const_iterator::difference_type difference_type
A container must have a difference_type.
bool operator==(block_ulong const &v) const
Two block_ulong objects are identically equal if their elements are identical.
void swap(block_ulong &v)
Swap two block_ulong objects.
reverse_iterator rend()
Get iterator pointing beyond last block_ulong element.
block_ulong(std::initializer_list< unsigned long > initializer_list)
Could construct from a std::initializer_list in C++11.
iterator end()
Get iterator pointing beyond last block_ulong element.
unsigned long & operator[](size_t const n)
Get element at position n by reference ([] operator).
size_type size() const
The size (number of elements) of the block_ulong.
block_ulong clone() const
The clone function.
bool empty() const
Find if the block_ulong is empty.
size_t * count
The shared reference count.
iterator_t< false > iterator
The iterator type.
unsigned long const & operator[](size_t const n) const
Get element at position n by reference ([] operator).
@ GSL_EFAILED
generic failure
@ GSL_EINVAL
invalid argument supplied by user
@ GSL_EFAULT
invalid pointer
int min(movstat::end_t const endtype, vector const &x, vector &y, workspace &w)
C++ version of gsl_movstat_min().
size_t n(workspace const &w)
C++ version of gsl_rstat_n().
gsl_sf_result result
Typedef for gsl_sf_result.
The gsl package creates an interface to the GNU Scientific Library for C++.