nimble

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2022 License: MIT Imports: 0 Imported by: 3

README

nimble

Data structures and functional programming tools using generics

See unit tests for usage patterns

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter[T comparable](f func(v T) bool, values ...T) []T

Filter returns the filtered items from the input set, using the filter function

func Map

func Map[T any, U any](f func(v T) U, values ...T) []U

Map returns the original slice passed through the mapping function

func Unique

func Unique[T comparable](values ...T) []T

Unique returns a slice from the original containing only unique elements

Types

type Set

type Set[T comparable] struct {
	// contains filtered or unexported fields
}

func NewSet

func NewSet[T comparable](values ...T) *Set[T]

NewSet creates a new set, initialized with values

func (*Set[T]) Add

func (s *Set[T]) Add(value T)

Add adds a single value to the set

func (*Set[T]) Has

func (s *Set[T]) Has(value T) bool

Has returns true if the set already contains the provided value

func (*Set[T]) Remove

func (s *Set[T]) Remove(value T)

Remove removes the specified item from the set

func (*Set[T]) Size

func (s *Set[T]) Size() int

Size returns the size of the set

Jump to

Keyboard shortcuts

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