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). Edit on GitHub

FixObjectStack.clearQuick()



contains

checks if the array contains the object. Edit on GitHub

FixObjectStack.contains(var obj)



copy

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

FixObjectStack.copy(String propertyName, var target)



fill

Fills the array with the given object. Edit on GitHub

FixObjectStack.fill(var obj)



fromBase64

Restores an array from a previously exported state. Edit on GitHub

FixObjectStack.fromBase64( String b64)



indexOf

Returns the index of the first element that matches the given object. Edit on GitHub

FixObjectStack.indexOf(var obj)



insert

Inserts a element to the stack. Edit on GitHub

FixObjectStack.insert(var obj)



isEmpty

Checks whether the stack is empty. Edit on GitHub

FixObjectStack.isEmpty()



remove

Removes the element from the stack and fills up the gap. Edit on GitHub

FixObjectStack.remove(var obj)



removeElement

Removes the element at the given index and fills the gap. Edit on GitHub

FixObjectStack.removeElement(int index)



set

Replaces the object if it exists or inserts it at the end. Edit on GitHub

FixObjectStack.set(var obj)



size

Returns the number of used elements in the stack. Edit on GitHub

FixObjectStack.size()  override



sort

Sorts the array with the given compare function. Edit on GitHub

FixObjectStack.sort()



toBase64

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

FixObjectStack.toBase64()