Visible to Intel only — GUID: GUID-E8B13939-45F0-4A80-84A7-4CA14FFF36DC
Visible to Intel only — GUID: GUID-E8B13939-45F0-4A80-84A7-4CA14FFF36DC
bounds_t
Class represents a half-open interval with lower and upper bounds. #include <sdlt/bounds.h>
template<typename LowerT = int, typename UpperT = int>
struct bounds_t
bounds_t holds the lower and upper bounds of a half open interval. It is templated to allow the different representations for the lower and upper bounds. Supported types include fixed<NumberT>, aligned<AlignmentT> and integer values. bounds_t models a valid iteration space over a single dimension.
bounds_t can be used to represent an iteration space over the entire extent of a dimension or to restrict iteration space within the extent. n_bounds_t aggregates a number of bounds_t objects to allow construction of multi-demensional subsections restricting multiple extents.
The class interface is compatible with C++ range-based loops to simplify iteration.
Template Argument |
Description |
---|---|
|
Type of lower bound. Requirements: type is int, or fixed<NumberT>, or aligned<AlignmentT> |
|
Type of upper bound. Requirements: type is int, or fixed<NumberT>, or aligned<AlignmentT> |
Member Types |
Description |
---|---|
|
Type of the lower bound |
|
Type of the upper bound |
|
Iterator type for C++ range-based loops support. |
Member |
Description |
---|---|
|
Effects: Constructs bounds_t with uninitialized lower and upper bounds. |
|
Requirements: (u >= l) Effects: Constructs bounds_t representing the half-open interval [l, u) |
|
Effects: Constructs bounds_t with lower and upper bounds initialized from those of a_other. |
|
Requirements: OtherLowerT and OtherUpperT can legally be converted to lower_type and upper_type. For example it would be illegal to convert an int to fixed<8>(). Effects: Constructs bounds_t with lower and upper bounds initialized from those of a_other. |
|
Effects: Set index of the inclusive lower bound and the index of the exclusive upper bound. |
|
Effects: Set index of the inclusive lower bound |
|
Effects: Set index of the exclusive upper bound |
|
Returns: index of the inclusive lower bound |
|
Returns: index of the exclusive upper bound |
|
Returns: index iterator for the inclusive lower bound. NOTE: C++11 range-based loops require begin() & end() |
|
Returns: index iterator for the exclusive upper bound. NOTE: C++11 range-based loops require begin() & end() |
|
Effects: Determine width of iteration space inside the half open interval between lower() and upper() bounds. Returns: upper() – lower() NOTE: the return type depends on resulting type of a subtraction between the types of upper() and lower(). |
|
Effects: Determine if interval of a_other is entirely contained inside this object’s bounds Returns: (a_other.lower() >= lower() && a_other.upper() <= upper()) |
|
Effects: create a new bounds_t instance with offset added to both lower and upper bounds. Returns: bounds(lower() + offset, upper()+offset) NOTE: The lower_type and upper_type of the returned bound_t maybe different as result of addition of the offset. |
|
Effects: create a new bounds_t instance with offset subtracted from both lower and upper bounds. Returns: bounds(lower() - offset, upper()-offset) NOTE: The lower_type and upper_type of the returned object maybe different as result of subtraction of T. |
|
Effects: Equality comparison with same-typed bounds_t object Returns: (lower() == a_other.lower() && upper() == a_other.upper()) |
|
Effects: Equality comparison with bounds_t object of different lower_type or upper_type. Returns: (lower() == a_other.lower() && upper() == a_other.upper()) |
|
Effects: Inequality comparison with same-typed bounds_t object Returns: (lower() != a_other.lower() || upper() != a_other.upper()) |
|
Effects: Inequality comparison with with bounds_t object of different lower_type or upper_type Returns: (lower() != a_other.lower() || upper() != a_other.upper()) |
Friend Function |
Description |
---|---|
|
Effects: append string representation of bounds_t lower and upper values to a_output_stream Returns: reference to a_output_stream for chained calls |
Range-based loops support
The bounds_t provides begin() and end() methods returning iterators to enable C++11 range-based loops. The may save quite some typing and improve code clarity when iterating over bounds of a multidimensional container.
Compare:
auto ca = image_container.const_access();
auto b0 = bounds_d<0>(ca);
auto b1 = bounds_d<1>(ca);
for (auto y = b0.lower(); y < b0.upper(); ++y)
for (auto x = b1.lower(); x < b1.upper(); ++x) {
RGBAs pixel = ca[y][x];
// …
}
and
auto ca = image_container.const_access();
for (auto y: bounds_d<0>(ca))
for (auto x: bounds_d<1>(ca)) {
RGBAs pixel = ca[y][x];
// …
}
Note that iterator only gives an index value within the bounds, not an object value. It is expected to be used to index into accessors like in example above.