Libraries.Containers.Table Documentation
The Table class is a data structure that stores items in contiguous memory. An item is typically stored and accessed through an index or location(row and column). This location always starts at 0, this means the first item in the table is at location 0, 0. The default maximum size is set to 10, but can be changed by using the SetSize(row, column) method or the array will automatically make itself large when the space is needed (note: it is possible to turn the resizing off with the SetAutoResize(false) method).
Example Code
use Libraries.Containers.Table
class Main
action Main
//make the table
Table<integer> myTable
//add a value
myTable:AddToRow(0, 12)
//get it back
integer value = myTable:Get(0,0)
end
end
Inherits from: Libraries.Language.Object
Actions Documentation
Add(integer row, integer column, Type value)
This action adds a value at a location in the table.
Parameters
- integer row: The row to store the value at.
- integer column: The column to store the value at.
- Libraries.Language.Object: The item to be added to the indexed object.
Example
use Libraries.Containers.Table
Table<integer> myTable
myTable:Add(0, 0, 22)
AddRow(Libraries.Containers.Array<Type> row)
This action adds a row to the table.
Parameters
- Libraries.Containers.Array: A row (array) of values to add to the table.
Example
use Libraries.Containers.Table
use Libraries.Containers.Array
Table<integer> myTable
Array<integer> row
myTable:AddRow(row)
AddToEndOfRow(integer row, Type value)
This action adds an item to the end of a row in the table. If the max size has been reached an the table is not re-sizable an InvalidLocationError will be alerted.
Parameters
- integer row: The row to add the value to the end of.
- Libraries.Language.Object: The item to be added to the table.
Example
use Libraries.Containers.Table
use Libraries.Containers.Array
Table<integer> myTable
myTable:AddToEndOfRow(0,12)
AddToFrontOfRow(integer row, Type value)
This action adds an item to the front of the table's row at index 0. Then moves all other items down one index. If the max size is already reached and the array is not re-sizable an InvalidLocationError will be alerted.
Parameters
- integer row: The row to add the value to the end of.
- Libraries.Language.Object: The item to be added to the array.
Example
use Libraries.Containers.Table
Table<integer> myTable
myTable:AddToFrontOfRow(0, 12)
Compare(Libraries.Language.Object object)
This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.
Parameters
- Libraries.Language.Object: The object to compare to.
Return
integer: The Compare result, Smaller, Equal, or Larger.
Example
Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)
Copy()
This blueprint action copies an object and returns the copy.
Return
Libraries.Language.Object: Returns a copy of this object. This copy is not guaranteed to be a deep copy.
Example
use Libraries.Containers.Table
//the array class is Copyable
Table<integer> table
Object o = table:Copy()
Table<integer> copy = cast(Table<integer>, o)
Empty()
This action empty's the table, clearing out all of the items contained within it.
Example
use Libraries.Containers.Table
Table<integer> myTable
myTable:SetSize(10,10)
myTable:Set(0, 0, 22)
myTable:Set(1, 0, 33)
myTable:Set(2, 0, 45)
myTable:Set(3, 0, 22)
myTable:Empty()
Equals(Libraries.Language.Object object)
This action determines if two objects are equal based on their hash code values.
Parameters
- Libraries.Language.Object: The to be compared.
Return
boolean: True if the hash codes are equal and false if they are not equal.
Example
use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)
Get(integer row, integer column)
This action gets the item at a given location in an table.
Parameters
- integer row: The row the value is located at.
- integer column: The column the value is located at.
Return
Libraries.Language.Object: The item at the given location.
Example
use Libraries.Containers.Table
Table<integer> myTable
myTable:SetSize(10,10)
myTable:Set(0,0,22)
integer result = myTable:Get(0,0)
GetAutoResize()
This action returns true if the table is dynamic(resizable) or false if the table does not automatically resize.
Return
boolean: True if the table is resizable and false if it is not.
Example
use Libraries.Containers.Table
Table<integer> myTable
boolean result = myTable:GetAutoResize()
GetFromEndOfRow(integer row)
This action gets the item at the end of the row in the table(the item will remain in the table).
Parameters
- integer row: The row in the table.
Return
Libraries.Language.Object: The item at the end of the row in the table.
Example
use Libraries.Containers.Table
Table<integer> myTable
myTable:AddToEndOfRow(0, 4)
myTable:AddToEndOfRow(0, 13)
myTable:AddToEndOfRow(0, 12)
integer value = myTable:GetFromEndOfRow(0)
GetFromFrontOfRow(integer row)
This action gets the item at the front of the specified row in the table(the item will remain in the table).
Parameters
- integer row: The row in the table.
Return
Libraries.Language.Object: The item at the front of the array.
Example
use Libraries.Containers.Table
Table<integer> myTable
myTable:AddToEndOfRow(0,4)
myTable:AddToEndOfRow(0,13)
myTable:AddToEndOfRow(0,12)
integer value = myTable:GetFromFrontOfRow(0)
GetHashCode()
This action gets the hash code for an object.
Return
integer: The integer hash code of the object.
Example
Object o
integer hash = o:GetHashCode()
GetMaxNumberOfColumns()
This action gets the capacity of columns in the table(max size of columns).
Return
integer:
Example
use Libraries.Containers.Table
Table<integer> myTable
integer maxSize = myTable:GetMaxNumberOfColumns()
GetMaxNumberOfRows()
This action gets the capacity of rows in the table(max size of rows).
Return
integer:
Example
use Libraries.Containers.Table
Table<integer> myTable
integer maxSize = myTable:GetMaxNumberOfRows()
GetNumberOfRows()
This action gets the size of the rows in the table.
Return
integer:
Example
use Libraries.Containers.Table
Table<integer> myTable
integer size = myTable:GetNumberOfRows()
GetRow(integer row)
This action gets a row from the table at a given location.
Parameters
- integer row: The location to find the row
Return
Libraries.Containers.Array: The array or row at the given location
Example
use Libraries.Containers.Table
use Libraries.Containers.Array
Table<integer> myTable
myTable:SetSize(1,4)
myTable:Set(0, 0, 22)
myTable:Set(0, 1, 33)
myTable:Set(0, 2, 45)
myTable:Set(0, 3, 22)
Array<integer> row = myTable:GetRow(0)
GetRowIterator()
This action gets an iterator for the object and returns that iterator.
Return
Libraries.Containers.Iterator: Returns the iterator for an object.
Example
use Libraries.Containers.Table
use Libraries.Containers.Array
use Libraries.Containers.Iterator
Table<integer> myTable
myTable:SetSize(4,4)
myTable:Set(0, 0, 22)
myTable:Set(0, 1, 33)
myTable:Set(0, 2, 45)
myTable:Set(0, 3, 22)
Iterator<Array<integer>> it = myTable:GetRowIterator()
GetSizeOfRow(integer row)
This action gets the size of the row in the table.
Parameters
- integer row
Return
integer:
Example
use Libraries.Containers.Table
Table<integer> myTable
integer size = myTable:GetSizeOfRow(0)
Has(Type value)
This action determines if an addable object contains a certain item.
Parameters
- Libraries.Language.Object: The item to find in the Addable object.
Return
boolean: Returns true if the item was in the Addable object and false if it was not.
Example
use Libraries.Containers.Table
Table<integer> myTable
myTable:SetSize(10, 10)
myTable:Set(0, 0, 22)
myTable:Set(0, 1, 33)
myTable:Set(0, 2, 45)
myTable:Set(0, 3, 22)
boolean result = myTable:Has(33)
IsEmpty()
This action returns a boolean value, true if the container is empty and false if it contains any items.
Return
boolean: Returns true when the container is empty and false when it is not.
Example
use Libraries.Containers.Table
Table<integer> myTable
myTable:SetSize(10, 10)
myTable:Set(0, 0, 22)
myTable:Set(0, 1, 33)
myTable:Set(0, 2, 45)
myTable:Set(0, 3, 22)
boolean result = myTable:IsEmpty()
Remove(Type value)
This action removes the first occurrence of an item that is found in the Addable object.
Parameters
- Libraries.Language.Object: The item to find in the Addable object.
Return
boolean: Returns true if the item was removed and false if it was not removed.
Example
use Libraries.Containers.Table
Table<integer> myTable
myTable:SetSize(10,10)
myTable:Set(0, 0, 22)
myTable:Set(0, 1, 33)
myTable:Set(0, 2, 45)
myTable:Set(0, 3, 22)
boolean result = myTable:Remove(22)
RemoveAll(Type value)
This action removes all occurrences of an item from the Addable object.
Parameters
- Libraries.Language.Object: The item to find in the Addable object.
Return
boolean: Returns true if the item was removed and false if it was not removed.
Example
use Libraries.Containers.Table
Table<integer> myTable
myTable:SetSize(10,10)
myTable:Set(0, 0, 22)
myTable:Set(0, 1, 33)
myTable:Set(0, 2, 45)
myTable:Set(0, 3, 22)
boolean result = myTable:RemoveAll(22)
RemoveAt(integer row, integer column)
This action removes an item from an indexed object and returns that item.
Parameters
- integer row: The row in the table.
- integer column: The column in the table.
Return
Libraries.Language.Object: The item that was removed from the indexed object.
Example
use Libraries.Containers.Table
use Libraries.Containers.Array
Table<integer> myTable
myTable:SetSize(10,10)
myTable:Set(0, 0, 22)
myTable:Set(0, 1, 33)
myTable:Set(0, 2, 45)
myTable:Set(0, 3, 22)
integer item = myTable:RemoveAt(0, 2)
RemoveFromEndOfRow(integer row)
This action removes the item at the end of the table.
Parameters
- integer row
Return
Libraries.Language.Object: The item at the end of the table.
Example
use Libraries.Containers.Table
Table<integer> myTable
myTable:AddToEndOfRow(0, 33)
myTable:AddToEndOfRow(0, 13)
myTable:AddToEndOfRow(0, 43)
integer removed = myTable:RemoveFromEndOfRow(0)
RemoveFromFrontOfRow(integer row)
This action removes the item at the front of the table.
Parameters
- integer row
Return
Libraries.Language.Object: The item at the front of the table.
Example
use Libraries.Containers.Table
Table<integer> myTable
myTable:Add(0,0,33)
myTable:Add(0,1,13)
myTable:Add(0,2,43)
integer removed = myTable:RemoveFromFrontOfRow(0)
Set(integer row, integer column, Type value)
This action sets the item at a given location in the indexed object to a new item.
Parameters
- integer row: The row the value will be stored at.
- integer column: The column the value will be stored at.
- Libraries.Language.Object: The item to be added to the indexed object.
Example
use Libraries.Containers.Table
Table<integer> myTable
myTable:SetSize(10, 10)
myTable:Set(0, 0, 22)
SetAutoResize(boolean resizable)
This action changes the flag that tells the structure if it is a dynamic table or not. If it is dynamic then resizable is true and if it is not dynamic then resizable is false.
Parameters
- boolean resizable: The value to set the resizable flag to.
Example
use Libraries.Containers.Table
Table<integer> myTable
myTable:SetAutoResize(false)
myTable:SetSize(10, 10)
SetMaxSize(integer row, integer column)
This action sets the number of items that can be stored in the table(max rows and columns). The max size can only be increased, any value that is lower will leave the array with the same max size it had.
Parameters
- integer row: The max number of rows in the table.
- integer column: The max number of columns in the table.
Example
use Libraries.Containers.Table
Table<integer> myTable
myTable:SetMaxSize(10, 10)
SetSize(integer row, integer column)
This action sets the size of the table and fills it with undefined items. Changing the size of the table means any items already in the table must be copied over.
Parameters
- integer row: The number of rows.
- integer column: The number of columns.
Example
use Libraries.Containers.Table
Table<integer> myTable
myTable:SetSize(10,10)
On this page
Variables TableAction Documentation- Add(integer row, integer column, Type value)
- AddRow(Libraries.Containers.Array
row) - AddToEndOfRow(integer row, Type value)
- AddToFrontOfRow(integer row, Type value)
- Compare(Libraries.Language.Object object)
- Copy()
- Empty()
- Equals(Libraries.Language.Object object)
- Get(integer row, integer column)
- GetAutoResize()
- GetFromEndOfRow(integer row)
- GetFromFrontOfRow(integer row)
- GetHashCode()
- GetMaxNumberOfColumns()
- GetMaxNumberOfRows()
- GetNumberOfRows()
- GetRow(integer row)
- GetRowIterator()
- GetSizeOfRow(integer row)
- Has(Type value)
- IsEmpty()
- Remove(Type value)
- RemoveAll(Type value)
- RemoveAt(integer row, integer column)
- RemoveFromEndOfRow(integer row)
- RemoveFromFrontOfRow(integer row)
- Set(integer row, integer column, Type value)
- SetAutoResize(boolean resizable)
- SetMaxSize(integer row, integer column)
- SetSize(integer row, integer column)