Home

FloatVector

Holds a growable array of float values

Operations

New

Default constructor

New()

Copy constructor

New(values:FloatVector)
Parameters
NameTypeDescription
valuesFloatVectorvalues to copy

Copy constructor

New(values:Float[])
Parameters
NameTypeDescription
valuesFloat[]values to copy

AddBack

Adds a vector of values to the end of the vector

method : public : AddBack(values:FloatVector) ~ Nil
Parameters
NameTypeDescription
valuesFloatVectorvalues to append

Adds a value to the end

method : public : AddBack(value:Float) ~ Nil
Parameters
NameTypeDescription
valueFloatvalue to append

Apply

Applies the given function to each value in the vector

method : public : Apply(f:(Float)~Float) ~ FloatVector
Parameters
NameTypeDescription
f(Float)~Floatfunction to apply

Return
TypeDescription
FloatVectornewly calculated vector

Average

Calculates the average of the values in the vector

method : public : native : Average() ~ Float
Return
TypeDescription
Floatcalculated average

BinarySearch

Performs a binary search O(log n)

method : public : native : BinarySearch(value:Float) ~ Int
Parameters
NameTypeDescription
valueFloatvalue to search for

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

Empty

Checks to see if the vector is empty

method : public : Empty() ~ Nil
Return
TypeDescription
Niltrue if empty, false otherwise

Filter

Uses the given function to filter out values

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

Return
TypeDescription
FloatVectorfilter vector

Find

Finds a given value in the vector via linear search

method : public : native : Find(value:Float) ~ Int
Parameters
NameTypeDescription
valueFloatvalue to search for

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

Get

Gets an indexed value

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

Return
TypeDescription
Floatvalue

Has

Check of the given value is in the vector

method : public : Has(value:Float) ~ Bool
Parameters
NameTypeDescription
valueFloatvalue to check for

Return
TypeDescription
Booltrue if found, false otherwise

Max

Finds the largest value in the vector

method : public : native : Max() ~ Float
Return
TypeDescription
Floatlargest found value

Min

Finds the smallest value in the vector

method : public : native : Min() ~ Float
Return
TypeDescription
Floatsmallest found value

Reduce

Reduces elements in the vector

method : public : Reduce(f:(Float,Float)~Float) ~ Float
Parameters
NameTypeDescription
f(Float,Float)~Floatfunction to apply

Return
TypeDescription
Floatreduced value

Reduces elements in the vector

method : public : Reduce(f:(Float,Float)~Float, num:Int) ~ Float
Parameters
NameTypeDescription
f(Float,Float)~Floatfunction to apply
numIntnumber of elements to reduce

Return
TypeDescription
Floatreduced value

Remove

Removes an indexed value

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

Return
TypeDescription
Floatvalue

RemoveBack

Removes the last value

method : public : RemoveBack() ~ Float
Return
TypeDescription
Floatvalue

Set

Sets an indexed value

method : public : Set(value:Float, index:Int) ~ Bool
Parameters
NameTypeDescription
valueFloatvalue
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 float array

method : public : native : ToArray() ~ Float[]
Return
TypeDescription
Float[]float array