container

package
v0.0.0-...-fab4c1e Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InsertAll

func InsertAll[K constraints.Ordered, V any](m map[K]V, dict Dictionary[K, V])

InsertAll inserts all map elements in the dictionary.

Types

type Container

type Container[T any] interface {
	// List returns an iterator over all elements.
	List() lang.Iterator[T]
	// IsEmpty returns true if the container is empty.
	IsEmpty() bool
}

Container is an abstract container of elements.

type Dictionary

type Dictionary[K, V any] interface {
	// List returns an iterator over all elements in an implementation-defined order.
	List() lang.Iterator[KV[K, V]]

	// Find returns the value associated with the key, if present.
	Find(k K) (V, bool)
	// Insert sets the value of the key. Returns prior value, if present.
	Insert(k K, v V) (V, bool)
	// Remove removes the key. Returns removed value, if present.
	Remove(k K) (V, bool)
}

Dictionary is an associative mapping, typically implemented as a hashtable or binary search tree.

type KV

type KV[K, V any] struct {
	K K
	V V
}

KV is a key-value pair.

func (KV[K, V]) String

func (kv KV[K, V]) String() string

Directories

Path Synopsis
Package redgreen contains a generic implementation of a red-green binary search tree.
Package redgreen contains a generic implementation of a red-green binary search tree.

Jump to

Keyboard shortcuts

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