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 an integer.
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 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.

Example Code

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

Parameters

Return

integer:

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(

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(

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