Stratax
Scientific computing containers and operations
Loading...
Searching...
No Matches
Slice

Developer notes for include/stratax/core/Slice.hpp.

Purpose

Represents a half-open range used by slicing operations.

Main API

Constructor

  • Slice(start, stop)

Metadata

  • start()
  • stop()
  • size()
  • empty()

Comparison

  • operator==
  • operator!=

Invariants

  • Slices are half-open ranges: [start, stop).
  • start() <= stop() after construction.
  • size() == stop() - start().
  • empty() is true exactly when start() == stop().

Validation Notes

  • Slices are half-open: [start, stop).
  • start > stop is invalid and throws Exceptions::IndexError.
  • Empty slices are valid when start == stop.

Implementation Notes

  • size() is stop - start.
  • Constructor validation prevents unsigned underflow in size().
  • Slice bounds against a container are checked by ops-level slicing code.

Time Complexity

  • Construction, metadata access, size(), empty(), equality, and inequality are O(1).

Future Work

  • Add optional step support.
  • Consider signed indexes only if negative indexing becomes part of the API.