def reserve_fresh
bendvy-ecs-core@0.1.0.3 · entity_allocator.bend:90
import bendvy-ecs-core@0.1.0.3/entity_allocator.bend as EntityAllocator
import Base
import entity_key.bend as K
90def reserve_fresh(available:Bool,grow:Bool,allocator:Allocator) -> Allocator & Reservation:
91 match available grow allocator:
92 case False{} _ allocator:(allocator,Exhausted{})
93 case True{} False{} Allocator{+next,_,slots,+capacity,+depth,free,order}:(Allocator{(next + 1 : U32),next,Array.set(Slot,slots,next,Slot{0,Consumed{}}),capacity,depth,free,List.append(&2,K.Key,order,[K.EntityKey{next,0}])},Reserved{K.EntityKey{next,0}})
94 case True{} True{} Allocator{+next,_,slots,+capacity,+depth,free,order}:(Allocator{(next + 1 : U32),next,Array.set(Slot,ANode{slots,Array.new(Slot,depth,Slot{0,Consumed{}})},next,Slot{0,Consumed{}}),(capacity * 2 : U32),1n+depth,free,List.append(&2,K.Key,order,[K.EntityKey{next,0}])},Reserved{K.EntityKey{next,0}})