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

Summary

Actions Summary Table

ActionsDescription
Add(integer row, integer column, Type value)This action adds a value at a location in the table.
AddRow(Libraries.Containers.Array<Type> row)This action adds a row to the table.
AddToEndOfRow(integer row, Type value)This action adds an item to the end of a row in the table.
AddToFrontOfRow(integer row, Type value)This action adds an item to the front of the table's row at index 0.
Compare(Libraries.Language.Object object)This action compares two object hash codes and returns a CompareResult.
Copy()This blueprint action copies an object and returns the copy.
Empty()This action empty's the table, clearing out all of the items contained within it.
Equals(Libraries.Language.Object object)This action determines if two objects are equal based on their hash code values.
Get(integer row, integer column)This action gets the item at a given location in an table.
GetAutoResize()This action returns true if the table is dynamic(resizable) or false if the table does not automatically resize.
GetFromEndOfRow(integer row)This action gets the item at the end of the row in the table(the item will remain in the table).
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).
GetHashCode()This action gets the hash code for an object.
GetMaxNumberOfColumns()This action gets the capacity of columns in the table(max size of columns).
GetMaxNumberOfRows()This action gets the capacity of rows in the table(max size of rows).
GetNumberOfRows()This action gets the size of the rows in the table.
GetRow(integer row)This action gets a row from the table at a given location.
GetRowIterator()This action gets an iterator for the object and returns that iterator.
GetSizeOfRow(integer row)This action gets the size of the row in the table.
Has(Type value)This action determines if an addable object contains a certain item.
IsEmpty()This action returns a boolean value, true if the container is empty and false if it contains any items.
Remove(Type value)This action removes the first occurrence of an item that is found in the Addable object.
RemoveAll(Type value)This action removes all occurrences of an item from the Addable object.
RemoveAt(integer row, integer column)This action removes an item from an indexed object and returns that item.
RemoveFromEndOfRow(integer row)This action removes the item at the end of the table.
RemoveFromFrontOfRow(integer row)This action removes the item at the front of the table.
Set(integer row, integer column, Type value)This action sets the item at a given location in the indexed object to a new item.
SetAutoResize(boolean resizable)This action changes the flag that tells the structure if it is a dynamic table or not.
SetMaxSize(integer row, integer column)This action sets the number of items that can be stored in the table(max rows and columns).
SetSize(integer row, integer column)This action sets the size of the table and fills it with undefined items.

Actions Documentation

Add(integer row, integer column, Type value)

This action adds a value at a location in the table.

Example Code

use Libraries.Containers.Table
        Table<integer> myTable
        myTable:Add(0, 0, 22)

Parameters

AddRow(Libraries.Containers.Array<Type> row)

This action adds a row to the table.

Example Code

use Libraries.Containers.Table
        use Libraries.Containers.Array
        Table<integer> myTable
        Array<integer> row
        myTable:AddRow(row)

Parameters

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.

Example Code

use Libraries.Containers.Table
        use Libraries.Containers.Array
        Table<integer> myTable
        myTable:AddToEndOfRow(0,12)

Parameters

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.

Example Code

use Libraries.Containers.Table
        Table<integer> myTable
        myTable:AddToFrontOfRow(0, 12)

Parameters

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns a CompareResult. The compare result is either larger if this hash code is larger than the object passed as a parameter, smaller, or equal.

Example Code

use Libraries.Language.Support.CompareResult
        Object o
        Object t
        CompareResult result = o:Compare(t)

Parameters

Return

Libraries.Language.Support.CompareResult: The Compare result, Smaller, Equal, or Larger.

Copy()

This blueprint action copies an object and returns the copy.

Example Code

use Libraries.Containers.Table
        //the array class is Copyable
        Table<integer> table
        Object o = table:Copy()
        Table<integer> copy = cast(Table<integer>, o)

Return

Libraries.Language.Object: Returns a copy of this object. This copy is not guaranteed to be a deep copy.

Empty()

This action empty's the table, clearing out all of the items contained within it.

Example Code

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.

Example Code

use Libraries.Language.Object
        use Libraries.Language.Types.Text
        Object o
        Text t
        boolean result = o:Equals(t)

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Get(integer row, integer column)

This action gets the item at a given location in an table.

Example Code

use Libraries.Containers.Table
        Table<integer> myTable
        myTable:SetSize(10,10)
        myTable:Set(0,0,22)
        integer result = myTable:Get(0,0)

Parameters

Return

Libraries.Language.Object: The item at the given location.

GetAutoResize()

This action returns true if the table is dynamic(resizable) or false if the table does not automatically resize.

Example Code

use Libraries.Containers.Table
        Table<integer> myTable
        boolean result = myTable:GetAutoResize()

Return

boolean: True if the table is resizable and false if it is not.

GetFromEndOfRow(integer row)

This action gets the item at the end of the row in the table(the item will remain in the table).

Example Code

use Libraries.Containers.Table
        Table<integer> myTable
        myTable:AddToEndOfRow(0, 4)
        myTable:AddToEndOfRow(0, 13)
        myTable:AddToEndOfRow(0, 12)
        integer value = myTable:GetFromEndOfRow(0)

Parameters

Return

Libraries.Language.Object: The item at the end of the row in the table.

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).

Example Code

use Libraries.Containers.Table
        Table<integer> myTable
        myTable:AddToEndOfRow(0,4)
        myTable:AddToEndOfRow(0,13)
        myTable:AddToEndOfRow(0,12)
        integer value = myTable:GetFromFrontOfRow(0)

Parameters

Return

Libraries.Language.Object: The item at the front of the array.

GetHashCode()

This action gets the hash code for an object.

Example Code

Object o
        integer hash = o:GetHashCode()

Return

integer: The integer hash code of the object.

GetMaxNumberOfColumns()

This action gets the capacity of columns in the table(max size of columns).

Example Code

use Libraries.Containers.Table
        Table<integer> myTable
        integer maxSize = myTable:GetMaxNumberOfColumns()

Return

integer:

GetMaxNumberOfRows()

This action gets the capacity of rows in the table(max size of rows).

Example Code

use Libraries.Containers.Table
        Table<integer> myTable
        integer maxSize = myTable:GetMaxNumberOfRows()

Return

integer:

GetNumberOfRows()

This action gets the size of the rows in the table.

Example Code

use Libraries.Containers.Table
        Table<integer> myTable
        integer size = myTable:GetNumberOfRows()

Return

integer:

GetRow(integer row)

This action gets a row from the table at a given location.

Example Code

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)

Parameters

Return

Libraries.Containers.Array: The array or row at the given location

GetRowIterator()

This action gets an iterator for the object and returns that iterator.

Example Code

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()

Return

Libraries.Containers.Iterator: Returns the iterator for an object.

GetSizeOfRow(integer row)

This action gets the size of the row in the table.

Example Code

use Libraries.Containers.Table
        Table<integer> myTable
        integer size = myTable:GetSizeOfRow(0)

Parameters

Return

integer:

Has(Type value)

This action determines if an addable object contains a certain item.

Example Code

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)

Parameters

Return

boolean: Returns true if the item was in the Addable object and false if it was not.

IsEmpty()

This action returns a boolean value, true if the container is empty and false if it contains any items.

Example Code

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()

Return

boolean: Returns true when the container is empty and false when it is not.

Remove(Type value)

This action removes the first occurrence of an item that is found in the Addable object.

Example Code

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)

Parameters

Return

boolean: Returns true if the item was removed and false if it was not removed.

RemoveAll(Type value)

This action removes all occurrences of an item from the Addable object.

Example Code

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)

Parameters

Return

boolean: Returns true if the item was removed and false if it was not removed.

RemoveAt(integer row, integer column)

This action removes an item from an indexed object and returns that item.

Example Code

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)

Parameters

Return

Libraries.Language.Object: The item that was removed from the indexed object.

RemoveFromEndOfRow(integer row)

This action removes the item at the end of the table.

Example Code

use Libraries.Containers.Table
        Table<integer> myTable
        myTable:AddToEndOfRow(0, 33)
        myTable:AddToEndOfRow(0, 13)
        myTable:AddToEndOfRow(0, 43)
        integer removed = myTable:RemoveFromEndOfRow(0)

Parameters

Return

Libraries.Language.Object: The item at the end of the table.

RemoveFromFrontOfRow(integer row)

This action removes the item at the front of the table.

Example Code

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)

Parameters

Return

Libraries.Language.Object: The item at the front of the table.

Set(integer row, integer column, Type value)

This action sets the item at a given location in the indexed object to a new item.

Example Code

use Libraries.Containers.Table
        Table<integer> myTable
        myTable:SetSize(10, 10)
        myTable:Set(0, 0, 22)

Parameters

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.

Example Code

use Libraries.Containers.Table
        Table<integer> myTable
        myTable:SetAutoResize(false)
        myTable:SetSize(10, 10)

Parameters

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.

Example Code

use Libraries.Containers.Table
        Table<integer> myTable
        myTable:SetMaxSize(10, 10)

Parameters

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.

Example Code

use Libraries.Containers.Table
        Table<integer> myTable
        myTable:SetSize(10,10)

Parameters