-
Notifications
You must be signed in to change notification settings - Fork 6
/
pool.go
34 lines (30 loc) · 794 Bytes
/
pool.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package microui
/*============================================================================
** pool
**============================================================================*/
func (ctx *Context) PoolInit(items []MuPoolItem, id mu_Id) int {
f := ctx.Frame
var n int = -1
for i := 0; i < len(items); i++ {
if items[i].LastUpdate < f {
f = items[i].LastUpdate
n = i
}
}
expect(n > -1)
items[n].ID = id
ctx.PoolUpdate(items, n)
return n
}
// returns the index of an ID in the pool. returns -1 if it is not found
func (ctx *Context) PoolGet(items []MuPoolItem, id mu_Id) int {
for i := 0; i < len(items); i++ {
if items[i].ID == id {
return i
}
}
return -1
}
func (ctx *Context) PoolUpdate(items []MuPoolItem, idx int) {
items[idx].LastUpdate = ctx.Frame
}