Class Slice

Class Documentation

class Slice

Represents a forwards linear sequence of indexes for some arbitrary collection. Python equivalent is the slice operator [start:end:interval]. Eigen equivalent is Eigen::seq(start, end, interval). Matlab equivalent is slice operator (start:interval:end)

Note

No support for reverse order, e.g. (end:0:-1)

Public Functions

Slice() = default
Slice(boost::optional<int64_t> interval)
Slice(boost::optional<int64_t> start, boost::optional<int64_t> end)
Slice(boost::optional<int64_t> start, boost::optional<int64_t> end, boost::optional<int64_t> interval)
inline boost::optional<int64_t> GetStart() const

Gets the starting index of an arbitrary collection slice. -1 represents the end of the collection. none represents the element after the end of the collection.

inline boost::optional<int64_t> GetEnd() const

Gets the end exclusive index of an arbitrary collection slice. -1 represents the end of the collection. none represents the element after the end of the collection.

inline boost::optional<int64_t> GetInterval() const

Gets the interval betweeen indices of an arbitrary collection slice. none represents the length of the collection.

template<typename T>
inline Range<T> Evaluate(T collectionSize) const

Evaluates a slice from an arbirary index range to a positive integer index range for use with C++ collections.

Template Parameters:

T – integer type

Parameters:

collectionSize – size of the collection that to evaluate against

Returns:

Range<T>

Public Static Functions

static inline Slice First()
static inline Slice Last()
static inline Slice Each()
static inline Slice All()