memory

package
v0.2.12 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package memory contains structs for genny to generate templates of your need

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Float32BiComp added in v0.2.12

func Float32BiComp(a, b float32) uint8

func Float64BiComp added in v0.2.12

func Float64BiComp(a, b float64) uint8

func Int16BiComp added in v0.2.12

func Int16BiComp(a, b int16) uint8

func Int32BiComp added in v0.2.12

func Int32BiComp(a, b int32) uint8

func Int64BiComp added in v0.2.12

func Int64BiComp(a, b int64) uint8

func Int8BiComp added in v0.2.12

func Int8BiComp(a, b int8) uint8

func IntBiComp added in v0.2.12

func IntBiComp(a, b int) uint8

func NumberBiComp added in v0.2.12

func NumberBiComp(a, b Number) uint8

func Uint16BiComp added in v0.2.12

func Uint16BiComp(a, b uint16) uint8

func Uint32BiComp added in v0.2.12

func Uint32BiComp(a, b uint32) uint8

func Uint64BiComp added in v0.2.12

func Uint64BiComp(a, b uint64) uint8

func Uint8BiComp added in v0.2.12

func Uint8BiComp(a, b uint8) uint8

func UintBiComp added in v0.2.12

func UintBiComp(a, b uint) uint8

Types

type Element added in v0.2.12

type Element generic.Type

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

func (v *Int32Vec) BiInsert(value int32, cmp func(a, b int32) uint8)

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

func (v Int32Vec) BiSearch(value int32, cmp func(a, b int32) uint8) (int, bool)

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

func (v Int32Vec) Clone() Int32Vec

Clone creates new Int32Vec copies content of v to it and returns it

func (*Int32Vec) Extend added in v0.2.12

func (v *Int32Vec) Extend(amount int)

Extend extends vec size by amount so then len(Int32Vec) = len(Int32Vec) + amount

func (*Int32Vec) Filter added in v0.2.12

func (v *Int32Vec) Filter(filter func(e int32) bool)

Filter leaves only elements for with filter returns true

func (Int32Vec) Find added in v0.2.12

func (v Int32Vec) Find(find func(e int32) bool) (idx int, res int32)

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

func (v Int32Vec) ForEach(con func(i int, e int32) int32)

ForEach is a standard foreach method. Its shortcut for modifying all elements

func (*Int32Vec) Insert added in v0.2.12

func (v *Int32Vec) Insert(idx int, val int32)

Insert inserts value to given index

func (*Int32Vec) InsertSlice added in v0.2.12

func (v *Int32Vec) InsertSlice(idx int, val []int32)

InsertSlice inserts slice to given index

func (Int32Vec) Last added in v0.2.12

func (v Int32Vec) Last() int32

Last returns last element of slice

func (Int32Vec) Len added in v0.2.12

func (v Int32Vec) Len() int

Len implements VertexData interface

func (Int32Vec) Move added in v0.2.12

func (v Int32Vec) Move(old, new int)

Move moves value from old to new shifting elements in between

func (*Int32Vec) Pop added in v0.2.12

func (v *Int32Vec) Pop() int32

Pop removes last element

func (*Int32Vec) PopFront added in v0.2.12

func (v *Int32Vec) PopFront() int32

PopFront removes first element and returns it

func (*Int32Vec) Remove added in v0.2.12

func (v *Int32Vec) Remove(idx int) (val int32)

Remove removes element and returns it

func (*Int32Vec) RemoveSlice added in v0.2.12

func (v *Int32Vec) RemoveSlice(start, end int)

RemoveSlice removes sequence of slice

func (*Int32Vec) Resize added in v0.2.12

func (v *Int32Vec) Resize(size int)

Resize resizes the Int32Vec

func (Int32Vec) Reverse added in v0.2.12

func (v Int32Vec) Reverse()

Reverse reverses content of slice

func (Int32Vec) Rewrite added in v0.2.12

func (v Int32Vec) Rewrite(o Int32Vec, idx int)

Rewrite revrites elements from index to o values

func (Int32Vec) Sort added in v0.2.12

func (v Int32Vec) Sort(comp func(a, b int32) bool)

Sort is quicksort for Int32Vec, because this is part of a template comp function is necessary

func (Int32Vec) Swap added in v0.2.12

func (v Int32Vec) Swap(a, b int)

Swap swaps two elements

func (*Int32Vec) Truncate added in v0.2.12

func (v *Int32Vec) Truncate(l int)

Truncate in comparison to truncating by bracket operator also sets all forgoten elements to default value, witch is useful if this is slice of pointers Int32Vec will have length you specify

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

func (v *IntVec) BiInsert(value int, cmp func(a, b int) uint8)

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

func (v IntVec) BiSearch(value int, cmp func(a, b int) uint8) (int, bool)

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) Clear added in v0.2.11

func (v *IntVec) Clear()

Clear is equivalent to Truncate(0)

func (IntVec) Clone added in v0.2.11

func (v IntVec) Clone() IntVec

Clone creates new IntVec copies content of v to it and returns it

func (*IntVec) Extend added in v0.2.11

func (v *IntVec) Extend(amount int)

Extend extends vec size by amount so then len(IntVec) = len(IntVec) + amount

func (*IntVec) Filter added in v0.2.11

func (v *IntVec) Filter(filter func(e int) bool)

Filter leaves only elements for with filter returns true

func (IntVec) Find added in v0.2.11

func (v IntVec) Find(find func(e int) bool) (idx int, res int)

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

func (v IntVec) ForEach(con func(i int, e int) int)

ForEach is a standard foreach method. Its shortcut for modifying all elements

func (*IntVec) Insert added in v0.2.11

func (v *IntVec) Insert(idx int, val int)

Insert inserts value to given index

func (*IntVec) InsertSlice added in v0.2.11

func (v *IntVec) InsertSlice(idx int, val []int)

InsertSlice inserts slice to given index

func (IntVec) Last added in v0.2.11

func (v IntVec) Last() int

Last returns last element of slice

func (IntVec) Len added in v0.2.11

func (v IntVec) Len() int

Len implements VertexData interface

func (IntVec) Move added in v0.2.11

func (v IntVec) Move(old, new int)

Move moves value from old to new shifting elements in between

func (*IntVec) Pop added in v0.2.11

func (v *IntVec) Pop() int

Pop removes last element

func (*IntVec) PopFront added in v0.2.11

func (v *IntVec) PopFront() int

PopFront removes first element and returns it

func (*IntVec) Remove added in v0.2.11

func (v *IntVec) Remove(idx int) (val int)

Remove removes element and returns it

func (*IntVec) RemoveSlice added in v0.2.11

func (v *IntVec) RemoveSlice(start, end int)

RemoveSlice removes sequence of slice

func (*IntVec) Resize added in v0.2.11

func (v *IntVec) Resize(size int)

Resize resizes the IntVec

func (IntVec) Reverse added in v0.2.11

func (v IntVec) Reverse()

Reverse reverses content of slice

func (IntVec) Rewrite added in v0.2.11

func (v IntVec) Rewrite(o IntVec, idx int)

Rewrite revrites elements from index to o values

func (IntVec) Sort added in v0.2.11

func (v IntVec) Sort(comp func(a, b int) bool)

Sort is quicksort for IntVec, because this is part of a template comp function is necessary

func (IntVec) Swap added in v0.2.11

func (v IntVec) Swap(a, b int)

Swap swaps two elements

func (*IntVec) Truncate added in v0.2.11

func (v *IntVec) Truncate(l int)

Truncate in comparison to truncating by bracket operator also sets all forgoten elements to default value, witch is useful if this is slice of pointers IntVec will have length you specify

type Item added in v0.2.11

type Item generic.Type

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

func (v *ItemVec) BiInsert(value Item, cmp func(a, b Item) uint8)

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

func (v ItemVec) BiSearch(value Item, cmp func(a, b Item) uint8) (int, bool)

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

func (v ItemVec) Clone() ItemVec

Clone creates new ItemVec copies content of v to it and returns it

func (*ItemVec) Extend added in v0.2.11

func (v *ItemVec) Extend(amount int)

Extend extends vec size by amount so then len(ItemVec) = len(ItemVec) + amount

func (*ItemVec) Filter added in v0.2.11

func (v *ItemVec) Filter(filter func(e Item) bool)

Filter leaves only elements for with filter returns true

func (ItemVec) Find added in v0.2.11

func (v ItemVec) Find(find func(e Item) bool) (idx int, res Item)

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

func (v ItemVec) ForEach(con func(i int, e Item) Item)

ForEach is a standard foreach method. Its shortcut for modifying all elements

func (*ItemVec) Insert added in v0.2.11

func (v *ItemVec) Insert(idx int, val Item)

Insert inserts value to given index

func (*ItemVec) InsertSlice added in v0.2.11

func (v *ItemVec) InsertSlice(idx int, val []Item)

InsertSlice inserts slice to given index

func (ItemVec) Last added in v0.2.11

func (v ItemVec) Last() Item

Last returns last element of slice

func (ItemVec) Len added in v0.2.11

func (v ItemVec) Len() int

Len implements VertexData interface

func (ItemVec) Move added in v0.2.11

func (v ItemVec) Move(old, new int)

Move moves value from old to new shifting elements in between

func (*ItemVec) Pop added in v0.2.11

func (v *ItemVec) Pop() Item

Pop removes last element

func (*ItemVec) PopFront added in v0.2.11

func (v *ItemVec) PopFront() Item

PopFront removes first element and returns it

func (*ItemVec) Remove added in v0.2.11

func (v *ItemVec) Remove(idx int) (val Item)

Remove removes element and returns it

func (*ItemVec) RemoveSlice added in v0.2.11

func (v *ItemVec) RemoveSlice(start, end int)

RemoveSlice removes sequence of slice

func (*ItemVec) Resize added in v0.2.11

func (v *ItemVec) Resize(size int)

Resize resizes the ItemVec

func (ItemVec) Reverse added in v0.2.11

func (v ItemVec) Reverse()

Reverse reverses content of slice

func (ItemVec) Rewrite added in v0.2.11

func (v ItemVec) Rewrite(o ItemVec, idx int)

Rewrite revrites elements from index to o values

func (ItemVec) Sort added in v0.2.11

func (v ItemVec) Sort(comp func(a, b Item) bool)

Sort is quicksort for ItemVec, because this is part of a template comp function is necessary

func (ItemVec) Swap added in v0.2.11

func (v ItemVec) Swap(a, b int)

Swap swaps two elements

func (*ItemVec) Truncate added in v0.2.11

func (v *ItemVec) Truncate(l int)

Truncate in comparison to truncating by bracket operator also sets all forgoten elements to default value, witch is useful if this is slice of pointers ItemVec will have length you specify

type Key added in v0.2.11

type Key generic.Type

type KeyValueCapsule added in v0.2.11

type KeyValueCapsule struct {
	Key   Key
	Value Value
}

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

func (*KeyValueOrdered) Value added in v0.2.11

func (o *KeyValueOrdered) Value(key Key) (val Value, idx int, ok bool)

Value returns value under key

type Number added in v0.2.12

type Number generic.Number

type Quick added in v0.2.11

type Quick generic.Type

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

func (q *QuickPool) Item(new Quick) *Quick

Item returns pointer to pooling struct that is free, if no free struct is present new one is allocated

func (*QuickPool) Over

func (q *QuickPool) Over(val Quick) *Quick

Over overwrites by raw value and returns pointer to its new position

func (*QuickPool) Restart

func (q *QuickPool) Restart()

Restart makes QuickPool reuse old objects, if you cannot call this as pooling structs you taken are constantly referenced, its useles to use QuickPool in first place

type Value added in v0.2.11

type Value generic.Type

Jump to

Keyboard shortcuts

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