data_structure

package
v1.1303.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

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

func Filter[S ~[]E, E any](s S, keep func(E) bool) S

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

func Map[S ~[]E, E any, R any](s S, fn func(E) R) []R

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

Jump to

Keyboard shortcuts

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