Libraries.Containers.List Documentation

The List class is a data structure that stores items in nodes. Each of these nodes stores an item and a reference to the next and previous node in the sequence. Because of this, the list data structure does not need to re-size itself like an Array would when the structure is filled. One downside to this is, the nodes can only be accessed through the first or last nodes. Some basic examples and explanations of Lists can be found below.

Example Code

use Libraries.Containers.List
class Main
action Main
   //make the list
   List<integer> myList
   //add a value
   myList:Add(12)
   //get it back
   integer value = myList:GetFromFront()
end
end

Inherits from: Libraries.Language.Object

Actions Documentation

Add(integer location, Type value)

This action adds a value at a location in List.

Parameters

  • integer location: The index or location the value will be stored at.
  • Libraries.Language.Object: The item to be added to the List.

Example

use Libraries.Containers.List
List<integer> myList
myList:Add(12, 0)

Add(Type value)

This action adds a value at the end of the list.

Parameters

Example

use Libraries.Containers.List
List<integer> myList
myList:Add(12)

AddToEnd(Type value)

This action adds an item to the end of the list.

Parameters

Example

use Libraries.Containers.List
List<integer> myList
myList:AddToEnd(12)

AddToFront(Type value)

This action adds an item to the front of the list.

Parameters

Example

use Libraries.Containers.List
List<integer> myList
myList:AddToFront(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

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 action copies an object and returns the copy.

Return

Libraries.Language.Object: Returns a copy of this object.

Example

use Libraries.Containers.List
List<integer> myList
List<integer> copyList
myList:Add(12)
Object o = myList:Copy()
copyList = cast(List<integer>, o)

CopyToArray()

This action copies the list to an array data structure.

Return

Libraries.Containers.Array: This returns an array of the list.

Example

use Libraries.Containers.List
List<integer> myArray
myArray:Add(33)
myArray:Add(13)
myArray:Add(43)
myArray:Sort()

Empty()

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

Example

use Libraries.Containers.List
List<integer> myList
myList:Add(12)
myList:Empty() //the item we added is now gone

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

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

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

Parameters

  • integer location: The index or location the value is located at.

Return

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

Example

use Libraries.Containers.List
List<integer> myList
myList:Add(12)
myList:Add(13)
integer value = myList:Get(0)

GetFirstLocation(Type value)

This action gets the first occurrence of the item and returns its location.

Parameters

Return

integer: The location of the first occurrence of the item.

Example

use Libraries.Containers.List
List<integer> myList
myList:Add(12)
myList:Add(13)
myList:Add(12)
integer index = myList:GetFirstLocation(12)

GetFromEnd()

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

Return

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

Example

use Libraries.Containers.List
List<integer> myList
myList:Add(4)
myList:Add(13)
myList:Add(12)
integer value = myList:GetFromEnd()

GetFromFront()

This action gets the item at the front of the list(the item will remain in the list).

Return

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

Example

use Libraries.Containers.List
List<integer> myList
myList:Add(4)
myList:Add(13)
myList:Add(12)
integer value = myList:GetFromFront()

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

GetIterator()

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.List
use Libraries.Containers.Iterator
List<integer> myList
myList:Add(12)
myList:Add(13)
myList:Add(12)
Iterator<integer> listIterator = myList:GetIterator()

GetLastLocation(Type value)

This action gets the last occurrence of the item and returns its location.

Parameters

Return

integer: The location of the last occurrence of the item.

Example

use Libraries.Containers.List
List<integer> myList
myList:Add(12)
myList:Add(13)
myList:Add(12)
integer index = myList:GetLastLocation(12)

GetSize()

This action retrieves the number of elements or nodes in a list.

Return

integer: Returns an integer value representing the size of the list.

Example

use Libraries.Containers.List
List<integer> myList
myList:Add(12)
integer size = myList:GetSize()

Has(Type value)

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

Parameters

Return

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

Example

use Libraries.Containers.List
List<integer> myList
myList:Add(12)
myList:Add(1)
boolean hasItem = myList:Has(12)

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.List
List<integer> myList
if myList:IsEmpty()
    output "List is empty."
end

Remove(Type value)

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

Parameters

Return

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

Example

use Libraries.Containers.List
List<integer> myList
myList:Add(43)
myList:Add(13)
myList:Add(43)
boolean removed = myList:Remove(43)

RemoveAll(Type value)

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

Parameters

Return

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

Example

use Libraries.Containers.List
List<integer> myList
myList:Add(43)
myList:Add(13)
myList:Add(43)
boolean removed = myList:RemoveAll(43)

RemoveAt(integer location)

This action removes an item from an list and returns that item.

Parameters

  • integer location: The index or location of the item to remove.

Return

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

Example

use Libraries.Containers.List
List<integer> myList
myList:Add(43)
myList:Add(13)
myList:Add(43)
integer value = myList:RemoveAt(0)

RemoveFromEnd()

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

Return

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

Example

use Libraries.Containers.List
List<integer> myList
myList:Add(33)
myList:Add(13)
myList:Add(43)
integer removed = myList:RemoveFromEnd()

RemoveFromFront()

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

Return

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

Example

use Libraries.Containers.List
List<integer> myList
myList:Add(33)
myList:Add(13)
myList:Add(43)
integer removed = myList:RemoveFromFront()

Set(integer location, Type value)

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

Parameters

  • integer location: The index or location the value will be stored at.
  • Libraries.Language.Object: The item to be added to the list.

Example

use Libraries.Containers.List
List<integer> myList
myList:Add(43)
myList:Add(13)
myList:Add(43)
myList:Set(22, 2)

Sort()

This action sorts the values of the array. The example below sorts an array. Implementors may use any known sorting algorithm. Objects that should be sorted in a custom fashion should override the default Compare action in Libraries.Language.Object.

Example

use Libraries.Containers.List
List<integer> myList
myList:Add(33)
myList:Add(13)
myList:Add(43)
myList:Sort()