Skip to content

Introduce bounds-based ranges, directional iterators, and Entry API updates; add docs/tests#1

Merged
leaxoy merged 1 commit into
mainfrom
codex/optimize-project-comments-for-consistency
Mar 5, 2026
Merged

Introduce bounds-based ranges, directional iterators, and Entry API updates; add docs/tests#1
leaxoy merged 1 commit into
mainfrom
codex/optimize-project-comments-for-consistency

Conversation

@leaxoy
Copy link
Copy Markdown
Contributor

@leaxoy leaxoy commented Mar 5, 2026

Motivation

  • Introduce a composable range abstraction and unify range/iteration APIs across ordered containers using explicit direction suffixes (Asc/Desc).
  • Align Entry APIs across map-like types to a consistent upsert/delete contract that returns the previous value and existence flag, and add Delete helpers.
  • Add repository-wide contributor guidance and agent instructions, and refresh README examples to reflect the new APIs.

Description

  • Add a new bound package implementing Bound, RangeBounds and helpers (NewIncluded, NewExcluded, NewUnbounded) and Contains/IsValid semantics for comparator-based ranges, and add bound unit tests (bound/bound_test.go).
  • Replace legacy range and iterator signatures with directional and bounds-based variants across ordered containers, e.g. Iter() -> IterAsc()/IterDesc(), Range(lower, upper) -> RangeAsc(bounds)/RangeDesc(bounds), and matching mutable variants like IterMutAsc/IterMutDesc and RangeMutAsc/RangeMutDesc (changes applied to btree, btreemap, btreeset, skipmap, skipset, etc.).
  • Standardize Entry.Insert to return (old V, existed bool) and add Entry.Delete() for hashmap, btreemap, skipmap, trie and related entry implementations, and update underlying Insert/insert helpers to route through the Entry logic where applicable.
  • API and utility updates: export bound aliases and helpers from ds.go (Bound, RangeBounds, NewRangeBounds), add GetComparator on BTreeMap, add Equal helpers on sets, update many iterators/Range callers in tests and code to use the new bound API, and refresh README.md, CONTRIBUTING.md, and AGENTS.md to document conventions.

Testing

  • Reformatted code with gofmt -w as part of changes and updated examples and tests to the new APIs.
  • Ran the unit test suite with go test ./..., and all automated tests succeeded.

Codex Task

@leaxoy leaxoy merged commit 1bcebe3 into main Mar 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant