Documentation
¶
Overview ¶
Package sortedmap provides a sorted map implementation. It is kindly taken from https://github.com/gobs/sortedmap under the MIT license.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KeyValuePair ¶
type KeyValuePair[K constraints.Ordered, T any] struct { Key K Value T }
KeyValuePair describes an entry in SortedMap
func (KeyValuePair[K, T]) String ¶
func (e KeyValuePair[K, T]) String() string
String implements the Stringer interface for KeyValuePair
type SortedMap ¶
type SortedMap[K constraints.Ordered, T any] []KeyValuePair[K, T]
SortedMap is a structure that can sort a map[string]type by key
func AsSortedMap ¶
func AsSortedMap[K constraints.Ordered, T any](m map[K]T) SortedMap[K, T]
AsSortedMap return a SortedMap from a map[string]type. Note that this will panic if the input object is not a map
func (SortedMap[K, T]) Add ¶
Add adds an entry to a SortedMap (this requires re-sorting the SortedMap when ready to display). Note that a SortedMap is internally a slice, so you need to do something like:
s := NewSortedMap() s = s.Add(key1, value1) s = s.Add(key2, value2)
Click to show internal directories.
Click to hide internal directories.