Documentation ¶
Overview ¶
Set ¶
A simple type that allows bitset-like functionality.
Static Array ¶
A simple fixed-size array. Not super useful yet.
Index ¶
- type Set
- type StaticArray
- func (a *StaticArray[T]) Append(v T) *T
- func (a *StaticArray[T]) Cap() int
- func (a *StaticArray[T]) Items() []T
- func (a *StaticArray[T]) Len() int
- func (a *StaticArray[T]) Pop() T
- func (a *StaticArray[T]) Remove(idx int)
- func (a *StaticArray[T]) Reset()
- func (a *StaticArray[T]) UnorderedRemove(idx int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Set ¶
type Set[T anyInt] struct {
Value T
}
T must be a signed or unsigned integer of any size.
The intended use is for flags:
type Flag uint const ( FlagNone Flag = 1 << iota FlagA FlagB FlagC FlagFoo = FlagA | FlagC ) flags := NewSet[Flag]() flags.Set(FlagA) // FlagA is set flags.Set(FlagB) // FlagA + FlagB is set flags.Set(FlagFoo) // FlagA + FlagB + FlagC is set
func (*Set[T]) TotalUnset ¶
Returns the number of unset bits within a Set.
type StaticArray ¶
type StaticArray[T any] struct { // contains filtered or unexported fields }
func NewStaticArray ¶
func NewStaticArray[T any](cap uint) StaticArray[T]
func (*StaticArray[T]) Append ¶
func (a *StaticArray[T]) Append(v T) *T
Appends 'v' to the end of the array. Returns a pointer to the stored value.
func (*StaticArray[T]) Items ¶
func (a *StaticArray[T]) Items() []T
Slice of currently occupied items.
Allows for easier iteration:
arr := NewStaticArray[int](10) // ... for i, v := range arr.Items() { // ... }
func (*StaticArray[T]) Len ¶
func (a *StaticArray[T]) Len() int
Number of occupied items within the array.
func (*StaticArray[T]) Pop ¶
func (a *StaticArray[T]) Pop() T
Removes and returns the last element of the array.
func (*StaticArray[T]) Remove ¶
func (a *StaticArray[T]) Remove(idx int)
Ordered removal of the value at index 'idx'.
func (*StaticArray[T]) Reset ¶
func (a *StaticArray[T]) Reset()
Sets all values within the array to their zero value and resets the count.
func (*StaticArray[T]) UnorderedRemove ¶
func (a *StaticArray[T]) UnorderedRemove(idx int)
Unordered removal of the value at index 'idx'.