@@ -402,7 +402,7 @@ func (trie *Trie[T]) String() string {
402
402
return trie .toTrie ().String ()
403
403
}
404
404
405
- // AddedNodesTreeString provides a flattened version of the trie showing only the contained added nodes and their containment structure, which is non-binary.
405
+ // AddedNodesTreeString provides a string showing a flattened version of the trie showing only the contained added nodes and their containment structure, which is non-binary.
406
406
// The root node is included, which may or may not be added.
407
407
func (trie * Trie [T ]) AddedNodesTreeString () string {
408
408
return trie .toTrie ().AddedNodesTreeString ()
@@ -421,12 +421,16 @@ func (trie *Trie[T]) Add(addr T) bool {
421
421
422
422
// AddNode adds the address to this trie.
423
423
// The address must match the same type and version of any existing addresses already in the trie.
424
+ //
425
+ // If the argument is not a single address nor prefix block, this method will panic.
426
+ // The [Partition] type can be used to convert the argument to single addresses and prefix blocks before calling this method.
427
+ //
424
428
// The new or existing node for the address is returned.
425
429
func (trie * Trie [T ]) AddNode (addr T ) * TrieNode [T ] {
426
430
return toAddressTrieNode (trie .addNode (addr ))
427
431
}
428
432
429
- // AddTrie adds nodes for the keys in the trie with the root node as the passed in node .
433
+ // AddTrie adds nodes for the keys from the trie with the argument trie root .
430
434
// AddTrie returns the sub-node in the trie where the added trie begins, where the first node of the added trie is located.
431
435
func (trie * Trie [T ]) AddTrie (added * TrieNode [T ]) * TrieNode [T ] {
432
436
return toAddressTrieNode (trie .addTrie (added .toBase ()))
@@ -564,7 +568,7 @@ func (trie *Trie[T]) GetNode(addr T) *TrieNode[T] {
564
568
// The [Partition] type can be used to convert the argument to single addresses and prefix blocks before calling this method.
565
569
//
566
570
// Use Contains to check for the existence of a given address in the trie,
567
- // as well as GetNode to search for all nodes including those not-added but also auto-generated nodes for subnet blocks.
571
+ // as well as GetNode to search all nodes including those not-added but auto-generated for subnet blocks.
568
572
func (trie * Trie [T ]) GetAddedNode (addr T ) * TrieNode [T ] {
569
573
return toAddressTrieNode [T ](trie .getAddedNode (addr ))
570
574
}
@@ -820,7 +824,7 @@ func (trie *AssociativeTrie[T, V]) String() string {
820
824
return trie .toTrie ().String ()
821
825
}
822
826
823
- // AddedNodesTreeString provides a flattened version of the trie showing only the contained added nodes and their containment structure, which is non-binary.
827
+ // AddedNodesTreeString provides a string showing a flattened version of the trie showing only the contained added nodes and their containment structure, which is non-binary.
824
828
// The root node is included, which may or may not be added.
825
829
func (trie * AssociativeTrie [T , V ]) AddedNodesTreeString () string {
826
830
return trie .toTrie ().AddedNodesTreeString ()
@@ -838,12 +842,16 @@ func (trie *AssociativeTrie[T, V]) Add(addr T) bool {
838
842
}
839
843
840
844
// AddNode adds the address key to this trie.
845
+ //
846
+ // If the argument is not a single address nor prefix block, this method will panic.
847
+ // The [Partition] type can be used to convert the argument to single addresses and prefix blocks before calling this method.
848
+ //
841
849
// The new or existing node for the address is returned.
842
850
func (trie * AssociativeTrie [T , V ]) AddNode (addr T ) * AssociativeTrieNode [T , V ] {
843
851
return toAssociativeTrieNode [T , V ](trie .addNode (addr ))
844
852
}
845
853
846
- // AddTrie adds nodes for the keys in the trie with the root node as the passed in node . To add both keys and values, use PutTrie.
854
+ // AddTrie adds nodes for the keys from the trie with the argument trie root . To add both keys and values, use PutTrie.
847
855
// AddTrie returns the sub-node in the trie where the added trie begins, where the first node of the added trie is located.
848
856
func (trie * AssociativeTrie [T , V ]) AddTrie (added * AssociativeTrieNode [T , V ]) * AssociativeTrieNode [T , V ] {
849
857
return toAssociativeTrieNode [T , V ](trie .addTrie (added .toBase ()))
@@ -938,12 +946,12 @@ func (trie *AssociativeTrie[T, V]) LongestPrefixMatch(addr T) T {
938
946
return trie .longestPrefixMatch (addr )
939
947
}
940
948
941
- // LongestPrefixMatchNode returns the node of the address with the longest matching prefix compared to the provided address.
949
+ // LongestPrefixMatchNode returns the node of the address with the longest matching prefix compared to the provided address, or nil if no matching address .
942
950
func (trie * AssociativeTrie [T , V ]) LongestPrefixMatchNode (addr T ) * AssociativeTrieNode [T , V ] {
943
951
return toAssociativeTrieNode [T , V ](trie .longestPrefixMatchNode (addr ))
944
952
}
945
953
946
- // ShortestPrefixMatch returns the address added to the trie with the shortest matching prefix compared to the provided address, or nil if no matching address.
954
+ // ShortestPrefixMatch returns the node of the address added to the trie with the shortest matching prefix compared to the provided address, or nil if no matching address.
947
955
func (trie * AssociativeTrie [T , V ]) ShortestPrefixMatch (addr T ) T {
948
956
return trie .shortestPrefixMatch (addr )
949
957
}
@@ -1155,22 +1163,22 @@ func (trie *AssociativeTrie[T, V]) DeepEqual(other *AssociativeTrie[T, V]) bool
1155
1163
return trie .toBase ().deepEqual (other .toBase ())
1156
1164
}
1157
1165
1158
- // Put associates the specified value with the specified key in this map .
1166
+ // Put associates the specified value with the specified key in this trie .
1159
1167
//
1160
1168
// If the argument is not a single address nor prefix block, this method will panic.
1161
1169
// The [Partition] type can be used to convert the argument to single addresses and prefix blocks before calling this method.
1162
1170
//
1163
- // If this map previously contained a mapping for a key,
1171
+ // If this trie previously contained a node for the given key,
1164
1172
// the old value is replaced by the specified value, and false is returned along with the old value.
1165
- // If this map did not previously contain a mapping for the key, true is returned along with a nil value.
1166
- // The boolean return value allows you to distinguish whether the address was previously mapped to nil or not mapped at all.
1173
+ // If this trie did not previously contain a mapping for the key, true is returned along with the zero value.
1174
+ // The boolean return value allows you to distinguish whether the address was previously mapped to the zero value or not mapped at all.
1167
1175
func (trie * AssociativeTrie [T , V ]) Put (addr T , value V ) (V , bool ) {
1168
1176
return trie .put (addr , value )
1169
1177
}
1170
1178
1171
- // PutTrie adds nodes for the address keys and values in the trie with the root node as the passed in node . To add only the keys, use AddTrie.
1179
+ // PutTrie adds nodes with the address keys and values from the trie with the argument trie root . To add only the keys, use AddTrie.
1172
1180
//
1173
- // For each added in the given node that does not exist in the trie, a copy of each node will be made,
1181
+ // For each added node from the given trie that does not exist in this trie, a copy will be made,
1174
1182
// the copy including the associated value, and the copy will be inserted into the trie.
1175
1183
//
1176
1184
// The address type/version of the keys must match.
@@ -1246,7 +1254,7 @@ func (trie *AssociativeTrie[T, V]) RemapIfAbsent(addr T, supplier func() V) *Ass
1246
1254
// The [Partition] type can be used to convert the argument to single addresses and prefix blocks before calling this method.
1247
1255
//
1248
1256
// Returns the value for the given key.
1249
- // Returns nil if the contains no mapping for that key or if the mapped value is nil.
1257
+ // Returns nil if the trie contains no mapping for that key or if the mapped value is nil.
1250
1258
func (trie * AssociativeTrie [T , V ]) Get (addr T ) (V , bool ) {
1251
1259
return trie .get (addr )
1252
1260
}
0 commit comments