Skip to content

Commit

Permalink
rename the public methods All[46]Sorted
Browse files Browse the repository at this point in the history
All4Sorted -> AllSorted4
All6Sorted -> AllSorted6

API changed, but not yet used in the wild
  • Loading branch information
gaissmai committed Aug 25, 2024
1 parent d4d3220 commit 56f3462
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The child array at each stride level is also popcount compressed.

## API

The API changes in v0.4.2, 0.5.3, v0.6.3, v0.10.1, v0.11.0, v0.12.0
The API has changed in v0.4.2, 0.5.3, v0.6.3, v0.10.1, v0.11.0, v0.12.0, v0.12.6

```golang
import "github.com/gaissmai/bart"
Expand Down Expand Up @@ -65,16 +65,16 @@ The API changes in v0.4.2, 0.5.3, v0.6.3, v0.10.1, v0.11.0, v0.12.0
func (t *Table[V]) Overlaps4(o *Table[V]) bool
func (t *Table[V]) Overlaps6(o *Table[V]) bool

func (t *Table[V]) Supernets(pfx netip.Prefix) func(yield func(netip.Prefix, V) bool)
func (t *Table[V]) Subnets(pfx netip.Prefix) func(yield func(netip.Prefix, V) bool)
func (t *Table[V]) Supernets(pfx netip.Prefix) func(yield func(netip.Prefix, V) bool)

func (t *Table[V]) All() func(yield func(pfx netip.Prefix, val V) bool)
func (t *Table[V]) All4() func(yield func(pfx netip.Prefix, val V) bool)
func (t *Table[V]) All6() func(yield func(pfx netip.Prefix, val V) bool)

func (t *Table[V]) AllSorted() func(yield func(pfx netip.Prefix, val V) bool)
func (t *Table[V]) All4Sorted() func(yield func(pfx netip.Prefix, val V) bool)
func (t *Table[V]) All6Sorted() func(yield func(pfx netip.Prefix, val V) bool)
func (t *Table[V]) AllSorted4() func(yield func(pfx netip.Prefix, val V) bool)
func (t *Table[V]) AllSorted6() func(yield func(pfx netip.Prefix, val V) bool)

func (t *Table[V]) Size() int
func (t *Table[V]) Size4() int
Expand Down
4 changes: 2 additions & 2 deletions example_iter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import (
"github.com/gaissmai/bart"
)

func ExampleTable_All4_rangeoverfunc() {
func ExampleTable_AllSorted4_rangeoverfunc() {
rtbl := new(bart.Table[netip.Addr])
for _, item := range input {
rtbl.Insert(item.cidr, item.nextHop)
}

for pfx, val := range rtbl.All4Sorted() {
for pfx, val := range rtbl.AllSorted4() {
fmt.Printf("%v\t%v\n", pfx, val)
}

Expand Down
4 changes: 2 additions & 2 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ func ExampleTable_Lookup() {
// Lookup: 2001:7c0:3100:1::111 value: 2001:db8::1, ok: true
}

func ExampleTable_All4_callback() {
func ExampleTable_AllSorted4_callback() {
rtbl := new(bart.Table[netip.Addr])
for _, item := range input {
rtbl.Insert(item.cidr, item.nextHop)
}
rtbl.All4Sorted()(func(pfx netip.Prefix, val netip.Addr) bool {
rtbl.AllSorted4()(func(pfx netip.Prefix, val netip.Addr) bool {
fmt.Printf("%v\t%v\n", pfx, val)
return true
})
Expand Down
4 changes: 2 additions & 2 deletions table.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ func (t *Table[V]) Overlaps6(o *Table[V]) bool {

// Union combines two tables, changing the receiver table.
// If there are duplicate entries, the payload of type V is shallow copied from the other table.
// If type V implements the Cloner interface, the values are cloned, see also [Table.Clone].
// If type V implements the [Cloner] interface, the values are cloned, see also [Table.Clone].
func (t *Table[V]) Union(o *Table[V]) {
// nothing to do
if !o.isInit() {
Expand All @@ -579,7 +579,7 @@ func (t *Table[V]) Union(o *Table[V]) {
}

// Clone returns a copy of the routing table.
// The payload of type V is shallow copied, but if type V implements the Cloner interface, the values are cloned.
// The payload of type V is shallow copied, but if type V implements the [Cloner] interface, the values are cloned.
func (t *Table[V]) Clone() *Table[V] {
c := new(Table[V])
if !t.isInit() {
Expand Down
8 changes: 4 additions & 4 deletions table_iter.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,16 @@ func (t *Table[V]) AllSorted() func(yield func(pfx netip.Prefix, val V) bool) {
}
}

// All4Sorted, like [Table.AllSorted] but only for the v4 routing table.
func (t *Table[V]) All4Sorted() func(yield func(pfx netip.Prefix, val V) bool) {
// AllSorted4, like [Table.AllSorted] but only for the v4 routing table.
func (t *Table[V]) AllSorted4() func(yield func(pfx netip.Prefix, val V) bool) {
t.init()
return func(yield func(netip.Prefix, V) bool) {
_ = t.root4.allRecSorted(zeroPath, 0, true, yield)
}
}

// All6Sorted, like [Table.AllSorted] but only for the v6 routing table.
func (t *Table[V]) All6Sorted() func(yield func(pfx netip.Prefix, val V) bool) {
// AllSorted6, like [Table.AllSorted] but only for the v6 routing table.
func (t *Table[V]) AllSorted6() func(yield func(pfx netip.Prefix, val V) bool) {
t.init()
return func(yield func(netip.Prefix, V) bool) {
_ = t.root6.allRecSorted(zeroPath, 0, false, yield)
Expand Down
8 changes: 4 additions & 4 deletions table_iter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func TestAll4SortedIter(t *testing.T) {
}

// rangefunc iterator
for pfx, val := range rtbl.All4Sorted() {
for pfx, val := range rtbl.AllSorted4() {
// check if pfx/val is as expected
if seen[pfx] != val {
t.Errorf("%v got value: %v, expected: %v", pfx, val, seen[pfx])
Expand All @@ -189,7 +189,7 @@ func TestAll4SortedIter(t *testing.T) {

// check if callback stops prematurely
count := 0
for range rtbl.All4Sorted() {
for range rtbl.AllSorted4() {
count++
if count >= 1000 {
break
Expand All @@ -215,7 +215,7 @@ func TestAll6SortedRangeOverFunc(t *testing.T) {
}

// rangefunc iterator
for pfx, val := range rtbl.All6Sorted() {
for pfx, val := range rtbl.AllSorted6() {
// check if pfx/val is as expected
if seen[pfx] != val {
t.Errorf("%v got value: %v, expected: %v", pfx, val, seen[pfx])
Expand All @@ -237,7 +237,7 @@ func TestAll6SortedRangeOverFunc(t *testing.T) {

// check if callback stops prematurely
count := 0
for range rtbl.All6Sorted() {
for range rtbl.AllSorted6() {
count++
if count >= 1000 {
break
Expand Down
4 changes: 2 additions & 2 deletions table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1709,12 +1709,12 @@ func TestSize(t *testing.T) {
var golden4 int
var golden6 int

rtbl.All4Sorted()(func(netip.Prefix, any) bool {
rtbl.AllSorted4()(func(netip.Prefix, any) bool {
golden4++
return true
})

rtbl.All6Sorted()(func(netip.Prefix, any) bool {
rtbl.AllSorted6()(func(netip.Prefix, any) bool {
golden6++
return true
})
Expand Down

0 comments on commit 56f3462

Please sign in to comment.