Removed unneeded pool data structures
This commit is contained in:
parent
4987f1b0d2
commit
7949c1ca5d
4 changed files with 45 additions and 108 deletions
|
|
@ -1,50 +0,0 @@
|
|||
package adb_pool
|
||||
|
||||
Pool :: struct($T: typeid) {
|
||||
pool: []T,
|
||||
usage: int,
|
||||
}
|
||||
|
||||
init :: proc(pool: ^Pool($T), capacity: int, allocator := context.allocator) {
|
||||
pool.pool = make([]T, capacity, allocator)
|
||||
pool.usage = 0
|
||||
}
|
||||
|
||||
elems_available :: proc(pool: ^Pool($T), capacity: int) -> bool {
|
||||
return pool.usage + count <= pool.capacity
|
||||
}
|
||||
|
||||
capacity :: proc(pool: Pool($T)) -> int {
|
||||
return len(pool.pool)
|
||||
}
|
||||
|
||||
get :: proc(pool: ^Pool($T), count: int) -> []T {
|
||||
range_to := pool.usage + count
|
||||
assert(range_to <= len(pool.pool), "pool.get count reaches outside preallocated size")
|
||||
elements := pool.pool[pool.usage:]
|
||||
pool.usage += count
|
||||
return elements
|
||||
}
|
||||
|
||||
usage :: proc(pool: Pool($T)) -> int {
|
||||
return pool.usage
|
||||
}
|
||||
|
||||
get_allocated_elements :: proc(pool: Pool($T)) -> []T {
|
||||
return pool.pool[:pool.usage]
|
||||
}
|
||||
|
||||
clear :: proc(pool: ^Pool($T)) {
|
||||
pool.usage = 0
|
||||
}
|
||||
|
||||
free_range :: proc(pool: ^Pool($T), from, count: int) {
|
||||
assert(count > 0, "Cannot free zero or negative count")
|
||||
to := from + count
|
||||
assert(to < pool.usage, "Cannot free beyond usage")
|
||||
mem.copy(&pool.pool[from], &pool.pool[to], (pool.usage - to) * size_of(T))
|
||||
}
|
||||
|
||||
raw_data :: proc(pool: ^Pool) -> rawptr {
|
||||
return raw_data(pool.pool)
|
||||
}
|
||||
|
|
@ -280,6 +280,7 @@ foreign lib {
|
|||
GuiDropdownBox :: proc(bounds: Rectangle, text: cstring, active: ^c.int, editMode: bool) -> bool --- // Dropdown Box control, returns selected item
|
||||
GuiSpinner :: proc(bounds: Rectangle, text: cstring, value: ^c.int, minValue, maxValue: c.int, editMode: bool) -> c.int --- // Spinner control, returns selected value
|
||||
GuiValueBox :: proc(bounds: Rectangle, text: cstring, value: ^c.int, minValue, maxValue: c.int, editMode: bool) -> c.int --- // Value Box control, updates input text with numbers
|
||||
GuiValueBoxFloat :: proc(bounds: Rectangle, text: cstring, text_value: cstring, value: ^c.float, editMode: bool) -> c.int --- // Value box control for float values
|
||||
GuiTextBox :: proc(bounds: Rectangle, text: cstring, textSize: c.int, editMode: bool) -> bool --- // Text Box control, updates input text
|
||||
|
||||
GuiSlider :: proc(bounds: Rectangle, textLeft: cstring, textRight: cstring, value: ^f32, minValue: f32, maxValue: f32) -> c.int --- // Slider control, returns selected value
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue