Libraries.Containers.Support.SortableContainer Documentation

The SortableContainer class represents a container with a specified value used for comparisons and sorting.

Example Code

use Libraries.Game.SortableContainer
use Libraries.Containers.Array

Array<SortableContainer<integer, text>> array
SortableContainer<integer, text> container1
SortableContainer<integer, text> container2
container1:Set(2, "The second value")
container2:Set(1, "The first value")
array:Add(container1)
array:Add(container2)
array:Sort()

Inherits from: Libraries.Language.Object

Actions Documentation

Compare(Libraries.Language.Object object)

The Compare action will return an integer. If the given parameter is a SortableContainer, the result will indicate whether the sorter value of the container was smaller, equal, or larger than the sorter value of this SortableContainer. If the object isn't a SortableContainer, the integer will instead be the comparison of the hash values of the two objects.

Parameters

Return

integer:

Example

use Libraries.Game.SortableContainer

SortableContainer<integer, text> container1
SortableContainer<integer, text> container2
container1:Set(2, "The second value")
container2:Set(1, "The first value")
integer result = container1:Compare(container2) //1 (larger), 0 (equal), or -1 (smaller)

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)

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

GetSorter()

This action returns the sorting value of the SortableContainer.

Return

Libraries.Language.Object:

Example

use Libraries.Game.SortableContainer

SortableContainer<integer, text> container
container:Set(1)
integer sort = container:GetSorter()

GetValue()

This action returns the contained value of the SortableContainer.

Return

Libraries.Language.Object:

Example

use Libraries.Game.SortableContainer

SortableContainer<integer, text> container
container:SetValue("Some text to be stored")
text result = container:GetValue()

Set(Type1 s, Type2 v)

This action sets the sorting value and the contained value, respectively, of the SortableContainer.

Parameters

Example

use Libraries.Game.SortableContainer

SortableContainer<integer, text> container
container:Set(1, "Some text to be stored")

SetSorter(Type1 s)

This action sets the sorting value of the SortableContainer.

Parameters

Example

use Libraries.Game.SortableContainer

SortableContainer<integer, text> container
container:SetSorter(1)

SetValue(Type2 v)

This action sets the contained value of the SortableContainer.

Parameters

Example

use Libraries.Game.SortableContainer

SortableContainer<integer, text> container
container:SetValue("Some text to be stored")