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

Summary

Actions Summary Table

ActionsDescription
Compare(Libraries.Language.Object object)The Compare action will return a CompareResult.
Equals(Libraries.Language.Object object)This action determines if two objects are equal based on their hash code values.
GetHashCode()This action gets the hash code for an object.
GetSorter()This action returns the sorting value of the SortableContainer.
GetValue()This action returns the contained value of the SortableContainer.
Set(Type1 s, Type2 v)This action sets the sorting value and the contained value, respectively, of the SortableContainer.
SetSorter(Type1 s)This action sets the sorting value of the SortableContainer.
SetValue(Type2 v)This action sets the contained value of the SortableContainer.

Actions Documentation

Compare(Libraries.Language.Object object)

The Compare action will return a CompareResult. 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 CompareResult will instead be the comparison of the hash values of the two objects.

Example Code

use Libraries.Game.SortableContainer
        use Libraries.Language.Support.CompareResult

        SortableContainer<integer, text> container1
        SortableContainer<integer, text> container2
        container1:Set(2, "The second value")
        container2:Set(1, "The first value")
        CompareResult result = container1:Compare(container2)

Parameters

Return

Libraries.Language.Support.CompareResult:

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.

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.

GetSorter()

This action returns the sorting value of the SortableContainer.

Example Code

use Libraries.Game.SortableContainer

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

Return

Libraries.Language.Object:

GetValue()

This action returns the contained value of the SortableContainer.

Example Code

use Libraries.Game.SortableContainer

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

Return

Libraries.Language.Object:

Set(Type1 s, Type2 v)

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

Example Code

use Libraries.Game.SortableContainer

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

Parameters

SetSorter(Type1 s)

This action sets the sorting value of the SortableContainer.

Example Code

use Libraries.Game.SortableContainer

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

Parameters

SetValue(Type2 v)

This action sets the contained value of the SortableContainer.

Example Code

use Libraries.Game.SortableContainer

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

Parameters