Update dependencies

This commit is contained in:
bluepython508
2025-04-09 01:00:12 +01:00
parent f0641ffd6e
commit 5a9cfc022c
882 changed files with 68930 additions and 24201 deletions

View File

@@ -1,8 +1,8 @@
package bart
// Copyright (c) 2024 Karl Gaissmaier
// SPDX-License-Identifier: MIT
package bart
import (
"encoding/json"
"net/netip"
@@ -19,7 +19,9 @@ type DumpListNode[V any] struct {
// MarshalJSON dumps the table into two sorted lists: for ipv4 and ipv6.
// Every root and subnet is an array, not a map, because the order matters.
func (t *Table[V]) MarshalJSON() ([]byte, error) {
t.init()
if t == nil {
return nil, nil
}
result := struct {
Ipv4 []DumpListNode[V] `json:"ipv4,omitempty"`
@@ -40,24 +42,27 @@ func (t *Table[V]) MarshalJSON() ([]byte, error) {
// DumpList4 dumps the ipv4 tree into a list of roots and their subnets.
// It can be used to analyze the tree or build custom json representation.
func (t *Table[V]) DumpList4() []DumpListNode[V] {
t.init()
if t.rootV4 == nil {
if t == nil {
return nil
}
return t.rootV4.dumpListRec(0, zeroPath, 0, true)
return t.root4.dumpListRec(0, stridePath{}, 0, true)
}
// DumpList6 dumps the ipv6 tree into a list of roots and their subnets.
// It can be used to analyze the tree or build custom json representation.
func (t *Table[V]) DumpList6() []DumpListNode[V] {
t.init()
if t.rootV6 == nil {
if t == nil {
return nil
}
return t.rootV6.dumpListRec(0, zeroPath, 0, false)
return t.root6.dumpListRec(0, stridePath{}, 0, false)
}
func (n *node[V]) dumpListRec(parentIdx uint, path [16]byte, depth int, is4 bool) []DumpListNode[V] {
func (n *node[V]) dumpListRec(parentIdx uint, path stridePath, depth int, is4 bool) []DumpListNode[V] {
// recursion stop condition
if n == nil {
return nil
}
directKids := n.getKidsRec(parentIdx, path, depth, is4)
slices.SortFunc(directKids, cmpKidByPrefix[V])