storage

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSet16 = fmt.Errorf("%w: set16", Error)

ErrSet16 identifies Set16 related errors.

View Source
var ErrSet8 = fmt.Errorf("%w: set8", Error)

ErrSet8 identifies Set8 related errors.

View Source
var Error = errors.New("storage")

Error identifies general sets package error's.

Functions

This section is empty.

Types

type Collection16

type Collection16 []Table16

Collection16 stores unique ids.Set16 items organized in Table16 storages where each storage keeps sets of same sizes. Each Collection16 item is addressable by unique ids.ID32 which consists of Table16 ID16 item index in collection and ID16 element index in Table16 item.

func (Collection16) Find

func (collection8x8 Collection16) Find(item Set16) (foundIdx ID32, found bool)

Find returns 0-based index of ids.Set16 item in Collection16 array. If no such set found returns -1.

func (Collection16) Get

func (collection8x8 Collection16) Get(itemIdx ID32) (Set16, bool)

Get returns set by index.

func (*Collection16) Index

func (collection8x8 *Collection16) Index(item Set16) (indexedIdx ID32)

Index returns 0-based index of set in Collection8x8 array.

type Collection8x8

type Collection8x8 []Table8

Collection8x8 stores unique ids.Set8 items in Table8 items where each Table8 stores sets of same sizes. Each Collection8x8 item is addressable by unique ID16 which consists of Table8 ID8 item index in collection and ID8 element index in Table8 item.

func (Collection8x8) Find

func (collection8x8 Collection8x8) Find(setItem Set8) (foundIdx ID16, found bool)

Find returns 0-based index of ids.Set8 item in Collection8x8 array. If no such set found returns -1.

func (Collection8x8) Get

func (collection8x8 Collection8x8) Get(itemIdx ID16) (Set8, bool)

Get returns set by index.

func (*Collection8x8) Index

func (collection8x8 *Collection8x8) Index(setItem Set8) (indexedIdx ID16)

Index returns 0-based index of set in Collection8x8 array.

type ID16

type ID16 uint16

ID16 represents uint16 index of elements.

func Combine8

func Combine8(hi ID8, lo ID8) ID16

Combine8 makes an ID16 value putting upper ID8 onto upper bits and lower ID8 onto lower bits.

func (ID16) Lower

func (id16value ID16) Lower() ID8

Lower returns lower ID8 value encapsulated into ID16 value.

func (ID16) Upper

func (id16value ID16) Upper() ID8

Upper returns upper ID8 encapsulated into ID16 value.

type ID32

type ID32 uint32

ID32 represents uint32 index of elements. It wraps built-in uint32 type, providing some utilities methods.

func Combine16

func Combine16(upper ID16, lower ID16) ID32

Combine16 makes an ID32 value putting upper ID16 onto upper bits and lower ID16 onto lower bits.

func (ID32) Lower16

func (id32value ID32) Lower16() ID16

Lower16 returns Lower16 value encapsulated into Id32 value.

func (ID32) Uint32

func (id32value ID32) Uint32() uint32

Uint32 returns uint32 value of ID32 value.

func (ID32) Upper16

func (id32value ID32) Upper16() ID16

Upper16 returns upper ID16 encapsulated into Id32 value.

type ID8

type ID8 uint8

ID8 represents uint8 ID of elements.

func (ID8) Uint8

func (id8 ID8) Uint8() uint8

Uint8 returns uint8 value of ID8. Implements binutils.BinaryUint8.

type Set16

type Set16 []ID16

Set16 stores unique sorted ids.ID16's ids sets. Requires external implementation to provide item -> ids.ID16 and vise-versa transitions.

func (Set16) EqualTo

func (set16 Set16) EqualTo(another Set16) bool

EqualTo compares Set8 with another one. Returns true if both sets are contains the same ID8 elements or false otherwise. Note: both sets should be sorted before compare.

func (Set16) Len

func (set16 Set16) Len() int

Len returns length of Set16. Implements sort.Interface.

func (Set16) Less

func (set16 Set16) Less(i, j int) bool

Less reports whether the element with index i must be placed before the element with index j. Implements sort.Interface.

func (*Set16) ReadFrom

func (set16 *Set16) ReadFrom(r io.Reader) (totalBytesTaken int64, err error)

ReadFrom loads Set16 data from provided io.Reader until all data loaded or any error including EOF. Returns taken bytes count and error if occurs. Implements io.ReaderFrom.

func (Set16) Sort

func (set16 Set16) Sort()

Sort is a convenience method: x.Sort() calls sort.Sort(x). Does inplace sorting of Set8 items.

func (Set16) Swap

func (set16 Set16) Swap(i, j int)

Swap swaps the elements with ids i and j. Implements sort.Interface.

func (Set16) WriteTo

func (set16 Set16) WriteTo(w io.Writer) (n int64, err error)

WriteTo writes Set16 data into supplied io.Writer instance. Returns written bytes count and error if occurs. Implements io.WriterTo.

type Set8

type Set8 []ID8

Set8 stores unique sorted ID8's ids sets. Requires external management to provide item-to-ID8 and vise-versa transitions.

func (Set8) EqualTo

func (set8 Set8) EqualTo(another Set8) bool

EqualTo compares Set8 with another one. Returns true if both sets are contains the same ID8 elements or false otherwise. Note: both sets should be sorted before compare.

func (Set8) Len

func (set8 Set8) Len() int

Len returns length of Set8. Implements sort.Interface.

func (Set8) Less

func (set8 Set8) Less(i, j int) bool

Less reports whether the element with index i must be placed before the element with index j. Implements sort.Interface.

func (*Set8) ReadFrom

func (set8 *Set8) ReadFrom(r io.Reader) (totalBytesTaken int64, err error)

ReadFrom loads Set8 data from provided io.Reader until all data loaded or any error including EOF. Returns taken bytes count and error if occurs. Implements io.ReaderFrom.

func (Set8) Sort

func (set8 Set8) Sort()

Sort is a convenience method: x.Sort() calls sort.Sort(x). Does inplace sorting of Set8 items.

func (Set8) Swap

func (set8 Set8) Swap(i, j int)

Swap swaps the elements with ids i and j. Implements sort.Interface.

func (Set8) WriteTo

func (set8 Set8) WriteTo(w io.Writer) (n int64, err error)

WriteTo writes Set8 data into supplied io.Writer instance. Returns written bytes count and error if occurs. Implements io.WriterTo.

type Table16

type Table16 []Set16

Table16 stores unique ids.Set16 lists having equal length. It Uses its own ID16 index to address target sets.set16 stack in addition to address element in stack. Used in Collection16 to store different sized sets organized into stacks of equal-sized sets.

func (Table16) Find

func (table16 Table16) Find(item Set16) (ID16, bool)

Find returns 0-based index of ids.Set16 in Table16 storage. If no such set found returns -1. It required sets.Set16 argument to be sorted before.

func (Table16) Get

func (table16 Table16) Get(id ID16) (targetSet Set16, found bool)

Get returns ids.Set16 by index if present or found indicator will be false.

func (*Table16) Index

func (table16 *Table16) Index(item Set16) (id ID16)

Index returns 0-based ids.ID16 index of ids.Set16 in Table16 instance. Returns index of existed or appended item. Panics if specified set empty.

type Table8

type Table8 []Set8

Table8 stores upto 256 unique ids.Set8 lists having equal length. Used in Collection8x8 to store different sized sets organized into stacks of equal-sized sets.

func (Table8) Find

func (table8 Table8) Find(item Set8) (ID8, bool)

Find returns 0-based index of ids.Set8 in Table8 storage. If no such set found returns -1. It required argument sets.Set8 to be sorted before.

func (Table8) Get

func (table8 Table8) Get(itemIdx ID8) (targetSet Set8, found bool)

Get returns ids.Set8 by index if present or found indicator will be false.

func (*Table8) Index

func (table8 *Table8) Index(item Set8) (id ID8)

Index returns 0-based ids.ID8 index of ids.Set8 in Table8. Returns index of existed or appended item. Panics if specified set empty.

Jump to

Keyboard shortcuts

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