Documentation
¶
Index ¶
- Constants
- func Accumulate[T any, U constraints.Ordered](input []T, value func(T) U) U
- func AllOnes[T constraints.Unsigned](bits int) T
- func AsciiFrame(fields []AsciiFrameField, frameWidth int, unit string, ...) string
- func BitCast[To constraints.Integer, From constraints.Integer](from From) To
- func Bits(bytes int) int
- func ConcatMap[T any, U any](input []T, mapFunction func(T) []U) []U
- func ConditionallyReversedRefs[T any](input []T, reversed bool) []*T
- func Filter[T any](input []T, cond func(T) bool) []T
- func FormatSlice[T any](input []T, separator string) string
- func FormatUintBinary(value uint64, bits int) string
- func FormatUintHex(value uint64, bits int) string
- func GenMap[T any, Key comparable](input []T, keyFunc func(T) Key) map[Key]T
- func GenMapFromKeys[T any, Key comparable](keys []Key, itemFunc func(Key) T) map[Key]T
- func Indices(n int) []int
- func InvertedMap[Key comparable, Value comparable](input map[Key]Value) map[Value]Key
- func Iota[T any](n int, gen func(int) T) []T
- func Keys[Key comparable, Value comparable](input map[Key]Value) []Key
- func MakeError(err error, detailsBody string, args ...any) error
- func Map[T any, U any](input []T, mapFunction func(T) U) []U
- func MapMap[Key comparable, Value comparable, NewKey comparable, NewValue comparable](input map[Key]Value, mapFunction func(Key, Value) (NewKey, NewValue)) map[NewKey]NewValue
- func MapMember(name string, items []any) ([]any, error)
- func Max[T constraints.Ordered](input []T) T
- func Member(name string, object any) (any, error)
- func Min[T constraints.Ordered](input []T) T
- func Reduce[T any, U any](input []T, foldFunc func(T, U) U) U
- func Refs[T any](input []T) []*T
- func ReversedRefs[T any](input []T) []*T
- func Sizeof[T any]() int
- func SizeofBits[T any]() int
- func Values[Key comparable, Value comparable](input map[Key]Value) []Value
- type AsciiFrameField
- type AsciiFrameUnitLayout
- type BitView
- func (v BitView[T]) ClearBit(bit int)
- func (v BitView[T]) ClearBits(bit int, width int)
- func (v BitView[T]) Read(bit int, width int) T
- func (v BitView[T]) SetBit(bit int)
- func (v BitView[T]) SetBits(bit int, width int)
- func (v BitView[T]) SizeofBits() int
- func (v BitView[T]) Value() T
- func (v BitView[T]) Write(value T, bit int, width int)
- type Pair
Constants ¶
const BitsPerByte = 8
Variables ¶
This section is empty.
Functions ¶
func Accumulate ¶
func Accumulate[T any, U constraints.Ordered](input []T, value func(T) U) U
Reduces a sequence by adding up the value returned by a function applied to each item
func AllOnes ¶
func AllOnes[T constraints.Unsigned](bits int) T
Returns an all ones bitmask of n bits of the given unsigned integer type
func AsciiFrame ¶
func AsciiFrame(fields []AsciiFrameField, frameWidth int, unit string, layout AsciiFrameUnitLayout, leftpad int) string
Prints an ascii diagram of a binary frame composed of contiguous fields of different unit lenghts
func BitCast ¶
func BitCast[To constraints.Integer, From constraints.Integer](from From) To
func ConcatMap ¶
Generates a sequence composed by the concatenation of all the secuences generated by applying a map function to each element of the input sequence
func ConditionallyReversedRefs ¶
Returns a sequence of references to the items on an slice, reversed or not based on a condition
func Filter ¶
Returns the subset sequence of all items of a sequence passing a given boolean condition
func FormatSlice ¶
Returns an string containing all formatted sequence items separated by a given separator
func FormatUintBinary ¶
Formats an uint value into a fixed width binary string of n bits
func FormatUintHex ¶
Formats an uint value into an fixed width hex string of n characters
func GenMap ¶
func GenMap[T any, Key comparable](input []T, keyFunc func(T) Key) map[Key]T
Generates a map from a sequence of items and a function that generates a key from an item
func GenMapFromKeys ¶
func GenMapFromKeys[T any, Key comparable](keys []Key, itemFunc func(Key) T) map[Key]T
Generates a map from a sequence of keys and a function that generates an item from a key
func InvertedMap ¶
func InvertedMap[Key comparable, Value comparable](input map[Key]Value) map[Value]Key
Converts a Key -> Value map into a Value -> Key map
func Keys ¶
func Keys[Key comparable, Value comparable](input map[Key]Value) []Key
Returns an array with all the keys of a map
func Map ¶
Generates a sequence constructed by applying a function to all elements of a given input sequence
func MapMap ¶
func MapMap[Key comparable, Value comparable, NewKey comparable, NewValue comparable](input map[Key]Value, mapFunction func(Key, Value) (NewKey, NewValue)) map[NewKey]NewValue
Generates a new Map NewKey -> NewValue from a given map Key -> Value and a transformation function (Key, Value) -> (NewKey, NewValue)
func MapMember ¶
Maps a sequence of objects into a sequence of values of a given member of each item of the input sequence
func Member ¶
Returns the value of an object member by name. If the member is a method it is assumed that it has no paramters and gets called to return the value.
func Refs ¶
func Refs[T any](input []T) []*T
Returns a sequence of references to the items of an slice
func ReversedRefs ¶
func ReversedRefs[T any](input []T) []*T
Returns a sequence of references to the items of an slice in reverse order
func Values ¶
func Values[Key comparable, Value comparable](input map[Key]Value) []Value
Returns an array with all the values of a map
Types ¶
type AsciiFrameField ¶
type AsciiFrameField struct { // Name of the field Name string // Units within the frame the field begins from Begin int // Field width Width int }
func (*AsciiFrameField) PastTopUnit ¶
func (f *AsciiFrameField) PastTopUnit() int
The first unit within the frame used by the next field
func (*AsciiFrameField) TopUnit ¶
func (f *AsciiFrameField) TopUnit() int
The last unit within the frame used by this field
type AsciiFrameUnitLayout ¶
type AsciiFrameUnitLayout uint
const ( // Units increase left to right AsciiFrameUnitLayout_LeftToRight AsciiFrameUnitLayout = iota // Units increase right to left AsciiFrameUnitLayout_RightToLeft )
type BitView ¶
type BitView[T constraints.Unsigned] struct { Bits *T }
Implements a read/write view over an unsigned interger, allowing manipullating individual bits easily
func CreateBitView ¶
func CreateBitView[T constraints.Unsigned](value *T) BitView[T]
Creates a bit view out of an unsigned int
func (BitView[T]) SizeofBits ¶
Returns the size in bits of the viewed value
type Pair ¶
func ZipMap ¶
func ZipMap[Key comparable, Value comparable](input map[Key]Value) []Pair[Key, Value]
Returns an array of pairs (Key, Value) from a given map Key -> Value