Documentation
¶
Overview ¶
Package data_structure implements data structure functionality
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Filter ¶ added in v1.1303.0
Filter returns a new slice containing only the elements of the input slice that satisfy the predicate. The input slice is not modified. Parameters:
- s: The input slice to filter.
- keep: A predicate function that returns true for elements to keep.
Returns:
- A new slice containing only the elements that satisfy the predicate.
func Map ¶ added in v1.1303.0
Map returns a new slice containing the results of applying the function to each element of the input slice. The input slice is not modified. Parameters:
- s: The input slice to map.
- fn: A function that takes an element of the input slice and returns a result.
Returns:
- A new slice containing the results of applying the function to each element of the input slice.
func Unique ¶ added in v1.1303.0
func Unique[T comparable](slice []T) []T
Unique returns a new slice containing only the unique elements of the input slice.
Types ¶
type OrderedMap ¶
type OrderedMap[K comparable, V any] struct { // contains filtered or unexported fields }
func NewOrderedMap ¶
func NewOrderedMap[K comparable, V any]() *OrderedMap[K, V]
func (*OrderedMap[K, V]) Add ¶
func (m *OrderedMap[K, V]) Add(key K, value V)
func (*OrderedMap[K, V]) Get ¶
func (m *OrderedMap[K, V]) Get(key K) (value V, ok bool)
func (*OrderedMap[K, V]) Keys ¶
func (m *OrderedMap[K, V]) Keys() []K
Click to show internal directories.
Click to hide internal directories.