ordered

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2025 License: BSD-3-Clause, MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeyTypeNotString = errors.New("key type must be string")
	ErrNilOrderedMap    = errors.New("calling MarshalJSON on nil OrderedMap")
)

Functions

This section is empty.

Types

type Map

type Map[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func MapMerge added in v0.3.0

func MapMerge[K comparable, V any](m ...*Map[K, V]) *Map[K, V]

OrderedMapMerge merges the given ordered maps into a new ordered map. Similar to array_merge in PHP.

func NewMap

func NewMap[K comparable, V any](opts ...Option) *Map[K, V]

func (*Map[K, V]) Clear

func (o *Map[K, V]) Clear()

func (*Map[K, V]) Clone

func (o *Map[K, V]) Clone() *Map[K, V]

func (*Map[K, V]) Contains added in v0.3.0

func (o *Map[K, V]) Contains(key K) bool

func (*Map[K, V]) Del

func (o *Map[K, V]) Del(key K)

func (*Map[K, V]) Get

func (o *Map[K, V]) Get(key K) V

func (*Map[K, V]) Iter

func (o *Map[K, V]) Iter(yield func(key K, value V) bool)

func (*Map[K, V]) IterKeys added in v0.3.0

func (o *Map[K, V]) IterKeys(yield func(key K) bool)

func (*Map[K, V]) IterValues added in v0.3.0

func (o *Map[K, V]) IterValues(yield func(value V) bool)

func (*Map[K, V]) Keys

func (o *Map[K, V]) Keys() []K

func (*Map[K, V]) Len

func (o *Map[K, V]) Len() int

func (*Map[K, V]) MarshalJSON

func (o *Map[K, V]) MarshalJSON() ([]byte, error)

func (*Map[K, V]) Reverse added in v0.3.0

func (o *Map[K, V]) Reverse()

func (*Map[K, V]) Set

func (o *Map[K, V]) Set(key K, value V)

func (*Map[K, V]) TryGet

func (o *Map[K, V]) TryGet(key K) (V, bool)

func (*Map[K, V]) Values

func (o *Map[K, V]) Values() []V

type Option

type Option func(*option)

func WithCapacity

func WithCapacity(capacity int) Option

type Set added in v0.3.0

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

func NewSet added in v0.3.0

func NewSet[T comparable](opts ...Option) *Set[T]

func (*Set[T]) Add added in v0.3.0

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

func (*Set[T]) Clear added in v0.3.0

func (s *Set[T]) Clear()

func (*Set[T]) Clone added in v0.3.0

func (s *Set[T]) Clone() *Set[T]

func (*Set[T]) Contains added in v0.3.0

func (s *Set[T]) Contains(key T) bool

func (*Set[T]) Iter added in v0.3.0

func (s *Set[T]) Iter(yield func(key T) bool)

func (*Set[T]) Len added in v0.3.0

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

func (*Set[T]) MarshalJSON added in v0.3.0

func (s *Set[T]) MarshalJSON() ([]byte, error)

func (*Set[T]) Remove added in v0.3.0

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

func (*Set[T]) Reverse added in v0.3.1

func (s *Set[T]) Reverse()

func (*Set[T]) UnmarshalJSON added in v0.3.0

func (s *Set[T]) UnmarshalJSON(data []byte) error

func (*Set[T]) Values added in v0.3.1

func (s *Set[T]) Values() []T

Jump to

Keyboard shortcuts

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