Home

CompareVector

Holds a growable array of comparable objects

Operations

New

Default constructor

New()

Copy constructor

New(values:Compare[])
Parameters
NameTypeDescription
valuesCompare[]values to copy

Copy constructor

New(values:CompareVector)
Parameters
NameTypeDescription
valuesCompareVectorvalues to copy

AddBack

Adds a vector of values to the end of the vector

method : public : AddBack(values:CompareVector) ~ Nil
Parameters
NameTypeDescription
valuesCompareVectorvalues to append

Adds a value to the end

method : public : AddBack(value:Compare) ~ Nil
Parameters
NameTypeDescription
valueComparevalue to append

BinarySearch

Performs a binary search O(log n)

method : public : native : BinarySearch(value:Compare) ~ Int
Parameters
NameTypeDescription
valueComparevalue to search for

Return
TypeDescription
Intindex of found value, -1 if not found

Empty

Clears the vector

method : public : Empty() ~ Nil

Filter

Uses the given function to filter out values

method : public : Filter(f:(Compare)~Bool) ~ CompareVector
Parameters
NameTypeDescription
f(Compare)~Boolfunction to use a filter. If the function evaluates to true the value is added to the collection.

Return
TypeDescription
CompareVectorfilter vector

Find

Finds a given value in the vector via linear search

method : public : native : Find(value:Compare) ~ Int
Parameters
NameTypeDescription
valueComparevalue to search for

Return
TypeDescription
Intindex of found value, -1 if not found

Get

Gets an indexed value

method : public : Get(index:Int) ~ Compare
Parameters
NameTypeDescription
indexIntindex

Return
TypeDescription
Comparevalue

Has

Check of the given value is in the vector

method : public : Has(value:Compare) ~ Bool
Parameters
NameTypeDescription
valueComparevalue to check for

Return
TypeDescription
Booltrue if found, false otherwise

IsEmpty

Checks to see if the vector is empty

method : public : IsEmpty() ~ Bool
Return
TypeDescription
Booltrue if empty, false otherwise

Remove

Removes an indexed value

method : public : Remove(i:Int) ~ Compare
Parameters
NameTypeDescription
iIntindex

Return
TypeDescription
Comparevalue

RemoveBack

Removes the last value

method : public : RemoveBack() ~ Compare
Return
TypeDescription
Comparevalue

Set

Sets an indexed value

method : public : Set(value:Compare, index:Int) ~ Bool
Parameters
NameTypeDescription
valueComparevalue
indexIntindex

Size

Size of vector

method : public : Size() ~ Int
Return
TypeDescription
Intsize of vector

Sort

Sorts the values in the vector

method : public : native : Sort() ~ Nil

Swap

Swap two values in the vector

method : public : native : Swap(a:Int, b:Int) ~ Bool
Parameters
NameTypeDescription
aIntfirst value
bIntsecond value

Return
TypeDescription
Booltrue if values were swapped

ToArray

Converts the vector into an object array

method : public : native : ToArray() ~ Compare[]
Return
TypeDescription
Compare[]object array