fastcollection

package
v0.0.0-...-290d292 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FastCollection

type FastCollection[T any] struct {
	UnsafeBackingArray []entry[T]
	// contains filtered or unexported fields
}

FastCollection is an array-backed unordered collection with the goal of having fast insertions, fast deletions and fast iterations (without as much of a spatial locality penalty as iterations over a linked list would incur) FastCollection is not thread safe (analogous to Go's built-in slices and maps) Do not modify UnsafeBackingArray externally (modifying the Content of its entries is safe, modifying anything else is not) The zero value of FastCollection is usable without any special initialization

func (*FastCollection[T]) BackingCap

func (c *FastCollection[T]) BackingCap() int

Cap returns the capacity of the backing structure of the collection

func (*FastCollection[T]) Cap

func (c *FastCollection[T]) Cap() int

Cap returns the capacity of the collection

func (*FastCollection[T]) Delete

func (c *FastCollection[T]) Delete(removeIdx int) T

Delete deletes an item from the collection using the identifier that was returned when it was inserted Each item must be deleted only once Deleting items does not reduce the memory used by this FastCollection, whose capacity can only grow

func (*FastCollection[T]) Entries

func (c *FastCollection[T]) Entries() []T

Entries returns all valid entries as a slice. This is not the most performant way to iterate of the collection

func (*FastCollection[T]) ForEach

func (c *FastCollection[T]) ForEach(do func(*T))

ForEach allows for iterating over all entries without copying

func (*FastCollection[T]) Insert

func (c *FastCollection[T]) Insert(item T) int

Insert inserts the item in the collection and returns an identifier that should be used for its removal

func (*FastCollection[T]) Len

func (c *FastCollection[T]) Len() int

Len returns the count of items in the collection

Jump to

Keyboard shortcuts

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