Documentation ¶
Overview ¶
Package memory contains structs for genny to generate templates of your need
Index ¶
- func NumberBiComp(a, b Number) uint8
- type Element
- type ElementCapsule
- type ElementStorage
- func (s *ElementStorage) Allocate() (*Element, int)
- func (s *ElementStorage) AllocateID(id int) *Element
- func (s *ElementStorage) Blanc()
- func (s *ElementStorage) Clear()
- func (s *ElementStorage) Count() int
- func (s *ElementStorage) Item(id int) *Element
- func (s *ElementStorage) Len() int
- func (s *ElementStorage) Occupied() []int
- func (s *ElementStorage) Remove(id int)
- func (s *ElementStorage) SlowClear()
- func (s *ElementStorage) Used(id int) bool
- 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) 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(buff []int, comp func(a, pivot Item) bool) []int
- 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) (v Value, i int, b 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 NumberBiComp ¶ 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, int)
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 int) *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 int) *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() []int
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 int)
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 int) bool
Used returns whether id is used
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 keebuff 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) 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) (v Value, i int, b 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