hash

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2023 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cursor

type Cursor struct {
	K *big.Int
	V *big.Int
	// contains filtered or unexported fields
}

Cursor provides enumerating of Map items.

func (*Cursor) Next

func (c *Cursor) Next() bool

Next moves the cursor to the next item in the map and sets the K and V fields accordingly. It returns true on success, or false if there is no next item.

Every use of the K/V fields, even the first one, must be preceded by a call to Next, for example

for c := m.Cursor(); c.Next(); {
	... c.K, c.V valid here
}

type Map

type Map struct {
	// contains filtered or unexported fields
}

Map is a hash table.

func New

func New(hash func(*big.Int) int64, eq func(a, b *big.Int) bool, initialCapacity int) *Map

New returns a newly created Map. The hash function takes a key and returns its hash. The eq function takes two keys and returns whether they are equal.

func (*Map) Cursor

func (m *Map) Cursor() *Cursor

Cursor returns a new map Cursor.

func (*Map) Delete

func (m *Map) Delete(k *big.Int)

Delete removes the element with key k from the map.

func (*Map) Get

func (m *Map) Get(k *big.Int) (r *big.Int, ok bool)

Get returns the value associated with k and a boolean value indicating whether the key is in the map.

func (*Map) Insert

func (m *Map) Insert(k *big.Int, v *big.Int)

Insert inserts v into the map associating it with k.

func (*Map) Len

func (m *Map) Len() int

Len returns the number of items in the map.

Jump to

Keyboard shortcuts

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