Back to Arangodb

Range and Slice Storage

3rdParty/boost/1.78.0/libs/numeric/ublas/doc/range.html

3.12.9.14.8 KB
Original Source

Range and Slice Storage

Range<SizeType,DistanceType>

Description

The class range specifies a range of indicies. The range is a sequence of indices from a start value to stop value. The indices increase by one and exlude the stop value. range can therefore be used to specify ranges of elements from vectors and matrices.

Example

#include <boost/numeric/ublas/storage.hpp>

int main () {
    using namespace boost::numeric::ublas;
    range r (0, 3);
    for (unsigned i = 0; i < r.size (); ++ i) {
        std::cout << r (i) << std::endl;
    }
}

Definition

Defined in the header storage.hpp.

Model of

Reversible Container.

Type requirements

None, except for those imposed by the requirements of Reversible Container.

Public base classes

None.

Members

MemberDescription
range (size_type start, size_type stop)Constructs a range of indicies from start to stop (excluded) .
size_type start () constReturns the beginning of the range.
size_type size () constReturns the size of the range.
`const_reference operator [] (size_type i)
const`Returns the value start + i of the i -th element.
range compose (const range &r) constReturns the composite range from `start + r.start
()tostart + r.start () + r.size ()`.
bool operator == (const range &r) constTests two ranges for equality.
bool operator != (const range &r) constTests two ranges for inequality.
const_iterator begin () constReturns a const_iterator pointing to the beginning of the range.
const_iterator end () constReturns a const_iterator pointing to the end of the range.
const_reverse_iterator rbegin () constReturns a const_reverse_iterator pointing to the beginning of the reversed range.
const_reverse_iterator rend () constReturns a const_reverse_iterator pointing to the end of the reversed range.

Preconditions

  • start () <= stop ()

Slice<SizeType,DistanceType>

Description

The class slice specifies a 'slice' of indicies. Slices are more general then ranges, the stride allows the sequence of indicies to increase and decrease by the specified amount between element. slice can therefore be used to specify slices of element from vectors and matrices.

Example

#include <boost/numeric/ublas/storage.hpp>

int main () {
    using namespace boost::numeric::ublas;
    slice s (0, 1, 3);
    for (unsigned i = 0; i < s.size (); ++ i) {
        std::cout << s (i) << std::endl;
    }
}

Definition

Defined in the header storage.hpp.

Model of

Reversible Container.

Type requirements

None, except for those imposed by the requirements of Reversible Container.

Public base classes

None.

Members

MemberDescription
`slice (size_type start, size_type stride, size_type
size)`Constructs a slice start,start+stride,start+2*stride... with size elements.
size_type start () constReturns the beginning of the slice.
size_type stride () constReturns the stride of the slice.
size_type size () constReturns the size of the slice.
`const_reference operator [] (size_type i)
const`Returns the value start + i * stride of the i-th element.
slice compose (const range &r) constReturns the composite slice from `start + stride * r.start
()tostart + stride * (r.start () + r.size ())with stridestride`.
slice compose (const slice &s) constReturns the composite slice from `start + stride * s.start
()tostart + stride * s.stride () * (s.start () +
s.size ())with stridestride * s.stride ()` .
bool operator == (const slice &s) constTests two slices for equality.
bool operator != (const slice &s) constTests two slices for inequality.
const_iterator begin () constReturns a const_iterator pointing to the beginning of the slice.
const_iterator end () constReturns a const_iterator pointing to the end of the slice.
const_reverse_iterator rbegin () constReturns a const_reverse_iterator pointing to the beginning of the reversed slice.
const_reverse_iterator rend () constReturns a const_reverse_iterator pointing to the end of the reversed slice.

Preconditions

  • None all strides are vaild. However when an index is returned or an iterator is dereferenced its value must be representable as the size_type.

Copyright (©) 2000-2004 Michael Stevens, Mathias Koch, Joerg Walter, Gunter Winkler
Use, modification and distribution are subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).