types

package
v0.0.0-...-7ffa7f6 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Copyright (c) 2024 Thomas Mikalsen. Subject to the MIT License

Copyright (c) 2024 Thomas Mikalsen. Subject to the MIT License

Copyright (c) 2024 Thomas Mikalsen. Subject to the MIT License

Copyright (c) 2024 Thomas Mikalsen. Subject to the MIT License

Copyright (c) 2024 Thomas Mikalsen. Subject to the MIT License

Index

Constants

This section is empty.

Variables

View Source
var Nothing = struct{}{}

Nothing is the zero value of the Unit type

Functions

This section is empty.

Types

type Compare

type Compare[T any] func(a, b T) int

Compare is a function used to compare items during a search

-1 if a is less than b,
 0 if a equals b,
+1 if a is greater than b.

type Map

type Map[K cmp.Ordered, V any] interface {
	Size() (size int)
	Get(key K) (val V, found bool)
	MustGet(key K) (val V)
	Put(key K, val V)
	Delete(key K) (deleted bool)
}

Map is the interface to an associative container of key-value pairs with unique keys.

type Ordered

type Ordered[K cmp.Ordered, V any] interface {
	Size() (size int)
	// Min returns the smallest key in the container, or false if the container is empty
	Min() (minKey K, ok bool)
	// Max returns the largest key in the container, or false if the container is empty
	Max() (maxKey K, ok bool)
	// VisitInOrder visits all key,value pairs in order
	VisitInOrder(v Visitor[K, V])
}

Ordered is the interface to a container of key-value pairs sorted by key

type Queue

type Queue[T any] interface {
	Size() (len int)
	Enqueue(val T)
	Head() (head T, ok bool)
	MustHead() (head T)
	Dequeue() (head T, ok bool)
	MustDequeue() (head T)
}

Queue is the interface to a first-in/first-out container of items.

type Unit

type Unit = struct{}

Unit is a type that literally means nothing. It's the Seinfeld of data types ... the type about nothing.

type Visitor

type Visitor[K cmp.Ordered, V any] func(key K, val V)

Visitor defines a function to be applied when visiting the key-value pairs of a container.

Jump to

Keyboard shortcuts

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