No description
Find a file
dependabot[bot] 72bcf90d12
[chore] : Bump actions/setup-go from 6.0.0 to 6.2.0 (#89)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 6.0.0 to 6.2.0.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](4469467582...7a3fe6cf4c)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-version: 6.2.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-01-21 12:22:17 +05:30
.github [chore] : Bump actions/setup-go from 6.0.0 to 6.2.0 (#89) 2026-01-21 12:22:17 +05:30
.gitignore Initial commit 2015-06-01 21:17:47 +02:00
.go-version IND-2303 ci.yml updated with unit test coverage and linting, .go-version added 2025-02-20 15:15:08 +05:30
.golangci.yml [COMPLIANCE] Add Copyright and License Headers 2025-11-03 13:23:32 +00:00
CHANGELOG.md changelog: add note for v2 2022-12-16 10:55:53 -06:00
edges.go [COMPLIANCE] Update Copyright and License Headers 2025-11-03 13:28:57 +00:00
go.mod [chore] : Bump github.com/hashicorp/golang-lru/v2 from 2.0.0 to 2.0.7 2025-06-06 11:13:44 +05:30
go.sum [chore] : Bump github.com/hashicorp/golang-lru/v2 from 2.0.0 to 2.0.7 2025-06-06 11:13:44 +05:30
iradix.go [COMPLIANCE] Update Copyright and License Headers 2025-11-03 13:28:57 +00:00
iradix_test.go [COMPLIANCE] Update Copyright and License Headers 2025-11-03 13:28:57 +00:00
iter.go [COMPLIANCE] Update Copyright and License Headers 2025-11-03 13:28:57 +00:00
LICENSE [COMPLIANCE] Update Copyright and License Headers 2025-11-03 13:28:57 +00:00
node.go [COMPLIANCE] Update Copyright and License Headers 2025-11-03 13:28:57 +00:00
node_test.go [COMPLIANCE] Update Copyright and License Headers 2025-11-03 13:28:57 +00:00
path_iter.go [COMPLIANCE] Update Copyright and License Headers 2025-11-03 13:28:57 +00:00
path_iter_test.go [COMPLIANCE] Update Copyright and License Headers 2025-11-03 13:28:57 +00:00
raw_iter.go [COMPLIANCE] Update Copyright and License Headers 2025-11-03 13:28:57 +00:00
README.md readme: update noting v2, and fix an example 2022-07-15 09:01:22 -05:00
reverse_iter.go [COMPLIANCE] Update Copyright and License Headers 2025-11-03 13:28:57 +00:00
reverse_iter_test.go [COMPLIANCE] Update Copyright and License Headers 2025-11-03 13:28:57 +00:00

go-immutable-radix Run CI Tests

Provides the iradix package that implements an immutable radix tree. The package only provides a single Tree implementation, optimized for sparse nodes.

As a radix tree, it provides the following:

  • O(k) operations. In many cases, this can be faster than a hash table since the hash function is an O(k) operation, and hash tables have very poor cache locality.
  • Minimum / Maximum value lookups
  • Ordered iteration

A tree supports using a transaction to batch multiple updates (insert, delete) in a more efficient manner than performing each operation one at a time.

For a mutable variant, see go-radix.

V2

The v2 of go-immutable-radix introduces generics to improve compile-time type safety for users of the package. The module name for v2 is github.com/hashicorp/go-immutable-radix/v2.

Documentation

The full documentation is available on Godoc.

Example

Below is a simple example of usage

// Create a tree
r := iradix.New[int]()
r, _, _ = r.Insert([]byte("foo"), 1)
r, _, _ = r.Insert([]byte("bar"), 2)
r, _, _ = r.Insert([]byte("foobar"), 2)

// Find the longest prefix match
m, _, _ := r.Root().LongestPrefix([]byte("foozip"))
if string(m) != "foo" {
    panic("should be foo")
}

Here is an example of performing a range scan of the keys.

// Create a tree
r := iradix.New[int]()
r, _, _ = r.Insert([]byte("001"), 1)
r, _, _ = r.Insert([]byte("002"), 2)
r, _, _ = r.Insert([]byte("005"), 5)
r, _, _ = r.Insert([]byte("010"), 10)
r, _, _ = r.Insert([]byte("100"), 10)

// Range scan over the keys that sort lexicographically between [003, 050)
it := r.Root().Iterator()
it.SeekLowerBound([]byte("003"))
for key, _, ok := it.Next(); ok; key, _, ok = it.Next() {
  if string(key) >= "050" {
      break
  }
  fmt.Println(string(key))
}
// Output:
//  005
//  010