Documentation
¶
Index ¶
- Constants
- type OrderedMap
- func (t *OrderedMap[K, V]) Contains(key K) bool
- func (t *OrderedMap[K, V]) Delete(key K)
- func (t *OrderedMap[K, V]) DeleteMax()
- func (t *OrderedMap[K, V]) DeleteMin()
- func (t *OrderedMap[K, V]) Get(key K) (V, bool)
- func (t *OrderedMap[K, V]) IsEmpty() bool
- func (t *OrderedMap[K, V]) Keys() []K
- func (t *OrderedMap[K, V]) KeysInRange(lo, hi K) []K
- func (t *OrderedMap[K, V]) KeysInRangeBFS() []K
- func (t *OrderedMap[K, V]) Max() (K, bool)
- func (t *OrderedMap[K, V]) Min() (K, bool)
- func (t *OrderedMap[K, V]) Put(key K, val V)
- func (t *OrderedMap[K, V]) Size() int
Constants ¶
const ( RED color = true BLACK color = false )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OrderedMap ¶
type OrderedMap[K constraints.Ordered, V any] struct { // contains filtered or unexported fields }
func NewOrderedMap ¶
func NewOrderedMap[K constraints.Ordered, V any]() *OrderedMap[K, V]
NewOrderedMap creates and returns a new empty OrderedMap.
func (*OrderedMap[K, V]) Contains ¶
func (t *OrderedMap[K, V]) Contains(key K) bool
Contains checks if the given key exists in the OrderedMap.
func (*OrderedMap[K, V]) Delete ¶
func (t *OrderedMap[K, V]) Delete(key K)
Delete removes the key-value pair with the given key from the OrderedMap. If the key doesn't exist, this operation does nothing.
func (*OrderedMap[K, V]) DeleteMax ¶
func (t *OrderedMap[K, V]) DeleteMax()
DeleteMax removes the largest key and associated value from the map.
func (*OrderedMap[K, V]) DeleteMin ¶
func (t *OrderedMap[K, V]) DeleteMin()
DeleteMin removes the smallest key and associated value from the map.
func (*OrderedMap[K, V]) Get ¶
func (t *OrderedMap[K, V]) Get(key K) (V, bool)
Get retrieves the value associated with the given key.
func (*OrderedMap[K, V]) IsEmpty ¶
func (t *OrderedMap[K, V]) IsEmpty() bool
IsEmpty returns true if the OrderedMap contains no elements, false otherwise.
func (*OrderedMap[K, V]) Keys ¶
func (t *OrderedMap[K, V]) Keys() []K
Keys returns a slice containing all keys in the OrderedMap in sorted order.
func (*OrderedMap[K, V]) KeysInRange ¶
func (t *OrderedMap[K, V]) KeysInRange(lo, hi K) []K
KeysInRange returns a slice of all keys in the OrderedMap between lo and hi, inclusive.
func (*OrderedMap[K, V]) KeysInRangeBFS ¶
func (t *OrderedMap[K, V]) KeysInRangeBFS() []K
func (*OrderedMap[K, V]) Max ¶
func (t *OrderedMap[K, V]) Max() (K, bool)
Max returns the largest key in the OrderedMap and a boolean indicating success. If the map is empty, it returns the zero value of K and false.
func (*OrderedMap[K, V]) Min ¶
func (t *OrderedMap[K, V]) Min() (K, bool)
Min returns the smallest key in the OrderedMap and a boolean indicating success. If the map is empty, it returns the zero value of K and false.
func (*OrderedMap[K, V]) Put ¶
func (t *OrderedMap[K, V]) Put(key K, val V)
Put inserts a key-value pair into the OrderedMap. If the key already exists, its value is updated.
func (*OrderedMap[K, V]) Size ¶
func (t *OrderedMap[K, V]) Size() int
Size returns the number of key-value pairs in the OrderedMap.