skipmap

package module
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2022 License: MIT Imports: 5 Imported by: 18

README

Introduction

If your Go version is lower than 1.18, use v0.7.0 instead.

skipmap is a high-performance, scalable, concurrent-safe map based on skip-list. In the typical pattern(100000 operations, 90%LOAD 9%STORE 1%DELETE, 8C16T), the skipmap up to 10x faster than the built-in sync.Map.

The main idea behind the skipmap is A Simple Optimistic Skiplist Algorithm.

Different from the sync.Map, the keys in the skipmap are always sorted, and the Load and Range operations are wait-free (A goroutine is guaranteed to complete an operation as long as it keeps taking steps, regardless of the activity of other goroutines).

Features

  • Scalable, high-performance, concurrent-safe.
  • Wait-free Load and Range operations (wait-free algorithms have stronger guarantees than lock-free).
  • Sorted items.

When should you use skipmap

In most cases, skipmap is better than sync.Map, especially in these situations:

  • Sorted keys are needed.
  • Concurrent calls multiple operations. Such as use both Range and Store at the same time, in this situation, use skipmap can obtain very large improvement on performance.

If only one goroutine access the map for the most of the time, such as insert a batch of elements and then use only Load or Range, use built-in map is better.

QuickStart

See Go doc for more information.

package main

import (
	"fmt"

	"github.com/zhangyunhao116/skipmap"
)

func main() {
	// Typed key and generic value.
	m0 := skipmap.NewString[int]()

	for _, v := range []int{10, 12, 15} {
		m0.Store(strconv.Itoa(v), v+100)
	}

	v, ok := m0.Load("10")
	if ok {
		fmt.Println("skipmap load 10 with value ", v)
	}

	m0.Range(func(key string, value int) bool {
		fmt.Println("skipmap range found ", key, value)
		return true
	})

	m0.Delete("15")
	fmt.Printf("skipmap contains %d items\r\n", m0.Len())

	// Generic key and value.
	m1 := skipmap.New[string, int]()
	for _, v := range []int{11, 13, 16} {
		m1.Store(strconv.Itoa(v), v+100)
	}
	m1.Range(func(key string, value int) bool {
		println("m1 found ", key, value)
		return true
	})

	// Generic key and value with less function.
	m2 := skipmap.NewFunc[int, string](func(a, b int) bool { return a < b })
	for _, v := range []int{15, 17, 19} {
		m2.Store(v, strconv.Itoa(v+200))
	}
	m2.Range(func(key int, value string) bool {
		println("m2 found ", key, value)
		return true
	})
}

Note that generic APIs are always slower than typed APIs, but are more suitable for some scenarios such as functional programming.

e.g. New[string,int] is ~2x slower than NewString[int], and NewFunc[string,int](func(a, b string) bool { return a < b }) is 1~2x slower than NewString[int].

Performance ranking: NewString[int] > New[string,int] > NewFunc[string,int](func(a, b string) bool { return a < b })

Benchmark

based on typed APIs.

Go version: go1.16.2 linux/amd64

CPU: AMD 3700x(8C16T), running at 3.6GHz

OS: ubuntu 18.04

MEMORY: 16G x 2 (3200MHz)

benchmark

$ go test -run=NOTEST -bench=. -benchtime=100000x -benchmem -count=20 -timeout=60m  > x.txt
$ benchstat x.txt
name                                            time/op
Int64/Store/skipmap-16                           158ns ±12%
Int64/Store/sync.Map-16                          700ns ± 4%
Int64/Load50Hits/skipmap-16                     10.1ns ±14%
Int64/Load50Hits/sync.Map-16                    14.8ns ±23%
Int64/30Store70Load/skipmap-16                  50.6ns ±20%
Int64/30Store70Load/sync.Map-16                  592ns ± 7%
Int64/1Delete9Store90Load/skipmap-16            27.5ns ±13%
Int64/1Delete9Store90Load/sync.Map-16            480ns ± 4%
Int64/1Range9Delete90Store900Load/skipmap-16    34.2ns ±26%
Int64/1Range9Delete90Store900Load/sync.Map-16   1.00µs ±12%
String/Store/skipmap-16                          171ns ±15%
String/Store/sync.Map-16                         873ns ± 4%
String/Load50Hits/skipmap-16                    21.3ns ±38%
String/Load50Hits/sync.Map-16                   19.9ns ±12%
String/30Store70Load/skipmap-16                 75.6ns ±16%
String/30Store70Load/sync.Map-16                 726ns ± 5%
String/1Delete9Store90Load/skipmap-16           34.3ns ±20%
String/1Delete9Store90Load/sync.Map-16           584ns ± 5%
String/1Range9Delete90Store900Load/skipmap-16   41.0ns ±21%
String/1Range9Delete90Store900Load/sync.Map-16  1.17µs ± 8%

name                                            alloc/op
Int64/Store/skipmap-16                            112B ± 0%
Int64/Store/sync.Map-16                           128B ± 0%
Int64/Load50Hits/skipmap-16                      0.00B     
Int64/Load50Hits/sync.Map-16                     0.00B     
Int64/30Store70Load/skipmap-16                   33.0B ± 0%
Int64/30Store70Load/sync.Map-16                  81.2B ±11%
Int64/1Delete9Store90Load/skipmap-16             10.0B ± 0%
Int64/1Delete9Store90Load/sync.Map-16            57.9B ± 5%
Int64/1Range9Delete90Store900Load/skipmap-16     10.0B ± 0%
Int64/1Range9Delete90Store900Load/sync.Map-16     261B ±17%
String/Store/skipmap-16                           144B ± 0%
String/Store/sync.Map-16                          152B ± 0%
String/Load50Hits/skipmap-16                     15.0B ± 0%
String/Load50Hits/sync.Map-16                    15.0B ± 0%
String/30Store70Load/skipmap-16                  54.0B ± 0%
String/30Store70Load/sync.Map-16                 96.9B ±12%
String/1Delete9Store90Load/skipmap-16            27.0B ± 0%
String/1Delete9Store90Load/sync.Map-16           74.2B ± 4%
String/1Range9Delete90Store900Load/skipmap-16    27.0B ± 0%
String/1Range9Delete90Store900Load/sync.Map-16    257B ±10%

name                                            allocs/op
Int64/Store/skipmap-16                            3.00 ± 0%
Int64/Store/sync.Map-16                           4.00 ± 0%
Int64/Load50Hits/skipmap-16                       0.00     
Int64/Load50Hits/sync.Map-16                      0.00     
Int64/30Store70Load/skipmap-16                    0.00     
Int64/30Store70Load/sync.Map-16                   1.00 ± 0%
Int64/1Delete9Store90Load/skipmap-16              0.00     
Int64/1Delete9Store90Load/sync.Map-16             0.00     
Int64/1Range9Delete90Store900Load/skipmap-16      0.00     
Int64/1Range9Delete90Store900Load/sync.Map-16     0.00     
String/Store/skipmap-16                           4.00 ± 0%
String/Store/sync.Map-16                          5.00 ± 0%
String/Load50Hits/skipmap-16                      1.00 ± 0%
String/Load50Hits/sync.Map-16                     1.00 ± 0%
String/30Store70Load/skipmap-16                   1.00 ± 0%
String/30Store70Load/sync.Map-16                  2.00 ± 0%
String/1Delete9Store90Load/skipmap-16             1.00 ± 0%
String/1Delete9Store90Load/sync.Map-16            1.00 ± 0%
String/1Range9Delete90Store900Load/skipmap-16     1.00 ± 0%
String/1Range9Delete90Store900Load/sync.Map-16    1.00 ± 0%

Documentation

Overview

Package skipmap is a high-performance, scalable, concurrent-safe map based on skip-list. In the typical pattern(100000 operations, 90%LOAD 9%STORE 1%DELETE, 8C16T), the skipmap up to 10x faster than the built-in sync.Map.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FuncMap added in v0.8.0

type FuncMap[keyT any, valueT any] struct {
	// contains filtered or unexported fields
}

FuncMap represents a map based on skip list.

func NewFloat32

func NewFloat32[valueT any]() *FuncMap[float32, valueT]

NewFloat32 returns an empty skipmap in ascending order.

func NewFloat32Desc added in v0.3.0

func NewFloat32Desc[valueT any]() *FuncMap[float32, valueT]

NewFloat32Desc returns an empty skipmap in descending order.

func NewFloat64

func NewFloat64[valueT any]() *FuncMap[float64, valueT]

NewFloat64 returns an empty skipmap in ascending order.

func NewFloat64Desc added in v0.3.0

func NewFloat64Desc[valueT any]() *FuncMap[float64, valueT]

NewFloat64Desc returns an empty skipmap in descending order.

func NewFunc added in v0.8.0

func NewFunc[keyT any, valueT any](less func(a, b keyT) bool) *FuncMap[keyT, valueT]

NewFunc returns an empty skipmap in ascending order.

Note that the less function requires a strict weak ordering, see https://en.wikipedia.org/wiki/Weak_ordering#Strict_weak_orderings, or undefined behavior will happen.

func (*FuncMap[keyT, valueT]) Delete added in v0.8.0

func (s *FuncMap[keyT, valueT]) Delete(key keyT) bool

Delete deletes the value for a key.

func (*FuncMap[keyT, valueT]) Len added in v0.8.0

func (s *FuncMap[keyT, valueT]) Len() int

Len returns the length of this skipmap.

func (*FuncMap[keyT, valueT]) Load added in v0.8.0

func (s *FuncMap[keyT, valueT]) Load(key keyT) (value valueT, ok bool)

Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.

func (*FuncMap[keyT, valueT]) LoadAndDelete added in v0.8.0

func (s *FuncMap[keyT, valueT]) LoadAndDelete(key keyT) (value valueT, loaded bool)

LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present. (Modified from Delete)

func (*FuncMap[keyT, valueT]) LoadOrStore added in v0.8.0

func (s *FuncMap[keyT, valueT]) LoadOrStore(key keyT, value valueT) (actual valueT, loaded bool)

LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored. (Modified from Store)

func (*FuncMap[keyT, valueT]) LoadOrStoreLazy added in v0.8.0

func (s *FuncMap[keyT, valueT]) LoadOrStoreLazy(key keyT, f func() valueT) (actual valueT, loaded bool)

LoadOrStoreLazy returns the existing value for the key if present. Otherwise, it stores and returns the given value from f, f will only be called once. The loaded result is true if the value was loaded, false if stored. (Modified from LoadOrStore)

func (*FuncMap[keyT, valueT]) Range added in v0.8.0

func (s *FuncMap[keyT, valueT]) Range(f func(key keyT, value valueT) bool)

Range calls f sequentially for each key and value present in the skipmap. If f returns false, range stops the iteration.

Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently, Range may reflect any mapping for that key from any point during the Range call.

func (*FuncMap[keyT, valueT]) Store added in v0.8.0

func (s *FuncMap[keyT, valueT]) Store(key keyT, value valueT)

Store sets the value for a key.

type Int32Map

type Int32Map[valueT any] struct {
	// contains filtered or unexported fields
}

Int32Map represents a map based on skip list.

func NewInt32

func NewInt32[valueT any]() *Int32Map[valueT]

NewInt32 returns an empty skipmap in ascending order.

func (*Int32Map[valueT]) Delete

func (s *Int32Map[valueT]) Delete(key int32) bool

Delete deletes the value for a key.

func (*Int32Map[valueT]) Len

func (s *Int32Map[valueT]) Len() int

Len returns the length of this skipmap.

func (*Int32Map[valueT]) Load

func (s *Int32Map[valueT]) Load(key int32) (value valueT, ok bool)

Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.

func (*Int32Map[valueT]) LoadAndDelete

func (s *Int32Map[valueT]) LoadAndDelete(key int32) (value valueT, loaded bool)

LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present. (Modified from Delete)

func (*Int32Map[valueT]) LoadOrStore

func (s *Int32Map[valueT]) LoadOrStore(key int32, value valueT) (actual valueT, loaded bool)

LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored. (Modified from Store)

func (*Int32Map[valueT]) LoadOrStoreLazy added in v0.7.0

func (s *Int32Map[valueT]) LoadOrStoreLazy(key int32, f func() valueT) (actual valueT, loaded bool)

LoadOrStoreLazy returns the existing value for the key if present. Otherwise, it stores and returns the given value from f, f will only be called once. The loaded result is true if the value was loaded, false if stored. (Modified from LoadOrStore)

func (*Int32Map[valueT]) Range

func (s *Int32Map[valueT]) Range(f func(key int32, value valueT) bool)

Range calls f sequentially for each key and value present in the skipmap. If f returns false, range stops the iteration.

Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently, Range may reflect any mapping for that key from any point during the Range call.

func (*Int32Map[valueT]) Store

func (s *Int32Map[valueT]) Store(key int32, value valueT)

Store sets the value for a key.

type Int32MapDesc added in v0.3.0

type Int32MapDesc[valueT any] struct {
	// contains filtered or unexported fields
}

Int32MapDesc represents a map based on skip list.

func NewInt32Desc added in v0.3.0

func NewInt32Desc[valueT any]() *Int32MapDesc[valueT]

NewInt32Desc returns an empty skipmap in descending order.

func (*Int32MapDesc[valueT]) Delete added in v0.3.0

func (s *Int32MapDesc[valueT]) Delete(key int32) bool

Delete deletes the value for a key.

func (*Int32MapDesc[valueT]) Len added in v0.3.0

func (s *Int32MapDesc[valueT]) Len() int

Len returns the length of this skipmap.

func (*Int32MapDesc[valueT]) Load added in v0.3.0

func (s *Int32MapDesc[valueT]) Load(key int32) (value valueT, ok bool)

Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.

func (*Int32MapDesc[valueT]) LoadAndDelete added in v0.3.0

func (s *Int32MapDesc[valueT]) LoadAndDelete(key int32) (value valueT, loaded bool)

LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present. (Modified from Delete)

func (*Int32MapDesc[valueT]) LoadOrStore added in v0.3.0

func (s *Int32MapDesc[valueT]) LoadOrStore(key int32, value valueT) (actual valueT, loaded bool)

LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored. (Modified from Store)

func (*Int32MapDesc[valueT]) LoadOrStoreLazy added in v0.7.0

func (s *Int32MapDesc[valueT]) LoadOrStoreLazy(key int32, f func() valueT) (actual valueT, loaded bool)

LoadOrStoreLazy returns the existing value for the key if present. Otherwise, it stores and returns the given value from f, f will only be called once. The loaded result is true if the value was loaded, false if stored. (Modified from LoadOrStore)

func (*Int32MapDesc[valueT]) Range added in v0.3.0

func (s *Int32MapDesc[valueT]) Range(f func(key int32, value valueT) bool)

Range calls f sequentially for each key and value present in the skipmap. If f returns false, range stops the iteration.

Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently, Range may reflect any mapping for that key from any point during the Range call.

func (*Int32MapDesc[valueT]) Store added in v0.3.0

func (s *Int32MapDesc[valueT]) Store(key int32, value valueT)

Store sets the value for a key.

type Int64Map

type Int64Map[valueT any] struct {
	// contains filtered or unexported fields
}

Int64Map represents a map based on skip list.

func NewInt64

func NewInt64[valueT any]() *Int64Map[valueT]

NewInt64 returns an empty skipmap in ascending order.

func (*Int64Map[valueT]) Delete

func (s *Int64Map[valueT]) Delete(key int64) bool

Delete deletes the value for a key.

func (*Int64Map[valueT]) Len

func (s *Int64Map[valueT]) Len() int

Len returns the length of this skipmap.

func (*Int64Map[valueT]) Load

func (s *Int64Map[valueT]) Load(key int64) (value valueT, ok bool)

Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.

func (*Int64Map[valueT]) LoadAndDelete

func (s *Int64Map[valueT]) LoadAndDelete(key int64) (value valueT, loaded bool)

LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present. (Modified from Delete)

func (*Int64Map[valueT]) LoadOrStore

func (s *Int64Map[valueT]) LoadOrStore(key int64, value valueT) (actual valueT, loaded bool)

LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored. (Modified from Store)

func (*Int64Map[valueT]) LoadOrStoreLazy added in v0.7.0

func (s *Int64Map[valueT]) LoadOrStoreLazy(key int64, f func() valueT) (actual valueT, loaded bool)

LoadOrStoreLazy returns the existing value for the key if present. Otherwise, it stores and returns the given value from f, f will only be called once. The loaded result is true if the value was loaded, false if stored. (Modified from LoadOrStore)

func (*Int64Map[valueT]) Range

func (s *Int64Map[valueT]) Range(f func(key int64, value valueT) bool)

Range calls f sequentially for each key and value present in the skipmap. If f returns false, range stops the iteration.

Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently, Range may reflect any mapping for that key from any point during the Range call.

func (*Int64Map[valueT]) Store

func (s *Int64Map[valueT]) Store(key int64, value valueT)

Store sets the value for a key.

type Int64MapDesc added in v0.3.0

type Int64MapDesc[valueT any] struct {
	// contains filtered or unexported fields
}

Int64MapDesc represents a map based on skip list.

func NewInt64Desc added in v0.3.0

func NewInt64Desc[valueT any]() *Int64MapDesc[valueT]

NewInt64Desc returns an empty skipmap in descending order.

func (*Int64MapDesc[valueT]) Delete added in v0.3.0

func (s *Int64MapDesc[valueT]) Delete(key int64) bool

Delete deletes the value for a key.

func (*Int64MapDesc[valueT]) Len added in v0.3.0

func (s *Int64MapDesc[valueT]) Len() int

Len returns the length of this skipmap.

func (*Int64MapDesc[valueT]) Load added in v0.3.0

func (s *Int64MapDesc[valueT]) Load(key int64) (value valueT, ok bool)

Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.

func (*Int64MapDesc[valueT]) LoadAndDelete added in v0.3.0

func (s *Int64MapDesc[valueT]) LoadAndDelete(key int64) (value valueT, loaded bool)

LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present. (Modified from Delete)

func (*Int64MapDesc[valueT]) LoadOrStore added in v0.3.0

func (s *Int64MapDesc[valueT]) LoadOrStore(key int64, value valueT) (actual valueT, loaded bool)

LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored. (Modified from Store)

func (*Int64MapDesc[valueT]) LoadOrStoreLazy added in v0.8.0

func (s *Int64MapDesc[valueT]) LoadOrStoreLazy(key int64, f func() valueT) (actual valueT, loaded bool)

LoadOrStoreLazy returns the existing value for the key if present. Otherwise, it stores and returns the given value from f, f will only be called once. The loaded result is true if the value was loaded, false if stored. (Modified from LoadOrStore)

func (*Int64MapDesc[valueT]) Range added in v0.3.0

func (s *Int64MapDesc[valueT]) Range(f func(key int64, value valueT) bool)

Range calls f sequentially for each key and value present in the skipmap. If f returns false, range stops the iteration.

Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently, Range may reflect any mapping for that key from any point during the Range call.

func (*Int64MapDesc[valueT]) Store added in v0.3.0

func (s *Int64MapDesc[valueT]) Store(key int64, value valueT)

Store sets the value for a key.

type IntMap

type IntMap[valueT any] struct {
	// contains filtered or unexported fields
}

IntMap represents a map based on skip list.

func NewInt

func NewInt[valueT any]() *IntMap[valueT]

NewInt returns an empty skipmap in ascending order.

func (*IntMap[valueT]) Delete

func (s *IntMap[valueT]) Delete(key int) bool

Delete deletes the value for a key.

func (*IntMap[valueT]) Len

func (s *IntMap[valueT]) Len() int

Len returns the length of this skipmap.

func (*IntMap[valueT]) Load

func (s *IntMap[valueT]) Load(key int) (value valueT, ok bool)

Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.

func (*IntMap[valueT]) LoadAndDelete

func (s *IntMap[valueT]) LoadAndDelete(key int) (value valueT, loaded bool)

LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present. (Modified from Delete)

func (*IntMap[valueT]) LoadOrStore

func (s *IntMap[valueT]) LoadOrStore(key int, value valueT) (actual valueT, loaded bool)

LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored. (Modified from Store)

func (*IntMap[valueT]) LoadOrStoreLazy added in v0.7.0

func (s *IntMap[valueT]) LoadOrStoreLazy(key int, f func() valueT) (actual valueT, loaded bool)

LoadOrStoreLazy returns the existing value for the key if present. Otherwise, it stores and returns the given value from f, f will only be called once. The loaded result is true if the value was loaded, false if stored. (Modified from LoadOrStore)

func (*IntMap[valueT]) Range

func (s *IntMap[valueT]) Range(f func(key int, value valueT) bool)

Range calls f sequentially for each key and value present in the skipmap. If f returns false, range stops the iteration.

Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently, Range may reflect any mapping for that key from any point during the Range call.

func (*IntMap[valueT]) Store

func (s *IntMap[valueT]) Store(key int, value valueT)

Store sets the value for a key.

type IntMapDesc added in v0.3.0

type IntMapDesc[valueT any] struct {
	// contains filtered or unexported fields
}

IntMapDesc represents a map based on skip list.

func NewIntDesc added in v0.3.0

func NewIntDesc[valueT any]() *IntMapDesc[valueT]

NewIntDesc returns an empty skipmap in descending order.

func (*IntMapDesc[valueT]) Delete added in v0.3.0

func (s *IntMapDesc[valueT]) Delete(key int) bool

Delete deletes the value for a key.

func (*IntMapDesc[valueT]) Len added in v0.3.0

func (s *IntMapDesc[valueT]) Len() int

Len returns the length of this skipmap.

func (*IntMapDesc[valueT]) Load added in v0.3.0

func (s *IntMapDesc[valueT]) Load(key int) (value valueT, ok bool)

Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.

func (*IntMapDesc[valueT]) LoadAndDelete added in v0.3.0

func (s *IntMapDesc[valueT]) LoadAndDelete(key int) (value valueT, loaded bool)

LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present. (Modified from Delete)

func (*IntMapDesc[valueT]) LoadOrStore added in v0.3.0

func (s *IntMapDesc[valueT]) LoadOrStore(key int, value valueT) (actual valueT, loaded bool)

LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored. (Modified from Store)

func (*IntMapDesc[valueT]) LoadOrStoreLazy added in v0.7.0

func (s *IntMapDesc[valueT]) LoadOrStoreLazy(key int, f func() valueT) (actual valueT, loaded bool)

LoadOrStoreLazy returns the existing value for the key if present. Otherwise, it stores and returns the given value from f, f will only be called once. The loaded result is true if the value was loaded, false if stored. (Modified from LoadOrStore)

func (*IntMapDesc[valueT]) Range added in v0.3.0

func (s *IntMapDesc[valueT]) Range(f func(key int, value valueT) bool)

Range calls f sequentially for each key and value present in the skipmap. If f returns false, range stops the iteration.

Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently, Range may reflect any mapping for that key from any point during the Range call.

func (*IntMapDesc[valueT]) Store added in v0.3.0

func (s *IntMapDesc[valueT]) Store(key int, value valueT)

Store sets the value for a key.

type OrderedMap added in v0.8.0

type OrderedMap[keyT ordered, valueT any] struct {
	// contains filtered or unexported fields
}

OrderedMap represents a map based on skip list.

func New added in v0.8.0

func New[keyT ordered, valueT any]() *OrderedMap[keyT, valueT]

New returns an empty skipmap in ascending order.

func (*OrderedMap[keyT, valueT]) Delete added in v0.8.0

func (s *OrderedMap[keyT, valueT]) Delete(key keyT) bool

Delete deletes the value for a key.

func (*OrderedMap[keyT, valueT]) Len added in v0.8.0

func (s *OrderedMap[keyT, valueT]) Len() int

Len returns the length of this skipmap.

func (*OrderedMap[keyT, valueT]) Load added in v0.8.0

func (s *OrderedMap[keyT, valueT]) Load(key keyT) (value valueT, ok bool)

Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.

func (*OrderedMap[keyT, valueT]) LoadAndDelete added in v0.8.0

func (s *OrderedMap[keyT, valueT]) LoadAndDelete(key keyT) (value valueT, loaded bool)

LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present. (Modified from Delete)

func (*OrderedMap[keyT, valueT]) LoadOrStore added in v0.8.0

func (s *OrderedMap[keyT, valueT]) LoadOrStore(key keyT, value valueT) (actual valueT, loaded bool)

LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored. (Modified from Store)

func (*OrderedMap[keyT, valueT]) LoadOrStoreLazy added in v0.8.0

func (s *OrderedMap[keyT, valueT]) LoadOrStoreLazy(key keyT, f func() valueT) (actual valueT, loaded bool)

LoadOrStoreLazy returns the existing value for the key if present. Otherwise, it stores and returns the given value from f, f will only be called once. The loaded result is true if the value was loaded, false if stored. (Modified from LoadOrStore)

func (*OrderedMap[keyT, valueT]) Range added in v0.8.0

func (s *OrderedMap[keyT, valueT]) Range(f func(key keyT, value valueT) bool)

Range calls f sequentially for each key and value present in the skipmap. If f returns false, range stops the iteration.

Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently, Range may reflect any mapping for that key from any point during the Range call.

func (*OrderedMap[keyT, valueT]) Store added in v0.8.0

func (s *OrderedMap[keyT, valueT]) Store(key keyT, value valueT)

Store sets the value for a key.

type OrderedMapDesc added in v0.8.0

type OrderedMapDesc[keyT ordered, valueT any] struct {
	// contains filtered or unexported fields
}

OrderedMapDesc represents a map based on skip list.

func NewDesc added in v0.8.0

func NewDesc[keyT ordered, valueT any]() *OrderedMapDesc[keyT, valueT]

NewDesc returns an empty skipmap in descending order.

func (*OrderedMapDesc[keyT, valueT]) Delete added in v0.8.0

func (s *OrderedMapDesc[keyT, valueT]) Delete(key keyT) bool

Delete deletes the value for a key.

func (*OrderedMapDesc[keyT, valueT]) Len added in v0.8.0

func (s *OrderedMapDesc[keyT, valueT]) Len() int

Len returns the length of this skipmap.

func (*OrderedMapDesc[keyT, valueT]) Load added in v0.8.0

func (s *OrderedMapDesc[keyT, valueT]) Load(key keyT) (value valueT, ok bool)

Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.

func (*OrderedMapDesc[keyT, valueT]) LoadAndDelete added in v0.8.0

func (s *OrderedMapDesc[keyT, valueT]) LoadAndDelete(key keyT) (value valueT, loaded bool)

LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present. (Modified from Delete)

func (*OrderedMapDesc[keyT, valueT]) LoadOrStore added in v0.8.0

func (s *OrderedMapDesc[keyT, valueT]) LoadOrStore(key keyT, value valueT) (actual valueT, loaded bool)

LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored. (Modified from Store)

func (*OrderedMapDesc[keyT, valueT]) LoadOrStoreLazy added in v0.8.0

func (s *OrderedMapDesc[keyT, valueT]) LoadOrStoreLazy(key keyT, f func() valueT) (actual valueT, loaded bool)

LoadOrStoreLazy returns the existing value for the key if present. Otherwise, it stores and returns the given value from f, f will only be called once. The loaded result is true if the value was loaded, false if stored. (Modified from LoadOrStore)

func (*OrderedMapDesc[keyT, valueT]) Range added in v0.8.0

func (s *OrderedMapDesc[keyT, valueT]) Range(f func(key keyT, value valueT) bool)

Range calls f sequentially for each key and value present in the skipmap. If f returns false, range stops the iteration.

Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently, Range may reflect any mapping for that key from any point during the Range call.

func (*OrderedMapDesc[keyT, valueT]) Store added in v0.8.0

func (s *OrderedMapDesc[keyT, valueT]) Store(key keyT, value valueT)

Store sets the value for a key.

type StringMap

type StringMap[valueT any] struct {
	// contains filtered or unexported fields
}

StringMap represents a map based on skip list.

func NewString

func NewString[valueT any]() *StringMap[valueT]

NewString returns an empty skipmap in ascending order.

func (*StringMap[valueT]) Delete

func (s *StringMap[valueT]) Delete(key string) bool

Delete deletes the value for a key.

func (*StringMap[valueT]) Len

func (s *StringMap[valueT]) Len() int

Len returns the length of this skipmap.

func (*StringMap[valueT]) Load

func (s *StringMap[valueT]) Load(key string) (value valueT, ok bool)

Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.

func (*StringMap[valueT]) LoadAndDelete

func (s *StringMap[valueT]) LoadAndDelete(key string) (value valueT, loaded bool)

LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present. (Modified from Delete)

func (*StringMap[valueT]) LoadOrStore

func (s *StringMap[valueT]) LoadOrStore(key string, value valueT) (actual valueT, loaded bool)

LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored. (Modified from Store)

func (*StringMap[valueT]) LoadOrStoreLazy added in v0.7.0

func (s *StringMap[valueT]) LoadOrStoreLazy(key string, f func() valueT) (actual valueT, loaded bool)

LoadOrStoreLazy returns the existing value for the key if present. Otherwise, it stores and returns the given value from f, f will only be called once. The loaded result is true if the value was loaded, false if stored. (Modified from LoadOrStore)

func (*StringMap[valueT]) Range

func (s *StringMap[valueT]) Range(f func(key string, value valueT) bool)

Range calls f sequentially for each key and value present in the skipmap. If f returns false, range stops the iteration.

Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently, Range may reflect any mapping for that key from any point during the Range call.

func (*StringMap[valueT]) Store

func (s *StringMap[valueT]) Store(key string, value valueT)

Store sets the value for a key.

type StringMapDesc added in v0.8.0

type StringMapDesc[valueT any] struct {
	// contains filtered or unexported fields
}

StringMapDesc represents a map based on skip list.

func NewStringDesc added in v0.8.0

func NewStringDesc[valueT any]() *StringMapDesc[valueT]

NewStringDesc returns an empty skipmap in descending order.

func (*StringMapDesc[valueT]) Delete added in v0.8.0

func (s *StringMapDesc[valueT]) Delete(key string) bool

Delete deletes the value for a key.

func (*StringMapDesc[valueT]) Len added in v0.8.0

func (s *StringMapDesc[valueT]) Len() int

Len returns the length of this skipmap.

func (*StringMapDesc[valueT]) Load added in v0.8.0

func (s *StringMapDesc[valueT]) Load(key string) (value valueT, ok bool)

Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.

func (*StringMapDesc[valueT]) LoadAndDelete added in v0.8.0

func (s *StringMapDesc[valueT]) LoadAndDelete(key string) (value valueT, loaded bool)

LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present. (Modified from Delete)

func (*StringMapDesc[valueT]) LoadOrStore added in v0.8.0

func (s *StringMapDesc[valueT]) LoadOrStore(key string, value valueT) (actual valueT, loaded bool)

LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored. (Modified from Store)

func (*StringMapDesc[valueT]) LoadOrStoreLazy added in v0.8.0

func (s *StringMapDesc[valueT]) LoadOrStoreLazy(key string, f func() valueT) (actual valueT, loaded bool)

LoadOrStoreLazy returns the existing value for the key if present. Otherwise, it stores and returns the given value from f, f will only be called once. The loaded result is true if the value was loaded, false if stored. (Modified from LoadOrStore)

func (*StringMapDesc[valueT]) Range added in v0.8.0

func (s *StringMapDesc[valueT]) Range(f func(key string, value valueT) bool)

Range calls f sequentially for each key and value present in the skipmap. If f returns false, range stops the iteration.

Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently, Range may reflect any mapping for that key from any point during the Range call.

func (*StringMapDesc[valueT]) Store added in v0.8.0

func (s *StringMapDesc[valueT]) Store(key string, value valueT)

Store sets the value for a key.

type Uint32Map

type Uint32Map[valueT any] struct {
	// contains filtered or unexported fields
}

Uint32Map represents a map based on skip list.

func NewUint32

func NewUint32[valueT any]() *Uint32Map[valueT]

NewUint32 returns an empty skipmap in ascending order.

func (*Uint32Map[valueT]) Delete

func (s *Uint32Map[valueT]) Delete(key uint32) bool

Delete deletes the value for a key.

func (*Uint32Map[valueT]) Len

func (s *Uint32Map[valueT]) Len() int

Len returns the length of this skipmap.

func (*Uint32Map[valueT]) Load

func (s *Uint32Map[valueT]) Load(key uint32) (value valueT, ok bool)

Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.

func (*Uint32Map[valueT]) LoadAndDelete

func (s *Uint32Map[valueT]) LoadAndDelete(key uint32) (value valueT, loaded bool)

LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present. (Modified from Delete)

func (*Uint32Map[valueT]) LoadOrStore

func (s *Uint32Map[valueT]) LoadOrStore(key uint32, value valueT) (actual valueT, loaded bool)

LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored. (Modified from Store)

func (*Uint32Map[valueT]) LoadOrStoreLazy added in v0.7.0

func (s *Uint32Map[valueT]) LoadOrStoreLazy(key uint32, f func() valueT) (actual valueT, loaded bool)

LoadOrStoreLazy returns the existing value for the key if present. Otherwise, it stores and returns the given value from f, f will only be called once. The loaded result is true if the value was loaded, false if stored. (Modified from LoadOrStore)

func (*Uint32Map[valueT]) Range

func (s *Uint32Map[valueT]) Range(f func(key uint32, value valueT) bool)

Range calls f sequentially for each key and value present in the skipmap. If f returns false, range stops the iteration.

Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently, Range may reflect any mapping for that key from any point during the Range call.

func (*Uint32Map[valueT]) Store

func (s *Uint32Map[valueT]) Store(key uint32, value valueT)

Store sets the value for a key.

type Uint32MapDesc added in v0.3.0

type Uint32MapDesc[valueT any] struct {
	// contains filtered or unexported fields
}

Uint32MapDesc represents a map based on skip list.

func NewUint32Desc added in v0.3.0

func NewUint32Desc[valueT any]() *Uint32MapDesc[valueT]

NewUint32Desc returns an empty skipmap in descending order.

func (*Uint32MapDesc[valueT]) Delete added in v0.3.0

func (s *Uint32MapDesc[valueT]) Delete(key uint32) bool

Delete deletes the value for a key.

func (*Uint32MapDesc[valueT]) Len added in v0.3.0

func (s *Uint32MapDesc[valueT]) Len() int

Len returns the length of this skipmap.

func (*Uint32MapDesc[valueT]) Load added in v0.3.0

func (s *Uint32MapDesc[valueT]) Load(key uint32) (value valueT, ok bool)

Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.

func (*Uint32MapDesc[valueT]) LoadAndDelete added in v0.3.0

func (s *Uint32MapDesc[valueT]) LoadAndDelete(key uint32) (value valueT, loaded bool)

LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present. (Modified from Delete)

func (*Uint32MapDesc[valueT]) LoadOrStore added in v0.3.0

func (s *Uint32MapDesc[valueT]) LoadOrStore(key uint32, value valueT) (actual valueT, loaded bool)

LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored. (Modified from Store)

func (*Uint32MapDesc[valueT]) LoadOrStoreLazy added in v0.7.0

func (s *Uint32MapDesc[valueT]) LoadOrStoreLazy(key uint32, f func() valueT) (actual valueT, loaded bool)

LoadOrStoreLazy returns the existing value for the key if present. Otherwise, it stores and returns the given value from f, f will only be called once. The loaded result is true if the value was loaded, false if stored. (Modified from LoadOrStore)

func (*Uint32MapDesc[valueT]) Range added in v0.3.0

func (s *Uint32MapDesc[valueT]) Range(f func(key uint32, value valueT) bool)

Range calls f sequentially for each key and value present in the skipmap. If f returns false, range stops the iteration.

Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently, Range may reflect any mapping for that key from any point during the Range call.

func (*Uint32MapDesc[valueT]) Store added in v0.3.0

func (s *Uint32MapDesc[valueT]) Store(key uint32, value valueT)

Store sets the value for a key.

type Uint64Map

type Uint64Map[valueT any] struct {
	// contains filtered or unexported fields
}

Uint64Map represents a map based on skip list.

func NewUint64

func NewUint64[valueT any]() *Uint64Map[valueT]

NewUint64 returns an empty skipmap in ascending order.

func (*Uint64Map[valueT]) Delete

func (s *Uint64Map[valueT]) Delete(key uint64) bool

Delete deletes the value for a key.

func (*Uint64Map[valueT]) Len

func (s *Uint64Map[valueT]) Len() int

Len returns the length of this skipmap.

func (*Uint64Map[valueT]) Load

func (s *Uint64Map[valueT]) Load(key uint64) (value valueT, ok bool)

Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.

func (*Uint64Map[valueT]) LoadAndDelete

func (s *Uint64Map[valueT]) LoadAndDelete(key uint64) (value valueT, loaded bool)

LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present. (Modified from Delete)

func (*Uint64Map[valueT]) LoadOrStore

func (s *Uint64Map[valueT]) LoadOrStore(key uint64, value valueT) (actual valueT, loaded bool)

LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored. (Modified from Store)

func (*Uint64Map[valueT]) LoadOrStoreLazy added in v0.7.0

func (s *Uint64Map[valueT]) LoadOrStoreLazy(key uint64, f func() valueT) (actual valueT, loaded bool)

LoadOrStoreLazy returns the existing value for the key if present. Otherwise, it stores and returns the given value from f, f will only be called once. The loaded result is true if the value was loaded, false if stored. (Modified from LoadOrStore)

func (*Uint64Map[valueT]) Range

func (s *Uint64Map[valueT]) Range(f func(key uint64, value valueT) bool)

Range calls f sequentially for each key and value present in the skipmap. If f returns false, range stops the iteration.

Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently, Range may reflect any mapping for that key from any point during the Range call.

func (*Uint64Map[valueT]) Store

func (s *Uint64Map[valueT]) Store(key uint64, value valueT)

Store sets the value for a key.

type Uint64MapDesc added in v0.3.0

type Uint64MapDesc[valueT any] struct {
	// contains filtered or unexported fields
}

Uint64MapDesc represents a map based on skip list.

func NewUint64Desc added in v0.3.0

func NewUint64Desc[valueT any]() *Uint64MapDesc[valueT]

NewUint64Desc returns an empty skipmap in descending order.

func (*Uint64MapDesc[valueT]) Delete added in v0.3.0

func (s *Uint64MapDesc[valueT]) Delete(key uint64) bool

Delete deletes the value for a key.

func (*Uint64MapDesc[valueT]) Len added in v0.3.0

func (s *Uint64MapDesc[valueT]) Len() int

Len returns the length of this skipmap.

func (*Uint64MapDesc[valueT]) Load added in v0.3.0

func (s *Uint64MapDesc[valueT]) Load(key uint64) (value valueT, ok bool)

Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.

func (*Uint64MapDesc[valueT]) LoadAndDelete added in v0.3.0

func (s *Uint64MapDesc[valueT]) LoadAndDelete(key uint64) (value valueT, loaded bool)

LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present. (Modified from Delete)

func (*Uint64MapDesc[valueT]) LoadOrStore added in v0.3.0

func (s *Uint64MapDesc[valueT]) LoadOrStore(key uint64, value valueT) (actual valueT, loaded bool)

LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored. (Modified from Store)

func (*Uint64MapDesc[valueT]) LoadOrStoreLazy added in v0.7.0

func (s *Uint64MapDesc[valueT]) LoadOrStoreLazy(key uint64, f func() valueT) (actual valueT, loaded bool)

LoadOrStoreLazy returns the existing value for the key if present. Otherwise, it stores and returns the given value from f, f will only be called once. The loaded result is true if the value was loaded, false if stored. (Modified from LoadOrStore)

func (*Uint64MapDesc[valueT]) Range added in v0.3.0

func (s *Uint64MapDesc[valueT]) Range(f func(key uint64, value valueT) bool)

Range calls f sequentially for each key and value present in the skipmap. If f returns false, range stops the iteration.

Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently, Range may reflect any mapping for that key from any point during the Range call.

func (*Uint64MapDesc[valueT]) Store added in v0.3.0

func (s *Uint64MapDesc[valueT]) Store(key uint64, value valueT)

Store sets the value for a key.

type UintMap

type UintMap[valueT any] struct {
	// contains filtered or unexported fields
}

UintMap represents a map based on skip list.

func NewUint

func NewUint[valueT any]() *UintMap[valueT]

NewUint returns an empty skipmap in ascending order.

func (*UintMap[valueT]) Delete

func (s *UintMap[valueT]) Delete(key uint) bool

Delete deletes the value for a key.

func (*UintMap[valueT]) Len

func (s *UintMap[valueT]) Len() int

Len returns the length of this skipmap.

func (*UintMap[valueT]) Load

func (s *UintMap[valueT]) Load(key uint) (value valueT, ok bool)

Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.

func (*UintMap[valueT]) LoadAndDelete

func (s *UintMap[valueT]) LoadAndDelete(key uint) (value valueT, loaded bool)

LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present. (Modified from Delete)

func (*UintMap[valueT]) LoadOrStore

func (s *UintMap[valueT]) LoadOrStore(key uint, value valueT) (actual valueT, loaded bool)

LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored. (Modified from Store)

func (*UintMap[valueT]) LoadOrStoreLazy added in v0.7.0

func (s *UintMap[valueT]) LoadOrStoreLazy(key uint, f func() valueT) (actual valueT, loaded bool)

LoadOrStoreLazy returns the existing value for the key if present. Otherwise, it stores and returns the given value from f, f will only be called once. The loaded result is true if the value was loaded, false if stored. (Modified from LoadOrStore)

func (*UintMap[valueT]) Range

func (s *UintMap[valueT]) Range(f func(key uint, value valueT) bool)

Range calls f sequentially for each key and value present in the skipmap. If f returns false, range stops the iteration.

Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently, Range may reflect any mapping for that key from any point during the Range call.

func (*UintMap[valueT]) Store

func (s *UintMap[valueT]) Store(key uint, value valueT)

Store sets the value for a key.

type UintMapDesc added in v0.3.0

type UintMapDesc[valueT any] struct {
	// contains filtered or unexported fields
}

UintMapDesc represents a map based on skip list.

func NewUintDesc added in v0.3.0

func NewUintDesc[valueT any]() *UintMapDesc[valueT]

NewUintDesc returns an empty skipmap in descending order.

func (*UintMapDesc[valueT]) Delete added in v0.3.0

func (s *UintMapDesc[valueT]) Delete(key uint) bool

Delete deletes the value for a key.

func (*UintMapDesc[valueT]) Len added in v0.3.0

func (s *UintMapDesc[valueT]) Len() int

Len returns the length of this skipmap.

func (*UintMapDesc[valueT]) Load added in v0.3.0

func (s *UintMapDesc[valueT]) Load(key uint) (value valueT, ok bool)

Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.

func (*UintMapDesc[valueT]) LoadAndDelete added in v0.3.0

func (s *UintMapDesc[valueT]) LoadAndDelete(key uint) (value valueT, loaded bool)

LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present. (Modified from Delete)

func (*UintMapDesc[valueT]) LoadOrStore added in v0.3.0

func (s *UintMapDesc[valueT]) LoadOrStore(key uint, value valueT) (actual valueT, loaded bool)

LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored. (Modified from Store)

func (*UintMapDesc[valueT]) LoadOrStoreLazy added in v0.7.0

func (s *UintMapDesc[valueT]) LoadOrStoreLazy(key uint, f func() valueT) (actual valueT, loaded bool)

LoadOrStoreLazy returns the existing value for the key if present. Otherwise, it stores and returns the given value from f, f will only be called once. The loaded result is true if the value was loaded, false if stored. (Modified from LoadOrStore)

func (*UintMapDesc[valueT]) Range added in v0.3.0

func (s *UintMapDesc[valueT]) Range(f func(key uint, value valueT) bool)

Range calls f sequentially for each key and value present in the skipmap. If f returns false, range stops the iteration.

Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently, Range may reflect any mapping for that key from any point during the Range call.

func (*UintMapDesc[valueT]) Store added in v0.3.0

func (s *UintMapDesc[valueT]) Store(key uint, value valueT)

Store sets the value for a key.

Jump to

Keyboard shortcuts

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