Documentation ¶
Overview ¶
Package memory contains structs for genny to generate templates of your need
Index ¶
- func Float32BiComp(a, b float32) uint8
- func Float64BiComp(a, b float64) uint8
- func Int16BiComp(a, b int16) uint8
- func Int32BiComp(a, b int32) uint8
- func Int64BiComp(a, b int64) uint8
- func Int8BiComp(a, b int8) uint8
- func IntBiComp(a, b int) uint8
- func NumberBiComp(a, b Number) uint8
- func Uint16BiComp(a, b uint16) uint8
- func Uint32BiComp(a, b uint32) uint8
- func Uint64BiComp(a, b uint64) uint8
- func Uint8BiComp(a, b uint8) uint8
- func UintBiComp(a, b uint) uint8
- type Element
- type ElementCapsule
- type ElementStorage
- func (s *ElementStorage) Allocate() (*Element, int32)
- func (s *ElementStorage) AllocateID(id int32) *Element
- func (s *ElementStorage) Blanc()
- func (s *ElementStorage) Clear()
- func (s *ElementStorage) Count() int
- func (s *ElementStorage) Item(id int32) *Element
- func (s *ElementStorage) Len() int
- func (s *ElementStorage) Occupied() []int32
- func (s *ElementStorage) Remove(id int32)
- func (s *ElementStorage) SlowClear()
- func (s *ElementStorage) Used(id int32) bool
- type Int32Vec
- func (v *Int32Vec) BiInsert(value int32, cmp func(a, b int32) uint8)
- func (v Int32Vec) BiSearch(value int32, cmp func(a, b int32) uint8) (int, bool)
- func (v *Int32Vec) Clear()
- func (v Int32Vec) Clone() Int32Vec
- func (v *Int32Vec) Extend(amount int)
- func (v *Int32Vec) Filter(filter func(e int32) bool)
- func (v Int32Vec) Find(find func(e int32) bool) (idx int, res int32)
- func (v Int32Vec) ForEach(con func(i int, e int32) int32)
- func (v *Int32Vec) Insert(idx int, val int32)
- func (v *Int32Vec) InsertSlice(idx int, val []int32)
- func (v Int32Vec) Last() int32
- func (v Int32Vec) Len() int
- func (v Int32Vec) Move(old, new int)
- func (v *Int32Vec) Pop() int32
- func (v *Int32Vec) PopFront() int32
- func (v *Int32Vec) Remove(idx int) (val int32)
- func (v *Int32Vec) RemoveSlice(start, end int)
- func (v *Int32Vec) Resize(size int)
- func (v Int32Vec) Reverse()
- func (v Int32Vec) Rewrite(o Int32Vec, idx int)
- func (v Int32Vec) Sort(comp func(a, b int32) bool)
- func (v Int32Vec) Swap(a, b int)
- func (v *Int32Vec) Truncate(l int)
- type IntVec
- func (v *IntVec) BiInsert(value int, cmp func(a, b int) uint8)
- func (v IntVec) BiSearch(value int, cmp func(a, b int) uint8) (int, bool)
- func (v *IntVec) Clear()
- func (v IntVec) Clone() IntVec
- func (v *IntVec) Extend(amount int)
- func (v *IntVec) Filter(filter func(e int) bool)
- func (v IntVec) Find(find func(e int) bool) (idx int, res int)
- func (v IntVec) ForEach(con func(i int, e int) int)
- func (v *IntVec) Insert(idx int, val int)
- func (v *IntVec) InsertSlice(idx int, val []int)
- func (v IntVec) Last() int
- func (v IntVec) Len() int
- func (v IntVec) Move(old, new int)
- func (v *IntVec) Pop() int
- func (v *IntVec) PopFront() int
- func (v *IntVec) Remove(idx int) (val int)
- func (v *IntVec) RemoveSlice(start, end int)
- func (v *IntVec) Resize(size int)
- func (v IntVec) Reverse()
- func (v IntVec) Rewrite(o IntVec, idx int)
- func (v IntVec) Sort(comp func(a, b int) bool)
- func (v IntVec) Swap(a, b int)
- func (v *IntVec) Truncate(l int)
- type Item
- type ItemVec
- func (v *ItemVec) BiInsert(value Item, cmp func(a, b Item) uint8)
- func (v ItemVec) BiSearch(value Item, cmp func(a, b Item) uint8) (int, bool)
- func (v *ItemVec) Clear()
- func (v ItemVec) Clone() ItemVec
- func (v *ItemVec) Extend(amount int)
- func (v *ItemVec) Filter(filter func(e Item) bool)
- func (v ItemVec) Find(find func(e Item) bool) (idx int, res Item)
- func (v ItemVec) ForEach(con func(i int, e Item) Item)
- func (v *ItemVec) Insert(idx int, val Item)
- func (v *ItemVec) InsertSlice(idx int, val []Item)
- func (v ItemVec) Last() Item
- func (v ItemVec) Len() int
- func (v ItemVec) Move(old, new int)
- func (v *ItemVec) Pop() Item
- func (v *ItemVec) PopFront() Item
- func (v *ItemVec) Remove(idx int) (val Item)
- func (v *ItemVec) RemoveSlice(start, end int)
- func (v *ItemVec) Resize(size int)
- func (v ItemVec) Reverse()
- func (v ItemVec) Rewrite(o ItemVec, idx int)
- func (v ItemVec) Sort(comp func(a, b Item) bool)
- func (v ItemVec) Swap(a, b int)
- func (v *ItemVec) Truncate(l int)
- type Key
- type KeyValueCapsule
- type KeyValueOrdered
- func (o *KeyValueOrdered) Clear()
- func (o *KeyValueOrdered) Index(name Key) (int, bool)
- func (o *KeyValueOrdered) Insert(key Key, idx int, value Value)
- func (o *KeyValueOrdered) IsNil() bool
- func (o *KeyValueOrdered) Put(key Key, value Value)
- func (o *KeyValueOrdered) ReIndex(old, new int)
- func (o *KeyValueOrdered) Remove(key Key) (val Value, idx int, ok bool)
- func (o *KeyValueOrdered) RemoveIndex(idx int) (cell KeyValueCapsule)
- func (o *KeyValueOrdered) Rename(old, new Key) bool
- func (o *KeyValueOrdered) Slice() []KeyValueCapsule
- func (o *KeyValueOrdered) Value(key Key) (val Value, idx int, ok bool)
- type Number
- type Quick
- type QuickPool
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Float32BiComp ¶ added in v0.2.12
func Float64BiComp ¶ added in v0.2.12
func Int16BiComp ¶ added in v0.2.12
func Int32BiComp ¶ added in v0.2.12
func Int64BiComp ¶ added in v0.2.12
func Int8BiComp ¶ added in v0.2.12
func NumberBiComp ¶ added in v0.2.12
func Uint16BiComp ¶ added in v0.2.12
func Uint32BiComp ¶ added in v0.2.12
func Uint64BiComp ¶ added in v0.2.12
func Uint8BiComp ¶ added in v0.2.12
func UintBiComp ¶ added in v0.2.12
Types ¶
type ElementCapsule ¶ added in v0.2.12
type ElementCapsule struct {
// contains filtered or unexported fields
}
ElementCapsule is something like an optional type, it holds boolean about whether it contains value though it does not hold pointer
type ElementStorage ¶ added in v0.2.12
type ElementStorage struct {
// contains filtered or unexported fields
}
ElementStorage generates IDs witch makes no need to use hashing, only drawback is that you cannot choose the id, it will be assigned like a pointer, but without putting presure no gc, brilliant ElementStorage for components. Its highly unlikely you will run out of ids as they are reused
func (*ElementStorage) Allocate ¶ added in v0.2.12
func (s *ElementStorage) Allocate() (*Element, int32)
Allocate allocates an value and returns id and pointer to it. Note that allocate does not always allocate at all and just reuses freed space, returned pointer also does not point to zero value and you have to overwrite all properties to get expected behavior
func (*ElementStorage) AllocateID ¶ added in v0.2.12
func (s *ElementStorage) AllocateID(id int32) *Element
Allocate id allocates if it is free, else it returns nil
func (*ElementStorage) Blanc ¶ added in v0.2.12
func (s *ElementStorage) Blanc()
Blanc allocates blanc space adds
func (*ElementStorage) Clear ¶ added in v0.2.12
func (s *ElementStorage) Clear()
Clear clears ElementStorage, but keeps allocated space
func (*ElementStorage) Count ¶ added in v0.2.12
func (s *ElementStorage) Count() int
Count returns amount of values stored
func (*ElementStorage) Item ¶ added in v0.2.12
func (s *ElementStorage) Item(id int32) *Element
Item returns pointer to value under the "id", accessing random id can result in random value that can be considered unoccupied
method panics if id is not occupied
func (*ElementStorage) Len ¶ added in v0.2.12
func (s *ElementStorage) Len() int
Len returns size of ElementStorage
func (*ElementStorage) Occupied ¶ added in v0.2.12
func (s *ElementStorage) Occupied() []int32
Occupied return all occupied ids in ElementStorage, this method panics if ElementStorage is outdated See Update method.
func (*ElementStorage) Remove ¶ added in v0.2.12
func (s *ElementStorage) Remove(id int32)
Remove removes a value and frees memory for something else
panic if there is nothing to free
func (*ElementStorage) SlowClear ¶ added in v0.2.12
func (s *ElementStorage) SlowClear()
SlowClear clears the the ElementStorage slowly with is tradeoff for having faster allocating speed
func (*ElementStorage) Used ¶ added in v0.2.12
func (s *ElementStorage) Used(id int32) bool
Used returns whether id is used
type Int32Vec ¶ added in v0.2.12
type Int32Vec []int32
Int32Vec is a standard Vector type with utility methods
func (*Int32Vec) BiInsert ¶ added in v0.2.12
BiInsert inserts inserts value in a way that keeps vec sorted, binary search is used to determinate where to insert
func (Int32Vec) BiSearch ¶ added in v0.2.12
BiSearch performs a binary search on Ves assuming it is sorted. cmp consumer should return 0 if a == b equal, 1 if a > b and 2 if b > a, even if value wos not found it returns it returns closest index and false. If Int32Vec is empty -1 and false is returned
func (*Int32Vec) Clear ¶ added in v0.2.12
func (v *Int32Vec) Clear()
Clear is equivalent to Truncate(0)
func (Int32Vec) Clone ¶ added in v0.2.12
Clone creates new Int32Vec copies content of v to it and returns it
func (*Int32Vec) Extend ¶ added in v0.2.12
Extend extends vec size by amount so then len(Int32Vec) = len(Int32Vec) + amount
func (Int32Vec) Find ¶ added in v0.2.12
Find returns first element for which find returns true along with index, if there is none, index equals -1
func (Int32Vec) ForEach ¶ added in v0.2.12
ForEach is a standard foreach method. Its shortcut for modifying all elements
func (*Int32Vec) InsertSlice ¶ added in v0.2.12
InsertSlice inserts slice to given index
func (Int32Vec) Move ¶ added in v0.2.12
Move moves value from old to new shifting elements in between
func (*Int32Vec) RemoveSlice ¶ added in v0.2.12
RemoveSlice removes sequence of slice
func (Int32Vec) Reverse ¶ added in v0.2.12
func (v Int32Vec) Reverse()
Reverse reverses content of slice
type IntVec ¶ added in v0.2.11
type IntVec []int
IntVec is a standard Vector type with utility methods
func (*IntVec) BiInsert ¶ added in v0.2.11
BiInsert inserts inserts value in a way that keeps vec sorted, binary search is used to determinate where to insert
func (IntVec) BiSearch ¶ added in v0.2.11
BiSearch performs a binary search on Ves assuming it is sorted. cmp consumer should return 0 if a == b equal, 1 if a > b and 2 if b > a, even if value wos not found it returns it returns closest index and false. If IntVec is empty -1 and false is returned
func (IntVec) Clone ¶ added in v0.2.11
Clone creates new IntVec copies content of v to it and returns it
func (*IntVec) Extend ¶ added in v0.2.11
Extend extends vec size by amount so then len(IntVec) = len(IntVec) + amount
func (IntVec) Find ¶ added in v0.2.11
Find returns first element for which find returns true along with index, if there is none, index equals -1
func (IntVec) ForEach ¶ added in v0.2.11
ForEach is a standard foreach method. Its shortcut for modifying all elements
func (*IntVec) InsertSlice ¶ added in v0.2.11
InsertSlice inserts slice to given index
func (*IntVec) RemoveSlice ¶ added in v0.2.11
RemoveSlice removes sequence of slice
func (IntVec) Reverse ¶ added in v0.2.11
func (v IntVec) Reverse()
Reverse reverses content of slice
type ItemVec ¶ added in v0.2.11
type ItemVec []Item
ItemVec is a standard Vector type with utility methods
func (*ItemVec) BiInsert ¶ added in v0.2.11
BiInsert inserts inserts value in a way that keeps vec sorted, binary search is used to determinate where to insert
func (ItemVec) BiSearch ¶ added in v0.2.11
BiSearch performs a binary search on Ves assuming it is sorted. cmp consumer should return 0 if a == b equal, 1 if a > b and 2 if b > a, even if value wos not found it returns it returns closest index and false. If ItemVec is empty -1 and false is returned
func (*ItemVec) Clear ¶ added in v0.2.11
func (v *ItemVec) Clear()
Clear is equivalent to Truncate(0)
func (ItemVec) Clone ¶ added in v0.2.11
Clone creates new ItemVec copies content of v to it and returns it
func (*ItemVec) Extend ¶ added in v0.2.11
Extend extends vec size by amount so then len(ItemVec) = len(ItemVec) + amount
func (ItemVec) Find ¶ added in v0.2.11
Find returns first element for which find returns true along with index, if there is none, index equals -1
func (ItemVec) ForEach ¶ added in v0.2.11
ForEach is a standard foreach method. Its shortcut for modifying all elements
func (*ItemVec) InsertSlice ¶ added in v0.2.11
InsertSlice inserts slice to given index
func (ItemVec) Move ¶ added in v0.2.11
Move moves value from old to new shifting elements in between
func (*ItemVec) RemoveSlice ¶ added in v0.2.11
RemoveSlice removes sequence of slice
func (ItemVec) Reverse ¶ added in v0.2.11
func (v ItemVec) Reverse()
Reverse reverses content of slice
type KeyValueCapsule ¶ added in v0.2.11
KeyValueCapsule is component of ordered map that stores key and a value
type KeyValueOrdered ¶ added in v0.2.11
type KeyValueOrdered struct {
// contains filtered or unexported fields
}
KeyValueOrdered stores its items in underlying slice and map just keeps indexes
func NKeyValueOrdered ¶ added in v0.2.11
func NKeyValueOrdered() KeyValueOrdered
NOrderedMap initializes inner map
func (*KeyValueOrdered) Clear ¶ added in v0.2.11
func (o *KeyValueOrdered) Clear()
Clear removes all elements
func (*KeyValueOrdered) Index ¶ added in v0.2.11
func (o *KeyValueOrdered) Index(name Key) (int, bool)
Index returns index of a key's value
func (*KeyValueOrdered) Insert ¶ added in v0.2.11
func (o *KeyValueOrdered) Insert(key Key, idx int, value Value)
Insert insets element under index and key
func (*KeyValueOrdered) IsNil ¶ added in v0.2.11
func (o *KeyValueOrdered) IsNil() bool
IsNil reports whether KeyValueOrdered instance is uninitialized
func (*KeyValueOrdered) Put ¶ added in v0.2.11
func (o *KeyValueOrdered) Put(key Key, value Value)
Put puts a value under key
func (*KeyValueOrdered) ReIndex ¶ added in v0.2.11
func (o *KeyValueOrdered) ReIndex(old, new int)
ReIndex changes index of an element
func (*KeyValueOrdered) Remove ¶ added in v0.2.11
func (o *KeyValueOrdered) Remove(key Key) (val Value, idx int, ok bool)
Remove removes the key value pair
func (*KeyValueOrdered) RemoveIndex ¶ added in v0.2.11
func (o *KeyValueOrdered) RemoveIndex(idx int) (cell KeyValueCapsule)
RemoveIndex removes by index
func (*KeyValueOrdered) Rename ¶ added in v0.2.11
func (o *KeyValueOrdered) Rename(old, new Key) bool
Rename renames element and keeps index
func (*KeyValueOrdered) Slice ¶ added in v0.2.11
func (o *KeyValueOrdered) Slice() []KeyValueCapsule
Slice returns underlying slice
type QuickPool ¶
type QuickPool struct {
// contains filtered or unexported fields
}
QuickPool is template that can store interface referenced objects on one place reducing allocation, if you are creating lot of date stored behind interface that has very short livetime QuickPool can be nice optimization
func (*QuickPool) Item ¶
Item returns pointer to pooling struct that is free, if no free struct is present new one is allocated