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
Summary
Actions Summary Table
Actions | Description |
---|---|
Add(integer location, Type value) | This action adds a value at a location in List. |
Add(Type value) | This action adds a value at the end of the list. |
AddToEnd(Type value) | This action adds an item to the end of the list. |
AddToFront(Type value) | This action adds an item to the front of the list. |
Compare(Libraries.Language.Object object) | This action compares two object hash codes and returns an integer. |
Copy() | This action copies an object and returns the copy. |
CopyToArray() | This action copies the list to an array data structure. |
Empty() | This action empty's the list, 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 location) | This action gets the item at a given location in an List. |
GetFirstLocation(Type value) | This action gets the first occurrence of the item and returns its location. |
GetFromEnd() | This action gets the item at the end of the list(the item will remain in the list). |
GetFromFront() | This action gets the item at the front of the list(the item will remain in the list). |
GetHashCode() | This action gets the hash code for an object. |
GetIterator() | This action gets an iterator for the object and returns that iterator. |
GetLastLocation(Type value) | This action gets the last occurrence of the item and returns its location. |
GetSize() | This action retrieves the number of elements or nodes in a list. |
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 location) | This action removes an item from an list and returns that item. |
RemoveFromEnd() | This action removes the item at the end of the list. |
RemoveFromFront() | This action removes the item at the front of the list. |
Set(integer location, Type value) | This action sets the item at a given location in the list to a new item. |
Sort() | This action sorts the values of the array. |
Actions Documentation
Add(integer location, Type value)
This action adds a value at a location in List.
Example Code
use Libraries.Containers.List
List<integer> myList
myList:Add(12, 0)
Parameters
- integer location: The index or location the value will be stored at.
- Libraries.Language.Object: The item to be added to the List.
Add(Type value)
This action adds a value at the end of the list.
Example Code
use Libraries.Containers.List
List<integer> myList
myList:Add(12)
Parameters
- Libraries.Language.Object: The value to be inserted at the back or last index of the linked list.
AddToEnd(Type value)
This action adds an item to the end of the list.
Example Code
use Libraries.Containers.List
List<integer> myList
myList:AddToEnd(12)
Parameters
- Libraries.Language.Object: The item to be added to the list.
AddToFront(Type value)
This action adds an item to the front of the list.
Example Code
use Libraries.Containers.List
List<integer> myList
myList:AddToFront(12)
Parameters
- Libraries.Language.Object: The item to be added to the list.
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.
Example Code
Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)
Parameters
- Libraries.Language.Object: The object to compare to.
Return
integer: The Compare result, Smaller, Equal, or Larger.
Copy()
This action copies an object and returns the copy.
Example Code
use Libraries.Containers.List
List<integer> myList
List<integer> copyList
myList:Add(12)
Object o = myList:Copy()
copyList = cast(List<integer>, o)
Return
Libraries.Language.Object: Returns a copy of this object.
CopyToArray()
This action copies the list to an array data structure.
Example Code
use Libraries.Containers.List
List<integer> myArray
myArray:Add(33)
myArray:Add(13)
myArray:Add(43)
myArray:Sort()
Return
Libraries.Containers.Array: This returns an array of the list.
Empty()
This action empty's the list, clearing out all of the items contained within it.
Example Code
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.
Example Code
use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)
Parameters
- Libraries.Language.Object: The to be compared.
Return
boolean: True if the hash codes are equal and false if they are not equal.
Get(integer location)
This action gets the item at a given location in an List.
Example Code
use Libraries.Containers.List
List<integer> myList
myList:Add(12)
myList:Add(13)
integer value = myList:Get(0)
Parameters
- integer location: The index or location the value is located at.
Return
Libraries.Language.Object: The item at the given location.
GetFirstLocation(Type value)
This action gets the first occurrence of the item and returns its location.
Example Code
use Libraries.Containers.List
List<integer> myList
myList:Add(12)
myList:Add(13)
myList:Add(12)
integer index = myList:GetFirstLocation(12)
Parameters
- Libraries.Language.Object: The item being searched for.
Return
integer: The location of the first occurrence of the item.
GetFromEnd()
This action gets the item at the end of the list(the item will remain in the list).
Example Code
use Libraries.Containers.List
List<integer> myList
myList:Add(4)
myList:Add(13)
myList:Add(12)
integer value = myList:GetFromEnd()
Return
Libraries.Language.Object: The item at the end of the list.
GetFromFront()
This action gets the item at the front of the list(the item will remain in the list).
Example Code
use Libraries.Containers.List
List<integer> myList
myList:Add(4)
myList:Add(13)
myList:Add(12)
integer value = myList:GetFromFront()
Return
Libraries.Language.Object: The item at the front of the list.
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.
GetIterator()
This action gets an iterator for the object and returns that iterator.
Example Code
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()
Return
Libraries.Containers.Iterator: Returns the iterator for an object.
GetLastLocation(Type value)
This action gets the last occurrence of the item and returns its location.
Example Code
use Libraries.Containers.List
List<integer> myList
myList:Add(12)
myList:Add(13)
myList:Add(12)
integer index = myList:GetLastLocation(12)
Parameters
- Libraries.Language.Object: The item being searched for.
Return
integer: The location of the last occurrence of the item.
GetSize()
This action retrieves the number of elements or nodes in a list.
Example Code
use Libraries.Containers.List
List<integer> myList
myList:Add(12)
integer size = myList:GetSize()
Return
integer: Returns an integer value representing the size of the list.
Has(Type value)
This action determines if an addable object contains a certain item.
Example Code
use Libraries.Containers.List
List<integer> myList
myList:Add(12)
myList:Add(1)
boolean hasItem = myList:Has(12)
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.
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.List
List<integer> myList
if myList:IsEmpty()
output "List is empty."
end
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.List
List<integer> myList
myList:Add(43)
myList:Add(13)
myList:Add(43)
boolean removed = myList:Remove(43)
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.
RemoveAll(Type value)
This action removes all occurrences of an item from the Addable object.
Example Code
use Libraries.Containers.List
List<integer> myList
myList:Add(43)
myList:Add(13)
myList:Add(43)
boolean removed = myList:RemoveAll(43)
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.
RemoveAt(integer location)
This action removes an item from an list and returns that item.
Example Code
use Libraries.Containers.List
List<integer> myList
myList:Add(43)
myList:Add(13)
myList:Add(43)
integer value = myList:RemoveAt(0)
Parameters
- integer location: The index or location of the item to remove.
Return
Libraries.Language.Object: The item that was removed from the list.
RemoveFromEnd()
This action removes the item at the end of the list.
Example Code
use Libraries.Containers.List
List<integer> myList
myList:Add(33)
myList:Add(13)
myList:Add(43)
integer removed = myList:RemoveFromEnd()
Return
Libraries.Language.Object: The item at the end of the list.
RemoveFromFront()
This action removes the item at the front of the list.
Example Code
use Libraries.Containers.List
List<integer> myList
myList:Add(33)
myList:Add(13)
myList:Add(43)
integer removed = myList:RemoveFromFront()
Return
Libraries.Language.Object: The item at the front of the list.
Set(integer location, Type value)
This action sets the item at a given location in the list to a new item.
Example Code
use Libraries.Containers.List
List<integer> myList
myList:Add(43)
myList:Add(13)
myList:Add(43)
myList:Set(22, 2)
Parameters
- integer location: The index or location the value will be stored at.
- Libraries.Language.Object: The item to be added to the list.
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 Code
use Libraries.Containers.List
List<integer> myList
myList:Add(33)
myList:Add(13)
myList:Add(43)
myList:Sort()