13#ifndef __stir_VectorWithOffset_H__
14#define __stir_VectorWithOffset_H__
70 typedef value_type& reference;
71 typedef const value_type& const_reference;
72 typedef ptrdiff_t difference_type;
74 typedef T
const* const_iterator;
76 typedef std::reverse_iterator<iterator> reverse_iterator;
77 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
79 typedef size_t size_type;
91#if STIR_VERSION < 070000
115 inline VectorWithOffset(
const int min_index,
const int max_index,
const T*
const data_ptr);
122 inline VectorWithOffset(
const int min_index,
const int max_index, shared_ptr<T[]> data_sptr);
146 swap(first.length, second.length);
147 swap(first.start, second.start);
148 swap(first.begin_allocated_memory, second.begin_allocated_memory);
149 swap(first.end_allocated_memory, second.end_allocated_memory);
150 swap(first.pointer_access, second.pointer_access);
151 swap(first.allocated_memory_sptr, second.allocated_memory_sptr);
197 inline virtual void grow(
const int min_index,
const int max_index);
200 inline void grow(
const unsigned int new_size);
210 inline virtual void resize(
const int min_index,
const int max_index);
213 inline void resize(
const unsigned int new_size);
216 inline void reserve(
const int min_index,
const int max_index);
219 inline void reserve(
const unsigned int new_size);
256 inline const T&
at(
int i)
const;
296 inline const_iterator
begin()
const;
300 inline const_iterator
end()
const;
302 inline reverse_iterator rbegin();
303 inline reverse_iterator rend();
304 inline const_reverse_iterator rbegin()
const;
305 inline const_reverse_iterator rend()
const;
380 inline void init_with_copy(
const int min_index,
const int max_index, T
const*
const data_ptr);
390 inline void init(
const int min_index,
const int max_index, T*
const data_ptr,
bool copy_data);
398 T* begin_allocated_memory;
399 T* end_allocated_memory;
402 shared_ptr<T[]> allocated_memory_sptr;
408 inline void _destruct_and_deallocate();
412 mutable bool pointer_access;
inline implementations of stir::VectorWithOffset
const T & at(int i) const
array access, read-only, but with range checking (throws std::out_of_range)
Definition VectorWithOffset.inl:172
void release_const_data_ptr() const
signal end of access to const T*
Definition VectorWithOffset.inl:672
T & at(int i)
allow array-style access, read/write, but with range checking (throws std::out_of_range)
Definition VectorWithOffset.inl:162
const T * get_const_data_ptr() const
member function for access to the data via a const T*
Definition VectorWithOffset.inl:634
iterator begin()
use to initialise an iterator to the first element of the vector
Definition VectorWithOffset.inl:190
VectorWithOffset(const int hsz)
Construct a VectorWithOffset of given length (initialised with T())
Definition VectorWithOffset.inl:260
VectorWithOffset & operator=(const VectorWithOffset &il)
assignment operator with another vector
Definition VectorWithOffset.inl:505
void check_state() const
Called internally to see if all variables are consistent.
Definition VectorWithOffset.inl:87
VectorWithOffset(const VectorWithOffset &il)
copy constructor
Definition VectorWithOffset.inl:529
virtual ~VectorWithOffset()
Destructor.
Definition VectorWithOffset.inl:330
int get_max_index() const
get value of last valid index
Definition VectorWithOffset.inl:131
VectorWithOffset(const int sz, shared_ptr< T[]> data_sptr)
Construct a VectorWithOffset sharing existing data.
Definition VectorWithOffset.h:129
void init(const int min_index, const int max_index, T *const data_ptr, bool copy_data)
initialise vector to the given index range and either copy from or point to data_ptr
Definition VectorWithOffset.inl:56
VectorWithOffset & operator*=(const VectorWithOffset &v)
multiplying elements of the current vector with elements of v
Definition VectorWithOffset.inl:727
size_t capacity() const
get allocated size
Definition VectorWithOffset.inl:358
VectorWithOffset & operator+=(const VectorWithOffset &v)
adding elements of v to the current vector
Definition VectorWithOffset.inl:682
VectorWithOffset operator-(const VectorWithOffset &v) const
subtracting vectors, element by element
Definition VectorWithOffset.inl:832
const T & operator[](int i) const
array access, read-only
Definition VectorWithOffset.inl:151
int get_min_index() const
get value of first valid index
Definition VectorWithOffset.inl:124
virtual void grow(const int min_index, const int max_index)
grow the range of the vector, new elements are set to T()
Definition VectorWithOffset.inl:491
void reserve(const unsigned int new_size)
make the allocated range at least from 0 to new_size-1
Definition VectorWithOffset.inl:415
VectorWithOffset(const int min_index, const int max_index, shared_ptr< T[]> data_sptr)
Construct a VectorWithOffset sharing existing data.
Definition VectorWithOffset.inl:316
bool owns_memory_for_data() const
check if this object owns the memory for the data
Definition VectorWithOffset.inl:76
const_iterator begin() const
use to initialise an iterator to the first element of the (const) vector
Definition VectorWithOffset.inl:198
void release_data_ptr()
signal end of access to T*
Definition VectorWithOffset.inl:655
void reserve(const int min_index, const int max_index)
make the allocated range at least from min_index to max_index
Definition VectorWithOffset.inl:385
VectorWithOffset & operator-=(const VectorWithOffset &v)
subtracting elements of v from the current vector
Definition VectorWithOffset.inl:704
VectorWithOffset operator*(const VectorWithOffset &v) const
multiplying vectors, element by element
Definition VectorWithOffset.inl:842
VectorWithOffset operator+(const VectorWithOffset &v) const
adding vectors, element by element
Definition VectorWithOffset.inl:822
VectorWithOffset(const int min_index, const int max_index)
Construct a VectorWithOffset with offset min_index (initialised with T())
Definition VectorWithOffset.inl:265
int get_length() const
return number of elements in this vector
Definition VectorWithOffset.inl:538
STIR_DEPRECATED VectorWithOffset(const int hsz, T *const data_ptr, T *const end_of_data_ptr)
Construct a VectorWithOffset of given length pointing to existing data.
Definition VectorWithOffset.inl:297
void set_min_index(const int min_index)
identical to set_offset()
Definition VectorWithOffset.inl:351
virtual void resize(const int min_index, const int max_index)
change the range of the vector, new elements are set to T()
Definition VectorWithOffset.inl:426
VectorWithOffset(const int hsz, const T *const data_ptr)
Construct a VectorWithOffset of given length from a bare pointer (copying data)
Definition VectorWithOffset.inl:311
void set_offset(const int min_index)
change value of starting index
Definition VectorWithOffset.inl:339
VectorWithOffset(VectorWithOffset &&other) noexcept
move constructor
Definition VectorWithOffset.inl:323
VectorWithOffset(const int min_index, const int max_index, const T *const data_ptr)
Construct a VectorWithOffset with offset min_index from a bare pointer (copying data)
Definition VectorWithOffset.inl:303
VectorWithOffset & operator/=(const VectorWithOffset &v)
dividing all elements of the current vector by elements of v
Definition VectorWithOffset.inl:751
iterator end()
iterator 'past' the last element of the vector
Definition VectorWithOffset.inl:206
VectorWithOffset operator/(const VectorWithOffset &v) const
dividing vectors, element by element
Definition VectorWithOffset.inl:852
void apply_lower_threshold(const T &lower)
Sets elements below value to the value.
Definition VectorWithOffset.inl:580
int get_capacity_max_index() const
get max_index within allocated range
Definition VectorWithOffset.inl:374
VectorWithOffset()
Default constructor: creates a vector of length 0.
Definition VectorWithOffset.inl:253
void recycle()
Free all memory and make object as if default-constructed.
Definition VectorWithOffset.inl:115
void fill(const T &n)
fill elements with value n
Definition VectorWithOffset.inl:571
T * get_data_ptr()
member function for access to the data via a T*
Definition VectorWithOffset.inl:612
T & operator[](int i)
allow array-style access, read/write
Definition VectorWithOffset.inl:139
int get_capacity_min_index() const
get min_index within allocated range
Definition VectorWithOffset.inl:365
bool empty() const
checks if the vector is empty
Definition VectorWithOffset.inl:183
void init_with_copy(const int min_index, const int max_index, T const *const data_ptr)
change vector to the new index range and copy data from data_ptr
Definition VectorWithOffset.inl:47
void resize(const unsigned int new_size)
change the range of the vector from 0 to new_size-1, new elements are set to T()
void grow(const unsigned int new_size)
grow the range of the vector from 0 to new_size-1, new elements are set to T()
const_iterator end() const
iterator 'past' the last element of the (const) vector
Definition VectorWithOffset.inl:214
void apply_upper_threshold(const T &upper)
Sets elements above value to the value.
Definition VectorWithOffset.inl:589
friend void swap(VectorWithOffset &first, VectorWithOffset &second)
Swap content/members of 2 objects.
Definition VectorWithOffset.h:141
T * num
pointer to (*this)[0] (taking get_min_index() into account that is).
Definition VectorWithOffset.h:370
size_t size() const
return number of elements in this vector
Definition VectorWithOffset.inl:546
STIR_DEPRECATED VectorWithOffset(const int min_index, const int max_index, T *const data_ptr, T *const end_of_data_ptr)
Construct a VectorWithOffset with offset min_index pointing to existing data.
Definition VectorWithOffset.inl:284
This file declares a deprecation macro.
#define STIR_DEPRECATED
Deprecation macro.
Definition deprecated.h:21
Import of std::shared_ptr, std::dynamic_pointer_cast and std::static_pointer_cast into the stir names...