MCPcopy
hub / github.com/cilium/ebpf / NextKeyBytes

Method NextKeyBytes

map.go:1124–1134  ·  view source on GitHub ↗

NextKeyBytes returns the key following an initial key as a byte slice. Passing nil will return the first key. Use Iterate if you want to traverse all entries in the map. Returns nil if there are no more keys.

(key any)

Source from the content-addressed store, hash-verified

1122//
1123// Returns nil if there are no more keys.
1124func (m *Map) NextKeyBytes(key any) ([]byte, error) {
1125 nextKey := make([]byte, m.keySize)
1126 nextKeyPtr := sys.UnsafeSlicePointer(nextKey)
1127
1128 err := m.nextKey(key, nextKeyPtr)
1129 if errors.Is(err, ErrKeyNotExist) {
1130 return nil, nil
1131 }
1132
1133 return nextKey, err
1134}
1135
1136func (m *Map) nextKey(key any, nextKeyOut sys.Pointer) error {
1137 var (

Callers

nothing calls this directly

Calls 3

nextKeyMethod · 0.95
UnsafeSlicePointerFunction · 0.92
IsMethod · 0.45

Tested by

no test coverage detected