embedded

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2022 License: MIT Imports: 5 Imported by: 0

README

go-embedded-container

Go

Embedded Containers for Go

What are they?

Various containers supporting Go Generics that don't own their entities. Instead, they facilitate container operations on values that might be owned by something else.

What containers are available?

Name Description
embedded.Hash A map-style container with hashed value (of int type) lookup
embedded.HashList A container combining the mechanisms of embedded.Hash and embedded.List
embedded.HashListMap A container with a map combined with a doubly-linked list interface. Internally, item keys are hashed (using FNV 64-bit hashing) so the embedded.HashList mechanisms can be reused
embedded.HashMap A container combining the mechanisms of embedded.Hash and embedded.Map without incurring the performance concerns of embedded.Map
embedded.List A list-style container with a doubly-linked interface
embedded.Map A map-style container with red-black tree internally
embedded.PriorityQueue A priority queue-style container with heap sorting internally

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hash

type Hash[T any] interface {
	TableInterface

	Remove(obj *T) *T

	Insert(hashValue HashedKeyValue, obj *T) *T

	Move(obj *T, newHashValue HashedKeyValue)

	FindFirst(hashValue HashedKeyValue) *T
	FindNext(prevResult *T) *T
	GetKey(obj *T) HashedKeyValue

	IsContained(obj *T) bool

	WalkFirst() *T
	WalkNext(prevResult *T) *T
}

func NewHashDynamic

func NewHashDynamic[T any](linkField uintptr) Hash[T]

func NewHashStatic

func NewHashStatic[T any](linkField uintptr, tableSize int) Hash[T]
type HashLink[M any] struct {
	// contains filtered or unexported fields
}

HashLink is a link to the map container

type HashList

type HashList[T any] interface {
	TableInterface
	ListInterface[HashedKeyValue, T]
}

func NewHashListDynamic

func NewHashListDynamic[T any](linkField uintptr) HashList[T]

func NewHashListStatic

func NewHashListStatic[T any](linkField uintptr, tableSize int) HashList[T]
type HashListLink[M any] struct {
	// contains filtered or unexported fields
}

HashListLink is a link to the map container

type HashListMap

type HashListMap[TKey HashMapKeyType, T any] interface {
	TableInterface
	ListInterface[TKey, T]

	RemoveAllByKey(key TKey)
	RemoveAllByUniqueKey(key TKey)
}

func NewHashListMapDynamic

func NewHashListMapDynamic[TKey HashMapKeyType, T any](linkField uintptr) HashListMap[TKey, T]

func NewHashListMapStatic

func NewHashListMapStatic[TKey HashMapKeyType, T any](linkField uintptr, tableSize int) HashListMap[TKey, T]
type HashListMapLink[TKey HashMapKeyType, T any] struct {
	// contains filtered or unexported fields
}

HashListMapLink is a link to the map container

type HashMap

type HashMap[TKey HashMapKeyType, T any] interface {
	TableInterface

	Remove(obj *T) *T

	Insert(key TKey, obj *T) *T

	Move(obj *T, newKey TKey)

	FindFirst(key TKey) *T
	FindNext(prevResult *T) *T
	GetKey(obj *T) TKey

	IsContained(obj *T) bool

	RemoveAllByKey(key TKey)
	RemoveAllByUniqueKey(key TKey)

	WalkFirst() *T
	WalkNext(prevResult *T) *T
}

func NewHashMapDynamic

func NewHashMapDynamic[TKey HashMapKeyType, T any](linkField uintptr) HashMap[TKey, T]

func NewHashMapStatic

func NewHashMapStatic[TKey HashMapKeyType, T any](linkField uintptr, tableSize int) HashMap[TKey, T]

type HashMapKeyType

type HashMapKeyType interface {
	constraints.Ordered
}
type HashMapLink[TKey HashMapKeyType, M any] struct {
	// contains filtered or unexported fields
}

HashMapLink is a link to the list container

type HashedKeyValue

type HashedKeyValue uint64

func HashKey

func HashKey[TKey HashMapKeyType](key TKey) HashedKeyValue

type List

type List[T any] interface {
	First() *T
	Last() *T
	Next(cur *T) *T
	Prev(cur *T) *T
	Position(index int) *T

	Remove(obj *T) *T
	RemoveFirst() *T
	RemoveLast() *T
	RemoveAll()

	InsertFirst(cur *T) *T
	InsertLast(cur *T) *T
	InsertAfter(prev, cur *T) *T
	InsertBefore(after, cur *T) *T

	MoveFirst(cur *T)
	MoveLast(cur *T)
	MoveAfter(dest, cur *T)
	MoveBefore(dest, cur *T)

	Count() int
	IsEmpty() bool
	IsContained(cur *T) bool
}

func NewList

func NewList[T any](linkField uintptr) List[T]

type ListInterface

type ListInterface[TKey any, T any] interface {
	First() *T
	Last() *T
	Next(cur *T) *T
	Prev(cur *T) *T
	Position(index int) *T

	Remove(obj *T) *T
	RemoveFirst() *T
	RemoveLast() *T
	RemoveAll()

	InsertFirst(key TKey, obj *T) *T
	InsertLast(key TKey, obj *T) *T
	InsertAfter(key TKey, prev, obj *T) *T
	InsertBefore(key TKey, after, obj *T) *T

	Move(obj *T, newKey TKey)
	MoveFirst(obj *T)
	MoveLast(obj *T)
	MoveAfter(dest, obj *T)
	MoveBefore(dest, obj *T)

	FindFirst(key TKey) *T
	FindNext(prevResult *T) *T
	GetKey(obj *T) TKey

	IsContained(obj *T) bool
}
type ListLink[M any] struct {
	// contains filtered or unexported fields
}

ListLink is a link to the list container

type Map

type Map[TKey MapKeyType, T any] interface {
	First() *T
	Last() *T
	Next(cur *T) *T
	Prev(cur *T) *T
	Position(index int) *T
	Count() int

	Remove(obj *T) *T
	RemoveFirst() *T
	RemoveLast() *T
	RemoveAll()

	Insert(key TKey, obj *T) *T

	Move(obj *T, newKey TKey)

	GetKey(obj *T) TKey
	IsEmpty() bool

	IsContained(obj *T) bool

	GetPosition(obj *T) int

	Find(key TKey) *T
	FindFirst(key TKey) *T
	FindNext(cur *T) *T
	FindLowerInclusive(key TKey) *T
	FindUpperInclusive(key TKey) *T
	FindLowerExclusive(key TKey) *T
	FindUpperExclusive(key TKey) *T
}

func NewMap

func NewMap[TKey MapKeyType, T any](linkField uintptr) Map[TKey, T]

type MapKeyType

type MapKeyType interface {
	constraints.Ordered
}
type MapLink[TKey, T any] struct {
	// contains filtered or unexported fields
}

MapLink is a link to the map container

type PriorityQueue

type PriorityQueue[P PriorityType, T any] interface {
	Top() *T
	TopWithPriority(priority P) *T
	Insert(priority P, entry *T) *T
	Remove(entry *T) *T
	RemoveTop() *T
	RemoveTopWithPriority(priority P) *T
	RemoveAll()
	Count() int
	IsEmpty() bool

	GetPriority(entry *T) *P
	IsContained(entry *T) bool
}

func NewPriorityQueue

func NewPriorityQueue[P PriorityType, T any](linkField uintptr) PriorityQueue[P, T]
type PriorityQueueLink[P PriorityType] struct {
	// contains filtered or unexported fields
}

PriorityQueueLink is a link to the priority queue container

type PriorityType

type PriorityType interface {
	constraints.Ordered
}

type TableInterface

type TableInterface interface {
	Count() int

	RemoveAll()

	GetTableSize() int
	GetTableUsed() int
	Reserve(count int)
	IsEmpty() bool
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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