slicemap

package module
v0.0.0-...-0433f2a Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: Unlicense Imports: 2 Imported by: 0

README

slicemap
========

a map implemented with a sorted slice underneath, using binary search.

done as an exercise. should not be used.

I expected it to be faster than the standard `map` for very little data, but turns out it isn't.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

type Map[K constraints.Ordered, V any] struct {
	// contains filtered or unexported fields
}

func New

func New[K constraints.Ordered, V any]() *Map[K, V]

func New2

func New2[K constraints.Ordered, V any]() *Map[K, V]

func (*Map[K, V]) Clear

func (m *Map[K, V]) Clear()

func (*Map[K, V]) Delete

func (m *Map[K, V]) Delete(key K)

func (*Map[K, V]) Load

func (m *Map[K, V]) Load(key K) (value V, ok bool)

func (*Map[K, V]) LoadAndDelete

func (m *Map[K, V]) LoadAndDelete(key K) (value V, loaded bool)

func (*Map[K, V]) LoadAndStore

func (m *Map[K, V]) LoadAndStore(key K, value V) (actual V, loaded bool)

func (*Map[K, V]) LoadOrCompute

func (m *Map[K, V]) LoadOrCompute(key K, valueFn func() V) (actual V, loaded bool)

func (*Map[K, V]) LoadOrStore

func (m *Map[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool)

func (*Map[K, V]) Range

func (m *Map[K, V]) Range(f func(key K, value V) bool)

func (*Map[K, V]) Size

func (m *Map[K, V]) Size() int

func (*Map[K, V]) Store

func (m *Map[K, V]) Store(key K, value V)

type Map2

type Map2[K constraints.Ordered, V any] struct {
	// contains filtered or unexported fields
}

func (*Map2[K, V]) Clear

func (m *Map2[K, V]) Clear()

func (*Map2[K, V]) Delete

func (m *Map2[K, V]) Delete(key K)

func (*Map2[K, V]) Load

func (m *Map2[K, V]) Load(key K) (value V, ok bool)

func (*Map2[K, V]) LoadAndDelete

func (m *Map2[K, V]) LoadAndDelete(key K) (value V, loaded bool)

func (*Map2[K, V]) LoadAndStore

func (m *Map2[K, V]) LoadAndStore(key K, value V) (actual V, loaded bool)

func (*Map2[K, V]) LoadOrCompute

func (m *Map2[K, V]) LoadOrCompute(key K, valueFn func() V) (actual V, loaded bool)

func (*Map2[K, V]) LoadOrStore

func (m *Map2[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool)

func (*Map2[K, V]) Range

func (m *Map2[K, V]) Range(f func(key K, value V) bool)

func (*Map2[K, V]) Size

func (m *Map2[K, V]) Size() int

func (*Map2[K, V]) Store

func (m *Map2[K, V]) Store(key K, value V)

Jump to

Keyboard shortcuts

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