dict

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package dict provides a data structure that wraps a map and allows repeatable traversals. The ordering is based on the order which the key / value pairs is set.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dict

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

Dict wraps a map and allows for repeatable traversals, via the Keys method.

func New

func New[K comparable, V any]() *Dict[K, V]

New creates a new dict.

func (*Dict[K, V]) Key

func (d *Dict[K, V]) Key(i int) K

Key returns the key at index i.

func (Dict[K, V]) Keys

func (d Dict[K, V]) Keys() []K

Keys returns the keys of the Dict. The order of the slice is the order in which the values were set.

func (*Dict[K, V]) Len

func (d *Dict[K, V]) Len() int

Len returns the length of the Dict.

func (*Dict[K, V]) Set

func (d *Dict[K, V]) Set(k K, v V)

Set creates a new entry in the Dict for the key k, and the value v. The ordering of the Dict is based on the order in which the key / value is Set. If the key / value pair already exists, it will be replaced and the original ordering is preserved.

func (*Dict[K, V]) Val

func (d *Dict[K, V]) Val(k K) V

Val returns the value for key k.

Jump to

Keyboard shortcuts

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