Skip to content

Implement LongSpan<T> constructor and indexed access #9

Description

@coderabbitai

Summary

Implement the missing runtime functionality for LongSpan<T>.

Required changes

Update src/LongSpan.cs so that LongSpan<T> can represent and expose a valid memory range.

  • Add a constructor that initializes _reference and Length.
  • Add a bounds-checked indexer.
  • Return indexed elements by using Unsafe.Add(ref _reference, index).
  • Preserve IsEmpty as a check of Length.

Rationale

The current type has no constructor or element accessor. _reference and Length therefore cannot be initialized for useful instances, and callers cannot access span elements.

Affected area

  • src/LongSpan.cs

Acceptance criteria

  • LongSpan<T> initializes its reference and length through a public constructor.
  • The indexer returns the element at a valid index.
  • The indexer rejects indexes below zero and indexes greater than or equal to Length.
  • IsEmpty remains true only when Length is zero.

Backlinks

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions