slices

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fixed

type Fixed[T any] struct {
	// contains filtered or unexported fields
}

Fixed is a slice of constant size, that can be used to store a fixed amount of items

func NewFixed

func NewFixed[T any](amount int) Fixed[T]

Creates a new slice of fixed sized, if its full nothing can be added

func (*Fixed[T]) Cap

func (s *Fixed[T]) Cap() int

Cap returns the capacity of the slice

func (*Fixed[T]) Clear

func (s *Fixed[T]) Clear()

Clear will remove all items from the slice

func (*Fixed[T]) Delete

func (s *Fixed[T]) Delete(index int) bool

Delete will remove the item at the given index, and return if it was successful

func (*Fixed[T]) DeleteFunc

func (s *Fixed[T]) DeleteFunc(predicate func(v T) bool) int

DeleteFunc will remove the all item that matches the predicate, and return the amount of items removed

func (*Fixed[T]) Find

func (s *Fixed[T]) Find(predicate func(v T) bool) (T, bool)

Find will return the first item that matches the predicate, and if it was found

func (*Fixed[T]) FindIndex

func (s *Fixed[T]) FindIndex(predicate func(v T) bool) (int, bool)

FindIndex will return the index of the first item that matches the predicate, and if it was found

func (*Fixed[T]) Get

func (s *Fixed[T]) Get(index int) (T, bool)

Get returns the item at the given index, and if it exists

func (*Fixed[T]) GoString

func (s *Fixed[T]) GoString() string

func (*Fixed[T]) IsFull

func (s *Fixed[T]) IsFull() bool

IsFull returns if the slice is full

func (*Fixed[T]) Len

func (s *Fixed[T]) Len() int

Len returns the amount of items in the slice

func (*Fixed[T]) Read

func (s *Fixed[T]) Read() iter.Seq[T]

Read will return a sequence of the items in the slice

func (*Fixed[T]) Set

func (s *Fixed[T]) Set(index int, value T) bool

Set will set the item at the given index, and return if it was successful

func (*Fixed[T]) SpaceLeft

func (s *Fixed[T]) SpaceLeft() int

SpaceLeft returns the amount of space left in the slice

func (*Fixed[T]) String

func (s *Fixed[T]) String() string

func (*Fixed[T]) TryAppend

func (s *Fixed[T]) TryAppend(items ...T) int

TryAppend will check how much space is left, and attempt to write as much as possible from the given data into its own buffer

If you have 5 items, and there is room for 3, it will return 3, and has added 3 items to its buffer

func (*Fixed[T]) UnsafeCap

func (s *Fixed[T]) UnsafeCap() int

UnsafeCap returns the capacity of the slice without locking

func (*Fixed[T]) UnsafeDelete

func (s *Fixed[T]) UnsafeDelete(index int) bool

UnsafeDelete will remove the item at the given index, and return if it was successful without locking

func (*Fixed[T]) UnsafeGet

func (s *Fixed[T]) UnsafeGet(index int) (T, bool)

UnsafeGet returns the item at the given index, and if it exists without locking

func (*Fixed[T]) UnsafeIsFull

func (s *Fixed[T]) UnsafeIsFull() bool

UnsafeIsFull returns if the slice is full without locking

func (*Fixed[T]) UnsafeLen

func (s *Fixed[T]) UnsafeLen() int

UnsafeLen returns the amount of items in the slice without locking

func (*Fixed[T]) UnsafeSet

func (s *Fixed[T]) UnsafeSet(index int, value T) bool

UnsafeSet will set the item at the given index, and return if it was successful without locking

func (*Fixed[T]) UnsafeSpaceLeft

func (s *Fixed[T]) UnsafeSpaceLeft() int

UnsafeSpaceLeft returns the amount of space left in the slice without locking

type FixedHashed

type FixedHashed[T hash.Hashed] struct {
	// contains filtered or unexported fields
}

FixedHashed is a fixed size slice, that can be used to store a fixed amount of items

func NewFixedHashed

func NewFixedHashed[T hash.Hashed](amount int) FixedHashed[T]

Creates a new slice of fixed sized, if its full nothing can be added

func (*FixedHashed[T]) Cap

func (s *FixedHashed[T]) Cap() int

Cap returns the capacity of the slice

func (*FixedHashed[T]) Clear

func (s *FixedHashed[T]) Clear()

Clear will remove all items from the slice

func (*FixedHashed[T]) Delete

func (s *FixedHashed[T]) Delete(index int) bool

Delete will remove the item at the given index, and return if it was successful

func (*FixedHashed[T]) DeleteFunc

func (s *FixedHashed[T]) DeleteFunc(predicate func(v T) bool) int

DeleteFunc will remove the all item that matches the predicate, and return the amount of items removed

func (*FixedHashed[T]) Find

func (s *FixedHashed[T]) Find(predicate func(v T) bool) (T, bool)

Find will return the first item that matches the predicate, and if it was found

func (*FixedHashed[T]) FindIndex

func (s *FixedHashed[T]) FindIndex(predicate func(v T) bool) (int, bool)

FindIndex will return the index of the first item that matches the predicate, and if it was found

func (*FixedHashed[T]) Get

func (s *FixedHashed[T]) Get(index int) (T, bool)

Get returns the item at the given index, and if it exists

func (*FixedHashed[T]) GoString

func (s *FixedHashed[T]) GoString() string

func (*FixedHashed[T]) HasHash

func (s *FixedHashed[T]) HasHash(v uint64) bool

func (*FixedHashed[T]) IsFull

func (s *FixedHashed[T]) IsFull() bool

IsFull returns if the slice is full

func (*FixedHashed[T]) Len

func (s *FixedHashed[T]) Len() int

Len returns the amount of items in the slice

func (*FixedHashed[T]) Read

func (s *FixedHashed[T]) Read() iter.Seq[T]

Read will return a sequence of the items in the slice

func (*FixedHashed[T]) Rehash

func (s *FixedHashed[T]) Rehash()

func (*FixedHashed[T]) Set

func (s *FixedHashed[T]) Set(index int, value T) bool

Set will set the item at the given index, and return if it was successful

func (*FixedHashed[T]) SpaceLeft

func (s *FixedHashed[T]) SpaceLeft() int

SpaceLeft returns the amount of space left in the slice

func (*FixedHashed[T]) String

func (s *FixedHashed[T]) String() string

func (*FixedHashed[T]) TryAppend

func (s *FixedHashed[T]) TryAppend(items ...T) int

TryAppend will check how much space is left, and attempt to write as much as possible from the given data into its own buffer

If you have 5 items, and there is room for 3, it will return 3, and has added 3 items to its buffer

func (*FixedHashed[T]) UnsafeCap

func (s *FixedHashed[T]) UnsafeCap() int

UnsafeCap returns the capacity of the slice without locking

func (*FixedHashed[T]) UnsafeDelete

func (s *FixedHashed[T]) UnsafeDelete(index int) bool

UnsafeDelete will remove the item at the given index, and return if it was successful without locking

func (*FixedHashed[T]) UnsafeGet

func (s *FixedHashed[T]) UnsafeGet(index int) (T, bool)

UnsafeGet returns the item at the given index, and if it exists without locking

func (*FixedHashed[T]) UnsafeIsFull

func (s *FixedHashed[T]) UnsafeIsFull() bool

UnsafeIsFull returns if the slice is full without locking

func (*FixedHashed[T]) UnsafeLen

func (s *FixedHashed[T]) UnsafeLen() int

UnsafeLen returns the amount of items in the slice without locking

func (*FixedHashed[T]) UnsafeSet

func (s *FixedHashed[T]) UnsafeSet(index int, value T) bool

UnsafeSet will set the item at the given index, and return if it was successful without locking

func (*FixedHashed[T]) UnsafeSpaceLeft

func (s *FixedHashed[T]) UnsafeSpaceLeft() int

UnsafeSpaceLeft returns the amount of space left in the slice without locking

Jump to

Keyboard shortcuts

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