Skip to content

feat(data-structures/unstable): add Readonly view and clone path to RollingCounter#7234

Open
tomas-zijdemans wants to merge 3 commits into
denoland:mainfrom
tomas-zijdemans:rolling-counter-ready
Open

feat(data-structures/unstable): add Readonly view and clone path to RollingCounter#7234
tomas-zijdemans wants to merge 3 commits into
denoland:mainfrom
tomas-zijdemans:rolling-counter-ready

Conversation

@tomas-zijdemans

Copy link
Copy Markdown
Contributor

Two additive changes, each adopting a pattern already used by sibling data structures.

  • Add ReadonlyRollingCounter, a Pick<> view of the non-mutating members. RollingCounter now implements ReadonlyRollingCounter for a compile-time guarantee. Matches ReadonlyDeque and ReadonlyIndexedHeap.
  • Widen RollingCounter.from() to accept a RollingCounter in addition to a RollingCounterSnapshot. The instance path produces an independent clone with a canonical layout (segments oldest-to-newest, cursor at the last position). Matches Deque.from(deque) and IndexedHeap.from(otherHeap).

No behavior changes for existing call sites.


Note

Recreates #7161, which was closed automatically when I accidentally deleted the head fork. The branch is identical to the original PR head.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant