pmaps

package
v0.4.46 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2023 License: ISC Imports: 8 Imported by: 1

Documentation

Overview

Ranking is a pointer-identity-to-value map of updatable values traversable by rank. Ranking implements parli.Ranking[V comparable, R constraints.Ordered].

KeyOrderedMap is a mapping whose keys are provided in order

KeyOrderedMapAny is a mapping of uncomparable keys whose keys are ordered by a key-order function

KeyOrderedMap is a mapping whose keys are provided in order

OrderedMapAny is a mapping of uncomparable keys whose keys are ordered by a key-order function

OrderedMap is a mapping whose values are provided in order

RankingThreadSafe is a thread-safe pointer-identity-to-value map of updatable values traversable by rank. RankingThreadSafe implements parli.Ranking[V comparable, R constraints.Ordered].

Ranking is a pointer-identity-to-value map of updatable values traversable by rank. Ranking implements parli.Ranking[V comparable, R constraints.Ordered].

RWMap is a one-liner thread-safe mapping. RWMap implements parli.ThreadSafeMap[K comparable, V any].

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAggregatePriority added in v0.4.30

func NewAggregatePriority[V any, P constraints.Ordered](
	value *V,
	index int,
	aggregator parli.Aggregator[V, P],
) (aggregatePriority parli.AggregatePriority[V, P])

func NewAggregatingPriorityQueue added in v0.4.30

func NewAggregatingPriorityQueue[V any, P constraints.Ordered]() (priorityQueue parli.AggregatingPriorityQueue[V, P])

NewRanking returns a map of updatable values traversable by rank

func NewPriorityQueue added in v0.4.30

func NewPriorityQueue[V any, P constraints.Ordered](
	priorityFunc func(value *V) (priority P),
) (priorityQueue parli.PriorityQueue[V, P])

NewPriorityQueue returns a map of updatable values traversable by rank

func NewPriorityQueueThreadSafe added in v0.4.30

func NewPriorityQueueThreadSafe[V any, P constraints.Ordered](
	ranker func(value *V) (rank P),
) (o1 parli.PriorityQueue[V, P])

NewRanking returns a thread-safe map of updatable values traversable by rank

func NewRWMap

func NewRWMap[K comparable, V any]() (rwMap parli.ThreadSafeMap[K, V])

NewRWMap returns a thread-safe map implementation

Types

type AggregatePriority added in v0.4.30

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

func (*AggregatePriority[V, P]) Aggregator added in v0.4.30

func (ap *AggregatePriority[V, P]) Aggregator() (aggregator parli.Aggregator[V, P])

func (*AggregatePriority[V, P]) CachedPriority added in v0.4.30

func (ap *AggregatePriority[V, P]) CachedPriority() (priority P)

func (*AggregatePriority[V, P]) Cmp added in v0.4.30

func (a *AggregatePriority[V, P]) Cmp(b parli.AggregatePriority[V, P]) (result int)

func (*AggregatePriority[V, P]) Update added in v0.4.30

func (ap *AggregatePriority[V, P]) Update()

type AggregatingPriorityQueue added in v0.4.30

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

func (*AggregatingPriorityQueue[V, P]) Clear added in v0.4.30

func (pq *AggregatingPriorityQueue[V, P]) Clear()

Clear empties the priority queue. The hashmap is left intact.

func (*AggregatingPriorityQueue[V, P]) Cmp added in v0.4.30

func (pq *AggregatingPriorityQueue[V, P]) Cmp(a, b parli.AggregatePriority[V, P]) (result int)

Cmp returns a comparison of two AggregatePriority objects that represents value elements.

  • Cmp is a custom comparison function to be sued with pslices and slices packages
  • Cmp makes AggregatePriority ordered

func (*AggregatingPriorityQueue[V, P]) Get added in v0.4.30

func (pq *AggregatingPriorityQueue[V, P]) Get(valuep *V) (aggregator parli.Aggregator[V, P], ok bool)

Get retrieves a possible value container associated with valuep

func (*AggregatingPriorityQueue[V, P]) List added in v0.4.30

func (pq *AggregatingPriorityQueue[V, P]) List(n ...int) (aggregatorQueue []parli.AggregatePriority[V, P])

List returns the first n or default all values by pirority

func (*AggregatingPriorityQueue[V, P]) Put added in v0.4.30

func (pq *AggregatingPriorityQueue[V, P]) Put(valuep *V, aggregator parli.Aggregator[V, P])

Put stores a new value container associated with valuep

  • the valuep is asusmed to not have a node in the queue

func (*AggregatingPriorityQueue[V, P]) Update added in v0.4.30

func (pq *AggregatingPriorityQueue[V, P]) Update(valuep *V)

Update re-prioritizes a value

type AssignedPriority added in v0.4.30

type AssignedPriority[V any, P constraints.Ordered] struct {
	Priority P
	Index    int
	Value    *V
}

AssignedPriority contains the assigned priority for a priority-queue element

  • V is the element value type whose pointer-value provides identity
  • P is the priority, a descending-ordered type
  • Index is insertion order, lowest-value first

func NewAssignedPriority added in v0.4.30

func NewAssignedPriority[V any, P constraints.Ordered](priority P, index int, value *V) (assignedPriority *AssignedPriority[V, P])

func (*AssignedPriority[V, P]) Cmp added in v0.4.30

func (a *AssignedPriority[V, P]) Cmp(b *AssignedPriority[V, P]) (result int)

Cmp sorts descending: -1 results appears first

func (*AssignedPriority[V, P]) SetPriority added in v0.4.30

func (ap *AssignedPriority[V, P]) SetPriority(priority P)

type KeyInsOrderedMap added in v0.4.39

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

KeyInsOrderedMap is a mapping whose keys are provided in insertion order

func NewKeyInsOrderedMap added in v0.4.39

func NewKeyInsOrderedMap[K constraints.Ordered, V any]() (orderedMap *KeyInsOrderedMap[K, V])

NewKeyInsOrderedMap is a mapping whose keys are provided in insertion order

func (*KeyInsOrderedMap[K, V]) Clone added in v0.4.39

func (mp *KeyInsOrderedMap[K, V]) Clone() (clone *KeyInsOrderedMap[K, V])

Clone returns a shallow clone of the map

func (*KeyInsOrderedMap[K, V]) Delete added in v0.4.39

func (mp *KeyInsOrderedMap[K, V]) Delete(key K)

Delete removes mapping using key K.

  • if key K is not mapped, the map is unchanged.
  • O(log n)

func (*KeyInsOrderedMap[K, V]) List added in v0.4.39

func (mp *KeyInsOrderedMap[K, V]) List(n ...int) (list []K)

List provides the mapped values in order

  • O(n)

func (*KeyInsOrderedMap[K, V]) Put added in v0.4.39

func (mp *KeyInsOrderedMap[K, V]) Put(key K, value V)

Put saves or replaces a mapping

type KeyOrderedMap added in v0.4.32

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

KeyOrderedMap is a mapping whose keys are provided in order

func NewKeyOrderedMap added in v0.4.32

func NewKeyOrderedMap[K constraints.Ordered, V any]() (orderedMap *KeyOrderedMap[K, V])

func (*KeyOrderedMap[K, V]) Clone added in v0.4.32

func (mp *KeyOrderedMap[K, V]) Clone() (clone *KeyOrderedMap[K, V])

Clone returns a shallow clone of the map

func (*KeyOrderedMap[K, V]) Delete added in v0.4.32

func (mp *KeyOrderedMap[K, V]) Delete(key K)

Delete removes mapping using key K.

  • if key K is not mapped, the map is unchanged.
  • O(log n)

func (*KeyOrderedMap[K, V]) List added in v0.4.32

func (mp *KeyOrderedMap[K, V]) List(n ...int) (list []K)

List provides the mapped values in order

  • O(n)

func (*KeyOrderedMap[K, V]) Put added in v0.4.32

func (mp *KeyOrderedMap[K, V]) Put(key K, value V)

Put saves or replaces a mapping

type KeyOrderedMapAny added in v0.4.32

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

KeyOrderedMapAny is a mapping of uncomparable keys whose keys are ordered by a key-order function

func NewKeyOrderedMapAny added in v0.4.32

func NewKeyOrderedMapAny[K any, O constraints.Ordered, V any](
	keyOrderFunc func(key K) (order O),
) (orderedMap *KeyOrderedMapAny[K, O, V])

func (*KeyOrderedMapAny[K, O, V]) Clone added in v0.4.32

func (mp *KeyOrderedMapAny[K, O, V]) Clone() (clone *KeyOrderedMapAny[K, O, V])

Clone returns a shallow clone of the map

func (*KeyOrderedMapAny[K, O, V]) Cmp added in v0.4.32

func (mp *KeyOrderedMapAny[K, O, V]) Cmp(a, b K) (result int)

func (*KeyOrderedMapAny[K, O, V]) Delete added in v0.4.32

func (mp *KeyOrderedMapAny[K, O, V]) Delete(key K)

Delete removes mapping using key K.

  • if key K is not mapped, the map is unchanged.
  • O(log n)

func (*KeyOrderedMapAny[K, O, V]) Get added in v0.4.32

func (mp *KeyOrderedMapAny[K, O, V]) Get(key K) (value V, ok bool)

Get returns the value mapped by key or the V zero-value otherwise.

  • the ok return value is true if a mapping was found.
  • O(1)

func (*KeyOrderedMapAny[K, O, V]) List added in v0.4.32

func (mp *KeyOrderedMapAny[K, O, V]) List(n ...int) (list []K)

List provides the mapped values in order

  • O(n)

func (*KeyOrderedMapAny[K, O, V]) Put added in v0.4.32

func (mp *KeyOrderedMapAny[K, O, V]) Put(key K, value V)

Put saves or replaces a mapping

type Map added in v0.4.32

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

func NewMap added in v0.4.32

func NewMap[K comparable, V any]() (mp *Map[K, V])

func (*Map[K, V]) Clear added in v0.4.32

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

Clear empties the map

func (*Map[K, V]) Clone added in v0.4.32

func (mp *Map[K, V]) Clone() (clone *Map[K, V])

Clone returns a shallow clone of the map

func (*Map[K, V]) Delete added in v0.4.32

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

Delete removes mapping using key K.

  • if key K is not mapped, the map is unchanged.
  • O(log n)

func (*Map[K, V]) Get added in v0.4.32

func (mp *Map[K, V]) Get(key K) (value V, ok bool)

Get returns the value mapped by key or the V zero-value otherwise.

  • the ok return value is true if a mapping was found.
  • O(1)

func (*Map[K, V]) Length added in v0.4.32

func (mp *Map[K, V]) Length() (length int)

Length returns the number of mappings

func (*Map[K, V]) List added in v0.4.32

func (mp *Map[K, V]) List() (list []V)

List provides the mapped values, undefined ordering

  • O(n)

func (*Map[K, V]) Put added in v0.4.32

func (mp *Map[K, V]) Put(key K, value V)

Put saves or replaces a mapping

type OrderedMap added in v0.4.32

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

OrderedMap is a mapping whose values are provided in order

func NewOrderedMap added in v0.4.32

func NewOrderedMap[K comparable, V constraints.Ordered]() (orderedMap *OrderedMap[K, V])

NewOrderedMap returns a mapping whose values are provided in order

func (*OrderedMap[K, V]) Clone added in v0.4.32

func (mp *OrderedMap[K, V]) Clone() (clone *OrderedMap[K, V])

Clone returns a shallow clone of the map

func (*OrderedMap[K, V]) Delete added in v0.4.32

func (mp *OrderedMap[K, V]) Delete(key K)

Delete removes mapping using key K.

  • if key K is not mapped, the map is unchanged.
  • O(log n)

func (*OrderedMap[K, V]) List added in v0.4.32

func (mp *OrderedMap[K, V]) List(n ...int) (list []V)

List provides the mapped values in order

  • O(n)

func (*OrderedMap[K, V]) Put added in v0.4.32

func (mp *OrderedMap[K, V]) Put(key K, value V)

Put saves or replaces a mapping

type OrderedMapAny added in v0.4.41

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

OrderedMapAny is a mapping of uncomparable keys whose keys are ordered by a key-order function

func NewOrderedMapAny added in v0.4.41

func NewOrderedMapAny[K comparable, O constraints.Ordered, V any](
	valueOrderFunc func(value V) (order O),
) (orderedMap *OrderedMapAny[K, O, V])

func (*OrderedMapAny[K, O, V]) Clone added in v0.4.41

func (mp *OrderedMapAny[K, O, V]) Clone() (clone *OrderedMapAny[K, O, V])

Clone returns a shallow clone of the map

func (*OrderedMapAny[K, O, V]) Cmp added in v0.4.41

func (mp *OrderedMapAny[K, O, V]) Cmp(a, b V) (result int)

func (*OrderedMapAny[K, O, V]) Delete added in v0.4.41

func (mp *OrderedMapAny[K, O, V]) Delete(key K)

Delete removes mapping using key K.

  • if key K is not mapped, the map is unchanged.
  • O(log n)

func (*OrderedMapAny[K, O, V]) Get added in v0.4.41

func (mp *OrderedMapAny[K, O, V]) Get(key K) (value V, ok bool)

Get returns the value mapped by key or the V zero-value otherwise.

  • the ok return value is true if a mapping was found.
  • O(1)

func (*OrderedMapAny[K, O, V]) List added in v0.4.41

func (mp *OrderedMapAny[K, O, V]) List(n ...int) (list []V)

List provides the mapped values in order

  • O(n)

func (*OrderedMapAny[K, O, V]) Put added in v0.4.41

func (mp *OrderedMapAny[K, O, V]) Put(key K, value V)

Put saves or replaces a mapping

type PriorityQueue added in v0.4.30

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

PriorityQueue is a pointer-identity-to-value map of updatable values traversable by rank. PriorityQueue implements parli.PriorityQueue[V comparable, R constraints.Ordered].

  • V is a value reference composite type that is comparable, ie. not slice map function. Preferrably, V is interface or pointer to struct type.
  • R is an ordered type such as int floating-point string, used to rank the V values
  • values are added or updated using AddOrUpdate method distinguished by (computer science) identity
  • if the same comparable value V is added again, that value is re-ranked
  • rank R is computed from a value V using the ranker function. The ranker function may be examining field values of a struct
  • values can have the same rank. If they do, equal rank is provided in insertion order

func (*PriorityQueue[V, P]) AddOrUpdate added in v0.4.30

func (pq *PriorityQueue[V, P]) AddOrUpdate(valuep *V)

AddOrUpdate adds a new value to the ranking or updates the ranking of a value that has changed.

func (*PriorityQueue[V, P]) List added in v0.4.30

func (pq *PriorityQueue[V, P]) List(n ...int) (valueQueue []*V)

List returns the first n or default all values by rank

type PriorityQueueThreadSafe added in v0.4.30

type PriorityQueueThreadSafe[V any, P constraints.Ordered] struct {
	parli.PriorityQueue[V, P]
	// contains filtered or unexported fields
}

PriorityQueueThreadSafe is a thread-safe pointer-identity-to-value map of updatable values traversable by rank. PriorityQueueThreadSafe implements parli.Ranking[V comparable, R constraints.Ordered].

  • V is a value reference composite type that is comparable, ie. not slice map function. Preferrably, V is interface or pointer to struct type.
  • P is an ordered type such as int floating-point string, used to rank the V values
  • values are added or updated using AddOrUpdate method distinguished by (computer science) identity
  • if the same comparable value V is added again, that value is re-ranked
  • rank R is computed from a value V using the ranker function. The ranker function may be examining field values of a struct
  • values can have the same rank. If they do, equal rank is provided in insertion order

func (*PriorityQueueThreadSafe[V, P]) AddOrUpdate added in v0.4.30

func (mp *PriorityQueueThreadSafe[V, P]) AddOrUpdate(value *V)

AddOrUpdate adds a new value to the ranking or updates the ranking of a value that has changed.

func (*PriorityQueueThreadSafe[V, P]) List added in v0.4.30

func (mp *PriorityQueueThreadSafe[V, P]) List(n ...int) (list []*V)

List returns the first n or default all values by rank

type RWMap

type RWMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

RWMap is a one-liner thread-safe mapping. RWMap implements parli.ThreadSafeMap[K comparable, V any].

  • GetOrCreate method is an atomic, thread-safe operation as opposed to Get-then-Put
  • Swap and PutIf are atomic, thread-safe operations
  • V is copied so if size of V is large or V contains locks, use pointer
  • RWMap uses reader/writer mutual exclusion lock for slightly higher performance.
  • Get methods are O(1)

func NewRWMap2 added in v0.4.34

func NewRWMap2[K comparable, V any]() (rwMap *RWMap[K, V])

func (*RWMap[K, V]) Clear

func (rw *RWMap[K, V]) Clear()

Clear empties the map

func (*RWMap[K, V]) Clone

func (rw *RWMap[K, V]) Clone() (clone parli.ThreadSafeMap[K, V])

Clone returns a shallow clone of the map

func (*RWMap[K, V]) Delete

func (rw *RWMap[K, V]) Delete(key K)

Delete removes mapping using key K.

  • if key K is not mapped, the map is unchanged.
  • O(log n)

func (*RWMap[K, V]) Get

func (rw *RWMap[K, V]) Get(key K) (value V, ok bool)

Get returns the value mapped by key or the V zero-value otherwise.

  • the ok return value is true if a mapping was found.
  • O(1)

func (*RWMap[K, V]) GetOrCreate

func (rw *RWMap[K, V]) GetOrCreate(
	key K,
	newV func() (value *V),
	makeV func() (value V),
) (value V, ok bool)

GetOrCreate returns an item from the map if it exists otherwise creates it.

  • newV or makeV are invoked in the critical section, ie. these functions may not access the map or deadlock
  • if a key is mapped, its value is returned
  • otherwise, if newV and makeV are both nil, nil is returned.
  • otherwise, if newV is present, it is invoked to return a pointer ot a value. A nil return value from newV causes panic. A new mapping is created using the value pointed to by the newV return value.
  • otherwise, a mapping is created using whatever makeV returns
  • newV and makeV may not access the map. The map’s write lock is held during their execution
  • GetOrCreate is an atomic, thread-safe operation
  • value insert is O(log n)

func (*RWMap[K, V]) Length

func (rw *RWMap[K, V]) Length() (length int)

Length returns the number of mappings

func (*RWMap[K, V]) List

func (rw *RWMap[K, V]) List() (list []V)

List provides the mapped values, undefined ordering

  • O(n)

func (*RWMap[K, V]) Put

func (rw *RWMap[K, V]) Put(key K, value V)

Put saves or replaces a mapping

func (*RWMap[K, V]) PutIf added in v0.4.39

func (rw *RWMap[K, V]) PutIf(key K, value V, putIf func(value V) (doPut bool)) (wasNewKey bool)

Putif is conditional Put depending on the return value from the putIf function.

  • if key does not exist in the map, the put is carried out and wasNewKey is true
  • if key exists and putIf is nil or returns true, the put is carried out and wasNewKey is false
  • if key exists and putIf returns false, the put is not carried out and wasNewKey is false
  • during PutIf, the map cannot be accessed and the map’s write-lock is held
  • PutIf is an atomic, thread-safe operation

func (*RWMap[K, V]) Swap added in v0.4.39

func (rw *RWMap[K, V]) Swap(otherMap parli.ThreadSafeMap[K, V]) (previousMap parli.ThreadSafeMap[K, V])

Swap replaces the map with otherMap and returns the current map in previousMap

  • if otherMap is not RWMap, no swap takes place and previousMap is nil
  • Swap is an atomic, thread-safe operation

type ThreadSafeKeyOrderedMap added in v0.4.43

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

ThreadSafeKeyOrderedMap is a mapping whose values are provided in order. Thread-safe.

func NewThreadSafeKeyOrderedMap added in v0.4.43

func NewThreadSafeKeyOrderedMap[K constraints.Ordered, V constraints.Ordered]() (orderedMap *ThreadSafeKeyOrderedMap[K, V])

func (*ThreadSafeKeyOrderedMap[K, V]) Clear added in v0.4.43

func (mp *ThreadSafeKeyOrderedMap[K, V]) Clear()

Clear empties the map

func (*ThreadSafeKeyOrderedMap[K, V]) Clone added in v0.4.43

func (mp *ThreadSafeKeyOrderedMap[K, V]) Clone() (clone *ThreadSafeKeyOrderedMap[K, V])

Clone returns a shallow clone of the map

func (*ThreadSafeKeyOrderedMap[K, V]) Delete added in v0.4.43

func (mp *ThreadSafeKeyOrderedMap[K, V]) Delete(key K)

Delete removes mapping using key K.

  • if key K is not mapped, the map is unchanged.
  • O(log n)

func (*ThreadSafeKeyOrderedMap[K, V]) Get added in v0.4.43

func (mp *ThreadSafeKeyOrderedMap[K, V]) Get(key K) (value V, ok bool)

func (*ThreadSafeKeyOrderedMap[K, V]) Length added in v0.4.43

func (mp *ThreadSafeKeyOrderedMap[K, V]) Length() (length int)

func (*ThreadSafeKeyOrderedMap[K, V]) List added in v0.4.43

func (mp *ThreadSafeKeyOrderedMap[K, V]) List(n ...int) (list []K)

List provides the mapped values in order

  • O(n)

func (*ThreadSafeKeyOrderedMap[K, V]) Put added in v0.4.43

func (mp *ThreadSafeKeyOrderedMap[K, V]) Put(key K, value V)

Put saves or replaces a mapping

type ThreadSafeOrderedMap added in v0.4.41

type ThreadSafeOrderedMap[K comparable, V constraints.Ordered] struct {
	OrderedMap[K, V]
	// contains filtered or unexported fields
}

ThreadSafeOrderedMap is a mapping whose values are provided in order. Thread-safe.

func NewThreadSafeOrderedMap added in v0.4.41

func NewThreadSafeOrderedMap[K comparable, V constraints.Ordered]() (orderedMap *ThreadSafeOrderedMap[K, V])

func (*ThreadSafeOrderedMap[K, V]) Clear added in v0.4.41

func (mp *ThreadSafeOrderedMap[K, V]) Clear()

Clear empties the map

func (*ThreadSafeOrderedMap[K, V]) Clone added in v0.4.41

func (mp *ThreadSafeOrderedMap[K, V]) Clone() (clone *ThreadSafeOrderedMap[K, V])

Clone returns a shallow clone of the map

func (*ThreadSafeOrderedMap[K, V]) Delete added in v0.4.41

func (mp *ThreadSafeOrderedMap[K, V]) Delete(key K)

Delete removes mapping using key K.

  • if key K is not mapped, the map is unchanged.
  • O(log n)

func (*ThreadSafeOrderedMap[K, V]) Get added in v0.4.41

func (mp *ThreadSafeOrderedMap[K, V]) Get(key K) (value V, ok bool)

func (*ThreadSafeOrderedMap[K, V]) Length added in v0.4.41

func (mp *ThreadSafeOrderedMap[K, V]) Length() (length int)

func (*ThreadSafeOrderedMap[K, V]) List added in v0.4.41

func (mp *ThreadSafeOrderedMap[K, V]) List(n ...int) (list []V)

List provides the mapped values in order

  • O(n)

func (*ThreadSafeOrderedMap[K, V]) Put added in v0.4.41

func (mp *ThreadSafeOrderedMap[K, V]) Put(key K, value V)

Put saves or replaces a mapping

type ThreadSafeOrderedMapAny added in v0.4.41

type ThreadSafeOrderedMapAny[K comparable, O constraints.Ordered, V any] struct {
	OrderedMapAny[K, O, V]
	// contains filtered or unexported fields
}

ThreadSafeOrderedMapAny is a mapping whose values are provided in order. Thread-safe.

func NewThreadSafeOrderedMapAny added in v0.4.41

func NewThreadSafeOrderedMapAny[K comparable, O constraints.Ordered, V any](
	valueOrderFunc func(value V) (order O),
) (orderedMap *ThreadSafeOrderedMapAny[K, O, V])

func (*ThreadSafeOrderedMapAny[K, O, V]) Clear added in v0.4.41

func (mp *ThreadSafeOrderedMapAny[K, O, V]) Clear()

Clear empties the map

func (*ThreadSafeOrderedMapAny[K, O, V]) Clone added in v0.4.41

func (mp *ThreadSafeOrderedMapAny[K, O, V]) Clone() (clone *ThreadSafeOrderedMapAny[K, O, V])

Clone returns a shallow clone of the map

func (*ThreadSafeOrderedMapAny[K, O, V]) Delete added in v0.4.41

func (mp *ThreadSafeOrderedMapAny[K, O, V]) Delete(key K)

Delete removes mapping using key K.

  • if key K is not mapped, the map is unchanged.
  • O(log n)

func (*ThreadSafeOrderedMapAny[K, O, V]) Get added in v0.4.41

func (mp *ThreadSafeOrderedMapAny[K, O, V]) Get(key K) (value V, ok bool)

func (*ThreadSafeOrderedMapAny[K, O, V]) Length added in v0.4.41

func (mp *ThreadSafeOrderedMapAny[K, O, V]) Length() (length int)

func (*ThreadSafeOrderedMapAny[K, O, V]) List added in v0.4.41

func (mp *ThreadSafeOrderedMapAny[K, O, V]) List(n ...int) (list []V)

List provides the mapped values in order

  • O(n)

func (*ThreadSafeOrderedMapAny[K, O, V]) Put added in v0.4.41

func (mp *ThreadSafeOrderedMapAny[K, O, V]) Put(key K, value V)

Put saves or replaces a mapping

Jump to

Keyboard shortcuts

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