-
#include "tensorstore/index_space/index_domain_builder.h" -
template <DimensionIndex Rank = dynamic_rank>
class tensorstore::IndexDomainBuilder; Builder class for creating an IndexDomain.
The rank may be specified either at compile time, as a template parameter, or at runtime, as a constructor parameter.
This behaves exactly like
IndexTransformBuilderwith an output rank of 0, except thatFinalizereturns anIndexDomainrather than anIndexTransform.Examples
IndexDomain<2> t = IndexDomainBuilder<2>() .origin({1, 2}) .shape({3, 4}) .labels({"x", "y"}) .Finalize() .value(); IndexDomain<> t = IndexDomainBuilder() .origin({1, 2, 3}) .exclusive_max({4, 5, 6}) .Finalize() .value();Constructors¶
- IndexDomainBuilder(std::nullptr_t);
Constructs an invalid
IndexDomainBuilder.
- IndexDomainBuilder(DimensionIndex rank);
-
IndexDomainBuilder(
std::integral_constant<DimensionIndex, R> rank = {}); Constructs a valid
IndexDomainBuilderwith the specified rank.
Methods¶
- bool valid() const;
Returns
trueif this is a valid, initialized builder.
- StaticOrDynamicRank<Rank> rank() const;
Returns the rank. :pre:
valid() == true
- span<Index, Rank> origin();
Returns the mutable
originvector, and marks theoriginas having been set.
- IndexDomainBuilder& origin(const Indices& indices);
- IndexDomainBuilder& origin(const Index (&indices)[N]);
Sets the
originvector to the specified value.
- span<Index, Rank> shape();
Returns the mutable
shapevector, and marks the upper bound as having been set.
- IndexDomainBuilder& shape(const Indices& indices);
- IndexDomainBuilder& shape(const Index (&indices)[N]);
Sets the
shapevector to the specified value. Specify a value ofkInfSizeto indicate an unbounded (infinite) upper bound.
- span<Index, Rank> exclusive_max();
Returns the mutable
exclusive_maxvector, and marks the upper bound as having been set.
- IndexDomainBuilder& exclusive_max(const Indices& indices);
- IndexDomainBuilder& exclusive_max(const Index (&indices)[N]);
Specifies the exclusive upper bounds of the input domain. Specify a value of
kInfIndex + 1to indicate an unbounded (infinite) upper bound.
- span<Index, Rank> inclusive_max();
Returns the mutable
inclusive_maxvector, and marks the upper bound as having been set.
- IndexDomainBuilder& inclusive_max(const Indices& indices);
- IndexDomainBuilder& inclusive_max(const Index (&indices)[N]);
Specifies the inclusive upper bounds. Specify a value of
kInfIndexto indicate an unbounded (infinite) upper bound.
- IndexDomainBuilder& bounds(const BoxLike& box);
Specifies the lower and upper bounds.
- MutableBoxView<Rank> bounds();
Returns the mutable
boundsbox, and marks the lower and upper bounds as having been set.
- IndexDomainBuilder& domain(IndexDomainView<Rank> domain);
Copies an existing domain. Individual parts of the domain may then be overridden by calling other methods.
- IndexDomainBuilder& labels(const Labels& labels);
- IndexDomainBuilder& labels(const std::string_view (&labels)[N]);
Sets the
labelsvector to the specified value.
- DimensionSet& implicit_lower_bounds();
Returns the mutable
implicit_lower_boundsbit vector, and marks it as having been set.
- IndexDomainBuilder& implicit_lower_bounds(DimensionSet x);
- IndexDomainBuilder& implicit_lower_bounds(const bool (&x)[N]);
Sets the
implicit_lower_boundsbit-vector to the specified value.
- DimensionSet& implicit_upper_bounds();
Returns the mutable
implicit_upper_boundsbit vector, and marks it as having been set.
- IndexDomainBuilder& implicit_upper_bounds(DimensionSet x);
- IndexDomainBuilder& implicit_upper_bounds(const bool (&x)[N]);
Sets the
implicit_upper_boundsbit-vector to the specified value.
- Result<IndexDomain<Rank>> Finalize();
Validates and returns the specified index domain.