HISE Docs

FixObjectStack


This data container in an enhancement of the FixObjectArray and keeps track of the amount of "used" elements.

It's special behaviour is that it always guarantees a dense structure: removing elements will just move the last element into the empty position. This will destroy the "order" of elements, but for use cases where the elements are not directly related with each other, this is a good trade-off because it allows very fast insertions & removal operations.

// This is the init state of our stack
[0, 1, 2, 3];

// Insert X

[0, 1, 2, 3, X];

// Remove 2, move X into the gap

[0, 1, X, 3];

// Insert Y at the end

[0, 1, X, 3, Y]


Class methods

clear

Clears the stack.

FixObjectStack.clear() override


Like FixObjectArray.clear() , this is a rather slow operation because it will iterate over the entire data range. If you want to "reset" the state in a realtime context, using clearQuick() might be a better candidate.

clearQuick

Clears the stack by moving the end pointer to the start (leaving its elements in the same state).

FixObjectStack.clearQuick()



contains

checks if the array contains the object.

FixObjectStack.contains(var obj)



copy

Copies the property from each element into a buffer (or array).

FixObjectStack.copy(String propertyName, var target)



fill

Fills the array with the given object.

FixObjectStack.fill(var obj)



fromBase64

Restores an array from a previously exported state.

FixObjectStack.fromBase64( String b64)



indexOf

Returns the index of the first element that matches the given object.

FixObjectStack.indexOf(var obj)



insert

Inserts a element to the stack.

FixObjectStack.insert(var obj)



isEmpty

Checks whether the stack is empty.

FixObjectStack.isEmpty()



remove

Removes the element from the stack and fills up the gap.

FixObjectStack.remove(var obj)



removeElement

Removes the element at the given index and fills the gap.

FixObjectStack.removeElement(int index)



set

Replaces the object if it exists or inserts it at the end.

FixObjectStack.set(var obj)



size

Returns the number of used elements in the stack.

FixObjectStack.size()  override



sort

Sorts the array with the given compare function.

FixObjectStack.sort()



toBase64

Exports the memory region of the entire array as Base64 encoded string.

FixObjectStack.toBase64()