MCPcopy Create free account
hub / github.com/cantabular/faststringmap / mapSliceN

Function mapSliceN

uint32_store_test.go:64–81  ·  view source on GitHub ↗
(m map[string]uint32, n int)

Source from the content-addressed store, hash-verified

62}
63
64func mapSliceN(m map[string]uint32, n int) mapSlice {
65 if n < 0 || n > len(m) {
66 panic(fmt.Sprintf("n value %d out of range for map size %d", n, len(m)))
67 }
68 in := make([]string, 0, n)
69 out := make([]string, 0, len(m)-n)
70 nAdded := 0
71
72 for k := range m {
73 if nAdded < n {
74 nAdded++
75 in = append(in, k)
76 } else {
77 out = append(out, k)
78 }
79 }
80 return mapSlice{m: m, in: in, out: out}
81}
82
83func (m mapSlice) AppendKeys(a []string) []string { return append(a, m.in...) }
84func (m mapSlice) Get(s string) uint32 { return m.m[s] }

Callers 3

TestFastStringToUint32Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected