ordered

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: BSD-3-Clause, MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilOrderedMap = errors.New("calling MarshalJSON on nil OrderedMap")
)

Functions

func MapEquals added in v0.4.0

func MapEquals[K MapKey, V comparable](a, b *Map[K, V]) bool

Types

type Map

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

func MapMerge added in v0.3.0

func MapMerge[K MapKey, 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 MapKey, V any](opts ...Option) *Map[K, V]

func (*Map[K, V]) Clear

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

func (*Map[K, V]) Clone

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

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

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

func (*Map[K, V]) Del

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

func (*Map[K, V]) Get

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

func (*Map[K, V]) Iter

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

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

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

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

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

func (*Map[K, V]) Keys

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

func (*Map[K, V]) Len

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

func (*Map[K, V]) MarshalJSON

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

MarshalJSON implements the json.Marshaler interface.

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

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

func (*Map[K, V]) Set

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

func (*Map[K, V]) TryGet

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

func (*Map[K, V]) UnmarshalJSON added in v0.4.0

func (m *Map[K, V]) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

The key order follows the json order.

func (*Map[K, V]) Values

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

type MapKey added in v0.4.0

type MapKey interface {
	~string | ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~float32 | ~float64
}

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]) Equals added in v0.4.0

func (s *Set[T]) Equals(other *Set[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