Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OrderedMap ¶
type OrderedMap[K comparable, V any] interface { // Len returns the number of items in the map. Len() int // Get returns a value by a key, or false. Get(key K) (V, bool) // GetAt returns an item at a given index. GetAt(index int) (K, V) // Contains returns true if a key exists. Contains(key K) bool // IndexOf returns the index of a key, or -1. // The method takes O(n) time in the worst case. IndexOf(key K) int // Keys returns a slice of keys in the order they were inserted. Keys() []K // Values returns a slice of values in the order they were inserted. Values() []V // Clear deletes all items. Clear() // Clone returns a copy of the map. Clone() OrderedMap[K, V] // Delete deletes an item, and returns its value. // The method takes O(n) time in the worst case. Delete(key K) (V, bool) // Set sets an item. Set(key K, value V) }
OrderedMap is a map that maintains the insertion order of items.
func NewCap ¶
func NewCap[K comparable, V any](cap int) OrderedMap[K, V]
NewCap returns a new ordered map with a given capacity.
Click to show internal directories.
Click to hide internal directories.