| 1 | // Copyright 2021 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package trie_testscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/ |
| 6 | |
| 7 | import ( |
| 8 | "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/" |
| 9 | "math/randscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/" |
| 10 | "reflectscip-go gomod github.com/golang/go/src go1.25.0 reflect/" |
| 11 | "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/" |
| 12 | "timescip-go gomod github.com/golang/go/src go1.25.0 time/" |
| 13 | |
| 14 | "golang.org/x/tools/go/callgraph/vta/internal/triescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/" |
| 15 | "mapsscip-go gomod github.com/golang/go/src go1.25.0 maps/" |
| 16 | ) |
| 17 | |
| 18 | // This file tests trie.Map by cross checking operations on a collection of |
| 19 | // trie.Map's against a collection of map[uint64]interface{}. This includes |
| 20 | // both limited fuzz testing for correctness and benchmarking. |
| 21 | |
| 22 | // mapCollection is effectively a []map[uint64]interface{}. |
| 23 | // These support operations being applied to the i'th maps. |
| 24 | type mapCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection# interface { |
| 25 | Elementsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection#Elements.() []map[uint64]any |
| 26 | |
| 27 | DeepEqualscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection#DeepEqual.(l, r int) bool |
| 28 | Lookupscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection#Lookup.(id int, k uint64) (any, bool) |
| 29 | |
| 30 | Insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection#Insert.(id int, k uint64, v any) |
| 31 | Updatescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection#Update.(id int, k uint64, v any) |
| 32 | Removescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection#Remove.(id int, k uint64) |
| 33 | Intersectscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection#Intersect.(l int, r int) |
| 34 | Mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection#Merge.(l int, r int) |
| 35 | Clearscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection#Clear.(id int) |
| 36 | |
| 37 | Averagescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection#Average.(l int, r int) |
| 38 | Assignscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection#Assign.(l int, r int) |
| 39 | } |
| 40 | |
| 41 | // opCode of an operation. |
| 42 | type opCodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/opCode# int |
| 43 | |
| 44 | const ( |
| 45 | deepEqualsOpscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/deepEqualsOp. opCodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/opCode# = iota |
| 46 | lookupOpscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/lookupOp. |
| 47 | insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/insert. |
| 48 | updatescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/update. |
| 49 | removescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/remove. |
| 50 | mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/merge. |
| 51 | intersectscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/intersect. |
| 52 | clearscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/clear. |
| 53 | takeAveragescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/takeAverage. |
| 54 | assignscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/assign. |
| 55 | ) |
| 56 | |
| 57 | func (op opCodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/opCode#) Stringscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/opCode#String().() string { |
| 58 | switch op { |
| 59 | case deepEqualsOpscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/deepEqualsOp.: |
| 60 | return "DE" |
| 61 | case lookupOpscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/lookupOp.: |
| 62 | return "LO" |
| 63 | case insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/insert.: |
| 64 | return "IN" |
| 65 | case updatescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/update.: |
| 66 | return "UP" |
| 67 | case removescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/remove.: |
| 68 | return "RE" |
| 69 | case mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/merge.: |
| 70 | return "ME" |
| 71 | case intersectscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/intersect.: |
| 72 | return "IT" |
| 73 | case clearscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/clear.: |
| 74 | return "CL" |
| 75 | case takeAveragescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/takeAverage.: |
| 76 | return "AV" |
| 77 | case assignscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/assign.: |
| 78 | return "AS" |
| 79 | default: |
| 80 | return "??" |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | // A mapCollection backed by MutMaps. |
| 85 | type trieCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection# struct { |
| 86 | bscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#b. *triescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/.Builderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder# |
| 87 | triesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#tries. []triescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/.MutMapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap# |
| 88 | } |
| 89 | |
| 90 | func (c *trieCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#) Elementsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#Elements().() []map[uint64]any { |
| 91 | var maps []map[uint64]any |
| 92 | for _, m := range c.triesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#tries. { |
| 93 | maps = append(maps, triescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/.Elemsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Elems().(m.Mscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#M.)) |
| 94 | } |
| 95 | return maps |
| 96 | } |
| 97 | func (c *trieCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#) Eqscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#Eq().(id int, m map[uint64]any) bool { |
| 98 | elems := triescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/.Elemsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Elems().(c.triesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#tries.[id].Mscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#M.) |
| 99 | return !reflectscip-go gomod github.com/golang/go/src go1.25.0 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.25.0 reflect/DeepEqual().(elems, m) |
| 100 | } |
| 101 | |
| 102 | func (c *trieCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#) Lookupscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#Lookup().(id int, k uint64) (any, bool) { |
| 103 | return c.triesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#tries.[id].Mscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#M..Lookupscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#Lookup().(k) |
| 104 | } |
| 105 | func (c *trieCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#) DeepEqualscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#DeepEqual().(l, r int) bool { |
| 106 | return c.triesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#tries.[l].Mscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#M..DeepEqualscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Map#DeepEqual().(c.triesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#tries.[r].Mscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#M.) |
| 107 | } |
| 108 | |
| 109 | func (c *trieCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#) Addscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#Add().() { |
| 110 | c.triesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#tries. = append(c.triesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#tries., c.bscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#b..MutEmptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#MutEmpty().()) |
| 111 | } |
| 112 | |
| 113 | func (c *trieCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#) Insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#Insert().(id int, k uint64, v any) { |
| 114 | c.triesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#tries.[id].Insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#Insert().(k, v) |
| 115 | } |
| 116 | |
| 117 | func (c *trieCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#) Updatescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#Update().(id int, k uint64, v any) { |
| 118 | c.triesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#tries.[id].Updatescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#Update().(k, v) |
| 119 | } |
| 120 | |
| 121 | func (c *trieCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#) Removescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#Remove().(id int, k uint64) { |
| 122 | c.triesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#tries.[id].Removescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#Remove().(k) |
| 123 | } |
| 124 | |
| 125 | func (c *trieCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#) Intersectscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#Intersect().(l int, r int) { |
| 126 | c.triesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#tries.[l].Intersectscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#Intersect().(c.triesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#tries.[r].Mscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#M.) |
| 127 | } |
| 128 | |
| 129 | func (c *trieCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#) Mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#Merge().(l int, r int) { |
| 130 | c.triesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#tries.[l].Mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#Merge().(c.triesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#tries.[r].Mscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#M.) |
| 131 | } |
| 132 | |
| 133 | func (c *trieCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#) Averagescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#Average().(l int, r int) { |
| 134 | c.triesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#tries.[l].MergeWithscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#MergeWith().(averagescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/average()., c.triesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#tries.[r].Mscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#M.) |
| 135 | } |
| 136 | |
| 137 | func (c *trieCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#) Clearscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#Clear().(id int) { |
| 138 | c.triesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#tries.[id] = c.bscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#b..MutEmptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#MutEmpty().() |
| 139 | } |
| 140 | func (c *trieCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#) Assignscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#Assign().(l, r int) { |
| 141 | c.triesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#tries.[l] = c.triesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#tries.[r] |
| 142 | } |
| 143 | |
| 144 | func averagescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/average().(x any, y any) any { |
| 145 | if x, ok := x.(float32); ok { |
| 146 | if y, ok := y.(float32); ok { |
| 147 | return (x + y) / 2.0 |
| 148 | } |
| 149 | } |
| 150 | return x |
| 151 | } |
| 152 | |
| 153 | type builtinCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/builtinCollection# []map[uint64]any |
| 154 | |
| 155 | func (c builtinCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/builtinCollection#) Elementsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/builtinCollection#Elements().() []map[uint64]any { |
| 156 | return c |
| 157 | } |
| 158 | |
| 159 | func (c builtinCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/builtinCollection#) Lookupscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/builtinCollection#Lookup().(id int, k uint64) (any, bool) { |
| 160 | v, ok := c[id][k] |
| 161 | return v, ok |
| 162 | } |
| 163 | func (c builtinCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/builtinCollection#) DeepEqualscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/builtinCollection#DeepEqual().(l, r int) bool { |
| 164 | return reflectscip-go gomod github.com/golang/go/src go1.25.0 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.25.0 reflect/DeepEqual().(c[l], c[r]) |
| 165 | } |
| 166 | |
| 167 | func (c builtinCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/builtinCollection#) Insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/builtinCollection#Insert().(id int, k uint64, v any) { |
| 168 | if _, ok := c[id][k]; !ok { |
| 169 | c[id][k] = v |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | func (c builtinCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/builtinCollection#) Updatescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/builtinCollection#Update().(id int, k uint64, v any) { |
| 174 | c[id][k] = v |
| 175 | } |
| 176 | |
| 177 | func (c builtinCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/builtinCollection#) Removescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/builtinCollection#Remove().(id int, k uint64) { |
| 178 | delete(c[id], k) |
| 179 | } |
| 180 | |
| 181 | func (c builtinCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/builtinCollection#) Intersectscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/builtinCollection#Intersect().(l int, r int) { |
| 182 | result := map[uint64]any{} |
| 183 | for k, v := range c[l] { |
| 184 | if _, ok := c[r][k]; ok { |
| 185 | result[k] = v |
| 186 | } |
| 187 | } |
| 188 | c[l] = result |
| 189 | } |
| 190 | |
| 191 | func (c builtinCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/builtinCollection#) Mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/builtinCollection#Merge().(l int, r int) { |
| 192 | result := map[uint64]any{} |
| 193 | mapsscip-go gomod github.com/golang/go/src go1.25.0 maps/.Copyscip-go gomod github.com/golang/go/src go1.25.0 maps/Copy().(result, c[r]) |
| 194 | mapsscip-go gomod github.com/golang/go/src go1.25.0 maps/.Copyscip-go gomod github.com/golang/go/src go1.25.0 maps/Copy().(result, c[l]) |
| 195 | c[l] = result |
| 196 | } |
| 197 | |
| 198 | func (c builtinCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/builtinCollection#) Averagescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/builtinCollection#Average().(l int, r int) { |
| 199 | avg := map[uint64]any{} |
| 200 | for k, lv := range c[l] { |
| 201 | if rv, ok := c[r][k]; ok { |
| 202 | avg[k] = averagescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/average().(lv, rv) |
| 203 | } else { |
| 204 | avg[k] = lv // add elements just in l |
| 205 | } |
| 206 | } |
| 207 | for k, rv := range c[r] { |
| 208 | if _, ok := c[l][k]; !ok { |
| 209 | avg[k] = rv // add elements just in r |
| 210 | } |
| 211 | } |
| 212 | c[l] = avg |
| 213 | } |
| 214 | |
| 215 | func (c builtinCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/builtinCollection#) Assignscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/builtinCollection#Assign().(l, r int) { |
| 216 | m := map[uint64]any{} |
| 217 | mapsscip-go gomod github.com/golang/go/src go1.25.0 maps/.Copyscip-go gomod github.com/golang/go/src go1.25.0 maps/Copy().(m, c[r]) |
| 218 | c[l] = m |
| 219 | } |
| 220 | |
| 221 | func (c builtinCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/builtinCollection#) Clearscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/builtinCollection#Clear().(id int) { |
| 222 | c[id] = map[uint64]any{} |
| 223 | } |
| 224 | |
| 225 | func newTriesCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/newTriesCollection().(size int) *trieCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection# { |
| 226 | tc := &trieCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#{ |
| 227 | bscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#b.: triescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/.NewBuilderscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/NewBuilder().(), |
| 228 | triesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#tries.: make([]triescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/.MutMapscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/MutMap#, size), |
| 229 | } |
| 230 | for i := range size { |
| 231 | tc.triesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#tries.[i] = tc.bscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/trieCollection#b..MutEmptyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie`/Builder#MutEmpty().() |
| 232 | } |
| 233 | return tc |
| 234 | } |
| 235 | |
| 236 | func newMapsCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/newMapsCollection().(size int) *builtinCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/builtinCollection# { |
| 237 | maps := make(builtinCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/builtinCollection#, size) |
| 238 | for i := range size { |
| 239 | maps[i] = map[uint64]any{} |
| 240 | } |
| 241 | return &maps |
| 242 | } |
| 243 | |
| 244 | // operation on a map collection. |
| 245 | type operationscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation# struct { |
| 246 | codescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#code. opCodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/opCode# |
| 247 | lscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#l., rscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#r. int |
| 248 | kscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#k. uint64 |
| 249 | vscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#v. float32 |
| 250 | } |
| 251 | |
| 252 | // Apply the operation to maps. |
| 253 | func (op operationscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#) Applyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#Apply().(maps mapCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection#) any { |
| 254 | type lookupresult struct { |
| 255 | v any |
| 256 | ok bool |
| 257 | } |
| 258 | switch op.codescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#code. { |
| 259 | case deepEqualsOpscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/deepEqualsOp.: |
| 260 | return maps.DeepEqualscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection#DeepEqual.(op.lscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#l., op.rscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#r.) |
| 261 | case lookupOpscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/lookupOp.: |
| 262 | v, ok := maps.Lookupscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection#Lookup.(op.lscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#l., op.kscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#k.) |
| 263 | return lookupresult{v, ok} |
| 264 | case insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/insert.: |
| 265 | maps.Insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection#Insert.(op.lscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#l., op.kscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#k., op.vscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#v.) |
| 266 | case updatescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/update.: |
| 267 | maps.Updatescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection#Update.(op.lscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#l., op.kscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#k., op.vscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#v.) |
| 268 | case removescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/remove.: |
| 269 | maps.Removescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection#Remove.(op.lscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#l., op.kscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#k.) |
| 270 | case mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/merge.: |
| 271 | maps.Mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection#Merge.(op.lscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#l., op.rscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#r.) |
| 272 | case intersectscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/intersect.: |
| 273 | maps.Intersectscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection#Intersect.(op.lscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#l., op.rscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#r.) |
| 274 | case clearscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/clear.: |
| 275 | maps.Clearscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection#Clear.(op.lscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#l.) |
| 276 | case takeAveragescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/takeAverage.: |
| 277 | maps.Averagescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection#Average.(op.lscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#l., op.rscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#r.) |
| 278 | case assignscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/assign.: |
| 279 | maps.Assignscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection#Assign.(op.lscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#l., op.rscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#r.) |
| 280 | } |
| 281 | return nil |
| 282 | } |
| 283 | |
| 284 | // Returns a collection of op codes with dist[op] copies of op. |
| 285 | func distributionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/distribution().(dist map[opCodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/opCode#]int) []opCodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/opCode# { |
| 286 | var codes []opCodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/opCode# |
| 287 | for op, n := range dist { |
| 288 | for range n { |
| 289 | codes = append(codes, op) |
| 290 | } |
| 291 | } |
| 292 | return codes |
| 293 | } |
| 294 | |
| 295 | // options for generating a random operation. |
| 296 | type optionsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options# struct { |
| 297 | mapsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options#maps. int |
| 298 | maxKeyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options#maxKey. uint64 |
| 299 | maxValscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options#maxVal. int |
| 300 | codesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options#codes. []opCodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/opCode# |
| 301 | } |
| 302 | |
| 303 | // returns a random operation using r as a source of randomness. |
| 304 | func randOperatorscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/randOperator().(r *randscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/.Randscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#, opts optionsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options#) operationscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation# { |
| 305 | id := func() int { return r.Intnscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#Intn().(opts.mapsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options#maps.) } |
| 306 | key := func() uint64 { return r.Uint64scip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#Uint64().() % opts.maxKeyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options#maxKey. } |
| 307 | val := func() float32 { return float32(r.Intnscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#Intn().(opts.maxValscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options#maxVal.)) } |
| 308 | switch code := opts.codesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options#codes.[r.Intnscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#Intn().(len(opts.codesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options#codes.))]; code { |
| 309 | case lookupOpscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/lookupOp., removescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/remove.: |
| 310 | return operationscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#{codescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#code.: code, lscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#l.: id(), kscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#k.: key()} |
| 311 | case insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/insert., updatescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/update.: |
| 312 | return operationscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#{codescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#code.: code, lscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#l.: id(), kscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#k.: key(), vscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#v.: val()} |
| 313 | case deepEqualsOpscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/deepEqualsOp., mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/merge., intersectscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/intersect., takeAveragescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/takeAverage., assignscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/assign.: |
| 314 | return operationscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#{codescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#code.: code, lscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#l.: id(), rscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#r.: id()} |
| 315 | case clearscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/clear.: |
| 316 | return operationscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#{codescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#code.: code, lscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#l.: id()} |
| 317 | default: |
| 318 | panic("Invalid op code") |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | func randOperatorsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/randOperators().(r *randscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/.Randscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/Rand#, numops int, opts optionsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options#) []operationscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation# { |
| 323 | ops := make([]operationscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#, numops) |
| 324 | for i := range numops { |
| 325 | ops[i] = randOperatorscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/randOperator().(r, opts) |
| 326 | } |
| 327 | return ops |
| 328 | } |
| 329 | |
| 330 | // TestOperations applies a series of random operations to collection of |
| 331 | // trie.MutMaps and map[uint64]interface{}. It tests for the maps being equal. |
| 332 | func TestOperationsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/TestOperations().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 333 | seed := timescip-go gomod github.com/golang/go/src go1.25.0 time/.Nowscip-go gomod github.com/golang/go/src go1.25.0 time/Now().().UnixNanoscip-go gomod github.com/golang/go/src go1.25.0 time/Time#UnixNano().() |
| 334 | s := randscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/.NewSourcescip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/NewSource().(seed) |
| 335 | r := randscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/.Newscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/New().(s) |
| 336 | t.Logscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Log().("seed: ", seed) |
| 337 | |
| 338 | size := 10 |
| 339 | N := 100000 |
| 340 | ops := randOperatorsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/randOperators().(r, N, optionsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options#{ |
| 341 | mapsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options#maps.: size, |
| 342 | maxKeyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options#maxKey.: 128, |
| 343 | maxValscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options#maxVal.: 100, |
| 344 | codesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options#codes.: distributionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/distribution().(map[opCodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/opCode#]int{ |
| 345 | deepEqualsOpscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/deepEqualsOp.: 1, |
| 346 | lookupOpscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/lookupOp.: 10, |
| 347 | insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/insert.: 10, |
| 348 | updatescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/update.: 10, |
| 349 | removescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/remove.: 10, |
| 350 | mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/merge.: 10, |
| 351 | intersectscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/intersect.: 10, |
| 352 | clearscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/clear.: 2, |
| 353 | takeAveragescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/takeAverage.: 5, |
| 354 | assignscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/assign.: 5, |
| 355 | }), |
| 356 | }) |
| 357 | |
| 358 | var tries mapCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection# = newTriesCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/newTriesCollection().(size) |
| 359 | var maps mapCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection# = newMapsCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/newMapsCollection().(size) |
| 360 | check := func() error { |
| 361 | if got, want := tries.Elementsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection#Elements.(), maps.Elementsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection#Elements.(); !reflectscip-go gomod github.com/golang/go/src go1.25.0 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.25.0 reflect/DeepEqual().(got, want) { |
| 362 | return fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("elements of tries and maps and tries differed. got %v want %v", got, want) |
| 363 | } |
| 364 | return nil |
| 365 | } |
| 366 | |
| 367 | for i, op := range ops { |
| 368 | got, want := op.Applyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#Apply().(tries), op.Applyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#Apply().(maps) |
| 369 | if got != want { |
| 370 | t.Errorfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Errorf().("op[%d]: (%v).Apply(%v) != (%v).Apply(%v). got %v want %v", |
| 371 | i, op, tries, op, maps, got, want) |
| 372 | } |
| 373 | } |
| 374 | if err := check(); err != nil { |
| 375 | t.Errorfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Errorf().("%d operators failed with %s", size, err) |
| 376 | t.Logscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Log().("Rerunning with more checking") |
| 377 | tries, maps = newTriesCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/newTriesCollection().(size), newMapsCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/newMapsCollection().(size) |
| 378 | for i, op := range ops { |
| 379 | op.Applyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#Apply().(tries) |
| 380 | op.Applyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#Apply().(maps) |
| 381 | if err := check(); err != nil { |
| 382 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatalf().("Failed first on op[%d]=%v: %v", i, op, err) |
| 383 | } |
| 384 | } |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | func runscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/run().(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#, opts optionsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options#, seed int64, mk func(int) mapCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection#) { |
| 389 | r := randscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/.Newscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/New().(randscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/.NewSourcescip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/NewSource().(seed)) |
| 390 | ops := randOperatorsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/randOperators().(r, b.Nscip-go gomod github.com/golang/go/src go1.25.0 testing/B#N., opts) |
| 391 | maps := mk(opts.mapsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options#maps.) |
| 392 | for _, op := range ops { |
| 393 | op.Applyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/operation#Apply().(maps) |
| 394 | } |
| 395 | } |
| 396 | |
| 397 | var standardscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/standard. optionsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options# = optionsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options#{ |
| 398 | mapsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options#maps.: 10, |
| 399 | maxKeyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options#maxKey.: 128, |
| 400 | maxValscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options#maxVal.: 100, |
| 401 | codesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options#codes.: distributionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/distribution().(map[opCodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/opCode#]int{ |
| 402 | deepEqualsOpscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/deepEqualsOp.: 1, |
| 403 | lookupOpscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/lookupOp.: 20, |
| 404 | insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/insert.: 20, |
| 405 | updatescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/update.: 20, |
| 406 | removescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/remove.: 20, |
| 407 | mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/merge.: 10, |
| 408 | intersectscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/intersect.: 10, |
| 409 | clearscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/clear.: 1, |
| 410 | takeAveragescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/takeAverage.: 5, |
| 411 | assignscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/assign.: 20, |
| 412 | }), |
| 413 | } |
| 414 | |
| 415 | func BenchmarkTrieStandardscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/BenchmarkTrieStandard().(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) { |
| 416 | runscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/run().(b, standardscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/standard., 123, func(size int) mapCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection# { |
| 417 | return newTriesCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/newTriesCollection().(size) |
| 418 | }) |
| 419 | } |
| 420 | |
| 421 | func BenchmarkMapsStandardscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/BenchmarkMapsStandard().(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) { |
| 422 | runscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/run().(b, standardscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/standard., 123, func(size int) mapCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection# { |
| 423 | return newMapsCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/newMapsCollection().(size) |
| 424 | }) |
| 425 | } |
| 426 | |
| 427 | var smallWidescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/smallWide. optionsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options# = optionsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options#{ |
| 428 | mapsscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options#maps.: 100, |
| 429 | maxKeyscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options#maxKey.: 100, |
| 430 | maxValscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options#maxVal.: 8, |
| 431 | codesscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/options#codes.: distributionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/distribution().(map[opCodescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/opCode#]int{ |
| 432 | deepEqualsOpscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/deepEqualsOp.: 0, |
| 433 | lookupOpscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/lookupOp.: 0, |
| 434 | insertscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/insert.: 30, |
| 435 | updatescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/update.: 20, |
| 436 | removescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/remove.: 0, |
| 437 | mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/merge.: 10, |
| 438 | intersectscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/intersect.: 0, |
| 439 | clearscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/clear.: 1, |
| 440 | takeAveragescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/takeAverage.: 0, |
| 441 | assignscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/assign.: 30, |
| 442 | }), |
| 443 | } |
| 444 | |
| 445 | func BenchmarkTrieSmallWidescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/BenchmarkTrieSmallWide().(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) { |
| 446 | runscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/run().(b, smallWidescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/smallWide., 456, func(size int) mapCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection# { |
| 447 | return newTriesCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/newTriesCollection().(size) |
| 448 | }) |
| 449 | } |
| 450 | |
| 451 | func BenchmarkMapsSmallWidescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/BenchmarkMapsSmallWide().(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) { |
| 452 | runscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/run().(b, smallWidescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/smallWide., 456, func(size int) mapCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/mapCollection# { |
| 453 | return newMapsCollectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/callgraph/vta/internal/trie_test`/newMapsCollection().(size) |
| 454 | }) |
| 455 | } |