contracts

package
v0.0.0-...-9de6be3 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comparator

type Comparator[T comparable] func(a, b T) int

Comparator will make type assertion (see IntComparator for example), which will panic if a or b are not of the asserted type.

Should return a number:

negative , if a < b
zero     , if a == b
positive , if a > b

type Container

type Container[T comparable] interface {
	Empty() bool
	Size() int
	Clear()
	Values() []T
	String() string
}

Container is base interface that all data structures implement.

type List

type List[T comparable] interface {
	Get(index int) (T, bool)
	Remove(index int)
	Add(values ...T)
	Contains(values ...T) bool
	Sort(comparator Comparator[T])
	Swap(index1, index2 int)
	Insert(index int, values ...T)
	Set(index int, value T)

	Container[T]
}

List interface that all lists implement

type Map

type Map[K constraints.Ordered, V comparable] interface {
	Len() int
	Keys() []K
	Values() []V
	Range(func(K, V) bool)
	Get(K) V
	GetExist(K) (V, bool)
	Set(K, V)
	Del(K)
}

Jump to

Keyboard shortcuts

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