orderedmap

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT, MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByPair

type ByPair struct {
	Pairs    []*Pair
	LessFunc func(a *Pair, j *Pair) bool
}

func (ByPair) Len

func (a ByPair) Len() int

func (ByPair) Less

func (a ByPair) Less(i, j int) bool

func (ByPair) Swap

func (a ByPair) Swap(i, j int)

type ByPairOf

type ByPairOf[K comparable, V any] struct {
	Pairs    []*PairOf[K, V]
	LessFunc func(a *PairOf[K, V], j *PairOf[K, V]) bool
}

func (ByPairOf[K, V]) Len

func (a ByPairOf[K, V]) Len() int

func (ByPairOf[K, V]) Less

func (a ByPairOf[K, V]) Less(i, j int) bool

func (ByPairOf[K, V]) Swap

func (a ByPairOf[K, V]) Swap(i, j int)

type OrderedMap

type OrderedMap struct {
	// contains filtered or unexported fields
}

func New

func New() *OrderedMap

func (*OrderedMap) Delete

func (o *OrderedMap) Delete(key string)

func (*OrderedMap) Get

func (o *OrderedMap) Get(key string) (any, bool)

func (*OrderedMap) Keys

func (o *OrderedMap) Keys() []string

func (OrderedMap) MarshalJSON

func (o OrderedMap) MarshalJSON() ([]byte, error)

func (*OrderedMap) Set

func (o *OrderedMap) Set(key string, value any)

func (*OrderedMap) SetEscapeHTML

func (o *OrderedMap) SetEscapeHTML(on bool)

func (*OrderedMap) Size

func (o *OrderedMap) Size() int

func (*OrderedMap) Sort

func (o *OrderedMap) Sort(lessFunc func(a *Pair, b *Pair) bool)

Sort the map using your sort func

func (*OrderedMap) SortKeys

func (o *OrderedMap) SortKeys(sortFunc ...func(keys []string))

SortKeys Sort the map keys using your sort func

func (*OrderedMap) UnmarshalJSON

func (o *OrderedMap) UnmarshalJSON(b []byte) error

func (*OrderedMap) Values

func (o *OrderedMap) Values() map[string]any

type OrderedMapOf

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

func NewOf

func NewOf[K comparable, V any]() *OrderedMapOf[K, V]

func (*OrderedMapOf[K, V]) Clone

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

func (*OrderedMapOf[K, V]) Delete

func (o *OrderedMapOf[K, V]) Delete(key K)

func (*OrderedMapOf[K, V]) Get

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

func (*OrderedMapOf[K, V]) Keys

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

func (*OrderedMapOf[K, V]) MarshalJSON

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

MarshalJSON 按插入 (或排序后) 的键顺序输出 JSON 对象, 键按 encoding/json 的 map 键规则转为字符串 (见 writeKeyOf). 键类型无法表示为 JSON 字符串时返回错误, 不输出非法对象.

func (*OrderedMapOf[K, V]) MustGet

func (o *OrderedMapOf[K, V]) MustGet(key K) V

func (*OrderedMapOf[K, V]) Set

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

func (*OrderedMapOf[K, V]) SetEscapeHTML

func (o *OrderedMapOf[K, V]) SetEscapeHTML(on bool)

func (*OrderedMapOf[K, V]) Size

func (o *OrderedMapOf[K, V]) Size() int

func (*OrderedMapOf[K, V]) Sort

func (o *OrderedMapOf[K, V]) Sort(lessFunc func(a *PairOf[K, V], b *PairOf[K, V]) bool)

Sort the map using your sort func

func (*OrderedMapOf[K, V]) SortKeys

func (o *OrderedMapOf[K, V]) SortKeys(sortFunc func(keys []K))

SortKeys Sort the map keys using your sort func

func (*OrderedMapOf[K, V]) ToMap

func (o *OrderedMapOf[K, V]) ToMap() map[K]V

func (*OrderedMapOf[K, V]) Values

func (o *OrderedMapOf[K, V]) Values() map[K]V

type Pair

type Pair struct {
	// contains filtered or unexported fields
}

func (*Pair) Key

func (kv *Pair) Key() string

func (*Pair) Value

func (kv *Pair) Value() any

type PairOf

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

func (*PairOf[K, V]) Key

func (kv *PairOf[K, V]) Key() K

func (*PairOf[K, V]) Value

func (kv *PairOf[K, V]) Value() V

Jump to

Keyboard shortcuts

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