nodeidmap

package
v1.108.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2024 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package nodeidmap implements an optimized version of map for storj.NodeID.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

type Map[Value any] struct {
	// contains filtered or unexported fields
}

Map implements a map[storj.NodeID]Value, which avoids hashing the whole node id.

func Make

func Make[Value any]() Map[Value]

Make creates a new Map.

func MakeSized

func MakeSized[Value any](size int) Map[Value]

MakeSized creates a new Map with the specified size.

func (Map[Value]) Add

func (m Map[Value]) Add(xs Map[Value], combine func(old, new Value) Value)

Add adds xs to the receiver, using combine to add values together when those values fall under the same NodeID.

func (Map[Value]) AsMap

func (m Map[Value]) AsMap() map[storj.NodeID]Value

AsMap converts Map to a regular Go map.

func (Map[Value]) Clear

func (m Map[Value]) Clear()

Clear clears the map.

func (Map[Value]) Clone

func (m Map[Value]) Clone() Map[Value]

Clone makes a deep clone of the map.

func (Map[Value]) Count

func (m Map[Value]) Count() (count int)

Count returns the number of entries in the map.

func (Map[Value]) Load

func (m Map[Value]) Load(id storj.NodeID) (value Value, ok bool)

Load loads the value for id.

func (Map[Value]) Modify

func (m Map[Value]) Modify(id storj.NodeID, modify func(old Value, ok bool) Value)

Modify modifies the value at id.

func (Map[Value]) Range

func (m Map[Value]) Range(fn func(k storj.NodeID, v Value) bool)

Range iterates over all the values in the map. Callback should return false to stop iteration.

func (*Map[Value]) Reset

func (m *Map[Value]) Reset(size int)

Reset recreates the map.

func (Map[Value]) Store

func (m Map[Value]) Store(id storj.NodeID, value Value)

Store stores the value at id.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL