Adt Optimized¶
Documentation for
std-library/ksp/data-structures/imports/adt-optimized.ksp
Import¶
import "_IVLS/std-library/ksp/data-structures/imports/adt-optimized.ksp"API¶
Macros¶
Functions¶
Macros¶
adt.CreateHeap(#name#, #size#, #type#)¶
(No description available.)
| Parameter | Description |
|---|---|
#name# |
name of heap |
#size# |
size of heap |
#type# |
type of heap (adt.HEAP_TYPE_MIN or adt.HEAP_TYPE_MAX) |
Post: Constructs an integer heap.
adt.CreateList(#name#, #size#)¶
(No description available.)
| Parameter | Description |
|---|---|
#name# |
name of list |
#size# |
size of list |
Post: Constructs an integer list.
adt.CreateQueue(#name#, #size#)¶
(No description available.)
| Parameter | Description |
|---|---|
#name# |
name of queue |
#size# |
size of queue |
Post: Constructs an integer queue.
adt.CreateStack(#name#, #size#)¶
(No description available.)
| Parameter | Description |
|---|---|
#name# |
name of stack |
#size# |
size of stack |
Post: Constructs an integer stack.
adt.HeapFunctions(#name#)¶
(No description available.)
Preconditions: Must be called in the script for every Heap declared.
| Parameter | Description |
|---|---|
#name# |
name of heap |
Post: Creates functions that operate on the heap.
adt.ListFunctions(#name#)¶
(No description available.)
Preconditions: Must be called in the script for every List declared.
| Parameter | Description |
|---|---|
#name# |
name of list |
Post: Creates functions that operate on the list.
adt.QueueFunctions(#name#)¶
(No description available.)
Preconditions: Must be called in the script for every Queue declared.
| Parameter | Description |
|---|---|
#name# |
name of queue |
Post: Creates functions that operate on the queue.
adt.StackFunctions(#name#)¶
(No description available.)
Preconditions: Must be called in the script for every Stack declared.
| Parameter | Description |
|---|---|
#name# |
name of stack |
Post: Creates functions that operate on the stack.
Functions¶
#name#.append(element)¶
(No description available.)
Preconditions: List must not be full.
| Parameter | Description |
|---|---|
element |
element to put in the list |
Post: Inserts the element at the end.
#name#.clear()¶
(No description available.)
Post: Will clear the list.
#name#.clear()¶
(No description available.)
Post: Will clear the list.
#name#.clear()¶
(No description available.)
Post: Will clear the list.
#name#.clear()¶
(No description available.)
Post: Will clear the list.
#name#.delete(idx)¶
(No description available.)
Preconditions: The list must not be empty.
| Parameter | Description |
|---|---|
idx |
the index of the element to delete |
Post: Will remove the element at specified idx from the list and re-align all elements.
#name#.delete_item(item)¶
(No description available.)
Preconditions: The list must not be empty.
| Parameter | Description |
|---|---|
item |
Post: Will remove the first element of specified velue from the list and re-align all elements.
#name#.get_next_re() -> result¶
(No description available.)
Returns: result — In-line returns the next index of read pointer.
#name#.get_next_wr() -> result¶
(No description available.)
Returns: result — In-line returns the next index of write pointer.
#name#.get_num_children(node) -> result¶
(No description available.)
Preconditions: Internal Use Only!
| Parameter | Description |
|---|---|
node |
index of the node in the heap array |
Returns: result — In-line returns the number of children a given node has. Does not fail upon checking
#name#.get_parent_idx(node) -> result¶
(No description available.)
Preconditions: node input must be greater than or equal to 0.
| Parameter | Description |
|---|---|
node |
index of the node in the heap array |
Returns: result — In-line returns the parent index of the node.
#name#.insert(element, idx)¶
(No description available.)
Preconditions: The list must not be full.
| Parameter | Description |
|---|---|
element |
element to push |
idx |
the desired location to put the element |
Post: Inserts the element at the specified index, re-aligning next elements forward.
#name#.peek() -> result¶
(No description available.)
Preconditions: Queue must not be empty.
Returns: result — Single-line returns the element. Returns adt.TASK_FAIL if the queue is empty.
#name#.peek() -> result¶
(No description available.)
Preconditions: Stack must not be empty.
Returns: result — Single-line returns the element. Returns adt.TASK_FAIL if the stack is empty.
#name#.peek(idx) -> result¶
(No description available.)
Preconditions: The list must not be empty.
| Parameter | Description |
|---|---|
idx |
Returns: result — Returns, but does not remove, the element at the specified index.
#name#.peek() -> result¶
(No description available.)
Preconditions: The heap must not be empty.
Returns: result — In-line returns the root node of the heap.
#name#.peek_end() -> result¶
(No description available.)
Preconditions: The list must not be empty.
Returns: result — Returns, but does not remove, the last element.
#name#.pop() -> result¶
(No description available.)
Preconditions: Queue must not be empty.
Returns: result — Single-line returns the element and increments the read pointer. Returns
#name#.pop() -> result¶
(No description available.)
Preconditions: Stack must not be empty.
Returns: result — Single-line returns the element and decrements the count. Returns
#name#.pop() -> result¶
(No description available.)
Preconditions: The list must not be empty.
Returns: result — Returns AND removes the element at the last index.
#name#.pop() -> result¶
(No description available.)
Preconditions: The heap must not be empty.
Returns: result — In-line returns the root node of the heap. Then removes it,
#name#.push(element)¶
(No description available.)
Preconditions: Queue must not be full.
| Parameter | Description |
|---|---|
element |
element to put in the queue |
Post: Inserts the element and increments the write pointer. Will be interrupted if the write pointer meets the read pointer.
#name#.push(element)¶
(No description available.)
Preconditions: Stack must not be full.
| Parameter | Description |
|---|---|
element |
element to put in the stack |
Post: Inserts the element and increments the count. Will not write if the stack is full.
#name#.push(element)¶
(No description available.)
Preconditions: Heap must not be full.
| Parameter | Description |
|---|---|
element |
element to put in the heap |
Post: Pushes the element onto the heap and sifts it to its pace.
#name#.retrieve(idx) -> result¶
(No description available.)
Preconditions: The list must not be empty.
| Parameter | Description |
|---|---|
idx |
the index of the element to pop |
Returns: result — Returns AND removes the element at the specified index.
#name#.retrieve_item(item) -> result¶
(No description available.)
Preconditions: The list must not be empty.
| Parameter | Description |
|---|---|
item |
Returns: result — Removes the first occurrence of the item and returns its index.
#name#.sift_down(node)¶
(No description available.)
Preconditions: Internal Use Only! Node must be valid idx.
| Parameter | Description |
|---|---|
node |
index of node to sift |
Post: Will sift a node downward through the heap. Single-line returns a task status flag.
#name#.sift_up(node)¶
(No description available.)
Preconditions: Internal Use Only! Node must be valid idx.
| Parameter | Description |
|---|---|
node |
index of node to sift |
Post: Will sift a node upward through the heap. Single-line returns a task status flag.
Example¶
// TODO: Add usage example