IAllocator

Description

interface Tinman.Engine.Rendering.Util.IAllocator
<TCount in val>
<TCoords val>
<TRange out val>

Derived from

ICapacity

Extended by

AllocatorBase abstract

Base interface for classes that allocate contiguous slot ranges in a domain with one or more dimensions.

An allocator has a fixed number of logical slots C, which is indicated by ICapacity.Capacity. Zero-based indices are used to refer to slots, their number range is [0..C[. The number of slots along the axis of the domain dimension S is given by Size. The allocator slots are arranged in an N-dimensional square, so that C = S^N holds true. An IAllocator object consumes memory proportionally to the actual number of active allocations, i.e. the number of calls to Allocate for which Release has not been called yet.

Public / Methods

Allocate


public method Allocate → (1)

count in : TCount

The number of slots to allocate along each domain axis.

returns → int32

Slot index of the allocation start or -1 iff the allocation request cannot be satisfied (for example, there are not enough contiguous free slots).

Allocates a slot range.

Count


[Pure]
public method Count → (1)

slot in : int32

The slot index of the allocation start.

returns → int32

The number of slots in the allocation or 0 iff the given slot in is invalid.

Returns the number of slots in the given allocation.

First


[Pure]
public method First → (1)

slot in : int32

The slot index.

returns → int32

Slot index of the start of the allocation that contains slot in or -1 iff the given slot in is not allocated.

Returns the slot index of the start of the allocation that contains the given slot in.

Range


[Pure]
public method Range → (1)

slot in : int32

The slot index of the allocation start.

returns → TRange

The slot range of the allocation. If slot in is invalid, an empty range will be returned.

Returns the slot range of the given allocation.

Release


public method Release → (1)

slot in : int32

The slot index of the allocation start.

returns → bool

true if the allocation has been released,
false if slot in is invalid.

Releases an allocated slot range.

Release​All


public method ReleaseAll → ()

Releases all allocations.

Slot​From​Coords


[Pure]
public method SlotFromCoords → (1)

coords in : TCoords

The domain coordinates.

returns → int32

The slot index.

Transforms the given domain coordinates to the corresponding slot index.

Slot​To​Coords


[Pure]
public method SlotToCoords → (1)

slot in : int32

The slot index.

returns → TCoords

The domain coordinates.

Transforms the slot index to the corresponding domain coordinates.

Public / Attributes

Size


public attribute Size → (get)

value : int32

[>0]
The allocator size, in slots.

Returns the size along a single domain axis.