ALP User Documentation  0.8.preview
Algebraic Programming User Documentation
Public Types | Public Member Functions | List of all members
Range< T > Class Template Reference

A container that contains a sequence of numbers with a given stride, and optionally a given number of repetitions. More...

Public Types

typedef iterator const_iterator
 The const-iterator type.
 
typedef grb::utils::iterators::Sequence< T >::RealType iterator
 The iterator type. More...
 

Public Member Functions

 Range (const size_t start, const size_t end, const size_t stride=static_cast< size_t >(1), const size_t repetitions=static_cast< size_t >(1)) noexcept
 Constructs a range. More...
 
iterator begin (const size_t s=0, const size_t P=1) const
 Returns a const-iterator at start position to this container. More...
 
const_iterator cbegin (const size_t s=0, const size_t P=1) const
 Returns a const-iterator at start position to this container. More...
 
const_iterator cend (const size_t s=0, const size_t P=1) const
 Returns a const-iterator at end position to this container. More...
 
iterator end (const size_t s=0, const size_t P=1) const
 Returns a const-iterator at end position to this container. More...
 

Detailed Description

template<typename T = size_t>
class grb::utils::containers::Range< T >

A container that contains a sequence of numbers with a given stride, and optionally a given number of repetitions.

Template Parameters
TThe type of numbers; optional, default is size_t.

The storage of this container is \( \Theta(1) \).

This is an unmodifiable (const) container.

Member Typedef Documentation

◆ iterator

typedef grb::utils::iterators::Sequence< T >::RealType iterator

The iterator type.

Constructor & Destructor Documentation

◆ Range()

Range ( const size_t  start,
const size_t  end,
const size_t  stride = static_cast< size_t >( 1 ),
const size_t  repetitions = static_cast< size_t >( 1 ) 
)
inlinenoexcept

Constructs a range.

Parameters
[in]startThe start of the range (inclusive)
[in]endThe end of the range (exclusive)
[in]strideThe stride of the range (optional, default is 1)
[in]repetitionsThe number of repetitions of each value (optional, default is 1)

The value end must be larger than or equal to start. Equal values for start and end result in an empty range. A larger value for end than start will result in a range consisting at least one element (start).

Examples
The range \( (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) \) may be constructed by start 1, end 11, stride 1 and repetitions 1.

The range \( (1, 3, 5, 7, 9) \) may be constructed by start 1, end 11, stride 2 and repetitions 1.

The range \( (1, 1, 2, 2, 3, 3) \) may be constructed by start 1, end 4, stride 1 and repetitions 2.

Member Function Documentation

◆ begin()

iterator begin ( const size_t  s = 0,
const size_t  P = 1 
) const
inline

Returns a const-iterator at start position to this container.

By default, it creates a sequential I/O iterator, meaning, an iterator that iterators over all elements in the container. Optionally, however, the callee may request an iterator over a chunk of this container instead:

Parameters
[in]sThe chunk ID of the requested chunk.
[in]PHow many chunks the underlying container should be cut into.

The defaults for s and P are 0 and 1, respectively. The value s must always be strictly smaller than P, and P must always be strictly larger than zero.

For \( P > 1 \), the iterator may be used to effect parallel I/O. With parallel I/O, multiple threads and/or processes may concurrently deal with different chunks of this container.

An iterator pair retrieved in this mode only has knowledge about the elements in its chunk of the container; the size of the container as visible by the iterator pair thus reflects the size of the chunk, not that of the container.

Thus as an addition to standard STL semenatics, iterator pairs when jointly passed to some STL (or ALP) call must not only be derived from the same container, but must be derived from the same chunk as well.

◆ cbegin()

const_iterator cbegin ( const size_t  s = 0,
const size_t  P = 1 
) const
inline

Returns a const-iterator at start position to this container.

Since this container is immutable, there is no difference between this function (cbegin) and begin. Please see the latter for full documentation.

◆ cend()

const_iterator cend ( const size_t  s = 0,
const size_t  P = 1 
) const
inline

Returns a const-iterator at end position to this container.

Since this container is immutable, there is no difference between this function (cend) and end. Please see the latter for full documentation.

◆ end()

iterator end ( const size_t  s = 0,
const size_t  P = 1 
) const
inline

Returns a const-iterator at end position to this container.

By default, it creates a sequential I/O iterator, meaning, an iterator that iterators over all elements in the container. Optionally, however, the callee may request an iterator over a chunk of this container instead:

Parameters
[in]sThe chunk ID of the requested chunk.
[in]PHow many chunks the underlying container should be cut into.

The defaults for s and P are 0 and 1, respectively. The value s must always be strictly smaller than P, and P must always be strictly larger than zero.

For \( P > 1 \), the iterator may be used to effect parallel I/O. With parallel I/O, multiple threads and/or processes may concurrently deal with different chunks of this container.

An iterator pair retrieved in this mode only has knowledge about the elements in its chunk of the container; the size of the container as visible by the iterator pair thus reflects the size of the chunk, not that of the container.

Thus as an addition to standard STL semenatics, iterator pairs when jointly passed to some STL (or ALP) call must not only be derived from the same container, but must be derived from the same chunk as well.


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