One-dimensional interval [start, end] over a numeric endpoint type.
More...
|
| constexpr | Section () noexcept |
| | Default constructor.
|
| constexpr | Section (const T &min, const T &max) noexcept |
| | Constructs a section with the given bounds.
|
| constexpr T | midpoint () const noexcept |
| | Returns the midpoint of the interval.
|
| constexpr T | length () const noexcept |
| | Returns the length of the interval.
|
| constexpr void | reset () noexcept |
| | Puts the section in reset (empty) state.
|
| constexpr void | expand (const T &value) noexcept |
| | Extends the interval to include value if outside current bounds.
|
| constexpr void | expand (const Section< T > §ion) noexcept |
| | Merges section into this interval (union of two intervals).
|
| constexpr bool | isReset () const noexcept |
| | Returns true if the section is in reset (empty) state.
|
| constexpr bool | isValid () const noexcept |
| | Returns true if the section represents a valid non-empty interval.
|
| constexpr bool | isContains (const T &value) const noexcept |
| | Returns true if value lies inside [start, end] (inclusive).
|
|
| T | start |
| | Lower bound of the interval.
|
| T | end |
| | Upper bound of the interval.
|
template<SectionEndpoint T>
class toy::geometry::Section< T >
One-dimensional interval [start, end] over a numeric endpoint type.
Represents a closed interval on a numeric type. Default-constructed section is in reset (empty) state: start > end, isValid() returns false. Use reset() to clear, or construct with (min, max) for a valid interval.
- Template Parameters
-
Key Features
- Numeric endpoint only: T constrained by toy::geometry::SectionEndpoint (signed integral, floating-point, or fixed-point only; unsigned integral is not allowed).
- Reset state: Empty interval represented by start > end; reset() restores it.
- Expand: expand() extends bounds to include a value or another section (union).
- Constexpr: All operations are constexpr and noexcept where applicable.
Usage Example
s.expand(5);
One-dimensional interval [start, end] over a numeric endpoint type.
Definition section.hpp:95
Umbrella header for the geometry module.
Performance Characteristics
Operations**: O(1). No allocations.
Safety Guarantees
- See also
- operator==(), operator!=()
◆ Section() [1/2]
template<SectionEndpoint T>
◆ Section() [2/2]
template<SectionEndpoint T>
Constructs a section with the given bounds.
- Parameters
-
| min | Lower bound. |
| max | Upper bound. |
◆ expand() [1/2]
template<SectionEndpoint T>
Merges section into this interval (union of two intervals).
- Precondition
- section.isValid() is
true.
- Parameters
-
- Postcondition
- This section contains the union of the previous interval and section.
◆ expand() [2/2]
template<SectionEndpoint T>
Extends the interval to include value if outside current bounds.
- Parameters
-
◆ isContains()
template<SectionEndpoint T>
|
|
nodiscardconstexprnoexcept |
Returns true if value lies inside [start, end] (inclusive).
- Parameters
-
- Returns
true when start <= value <= end.
◆ isReset()
template<SectionEndpoint T>
|
|
nodiscardconstexprnoexcept |
Returns true if the section is in reset (empty) state.
- Returns
true when start > end.
◆ isValid()
template<SectionEndpoint T>
|
|
nodiscardconstexprnoexcept |
Returns true if the section represents a valid non-empty interval.
- Returns
true when start <= end.
◆ length()
template<SectionEndpoint T>
|
|
nodiscardconstexprnoexcept |
Returns the length of the interval.
- Returns
- end - start.
◆ midpoint()
template<SectionEndpoint T>
|
|
nodiscardconstexprnoexcept |
Returns the midpoint of the interval.
- Returns
- (start + end) / 2.
◆ reset()
template<SectionEndpoint T>
Puts the section in reset (empty) state.
- Postcondition
- isReset() is
true, isValid() is false.
◆ end
template<SectionEndpoint T>
Upper bound of the interval.
◆ start
template<SectionEndpoint T>
Lower bound of the interval.
The documentation for this class was generated from the following files: