Home

IntVector

Holds a growable array of integer values

Operations

New

Default constructor

New()

Copy constructor

New(values:IntVector)
Parameters
NameTypeDescription
valuesIntVectorvalues to copy

Copy constructor

New(values:Int[])
Parameters
NameTypeDescription
valuesInt[]values to copy

AddBack

Adds a vector of values to the end of the vector

method : public : AddBack(values:IntVector) ~ Nil
Parameters
NameTypeDescription
valuesIntVectorvalues to append

Adds a value to the end

method : public : AddBack(value:Int) ~ Nil
Parameters
NameTypeDescription
valueIntvalue to append

Apply

Applies the given function to each value in the vector

method : public : Apply(f:(Int)~Int) ~ IntVector
Parameters
NameTypeDescription
f(Int)~Intfunction to apply

Return
TypeDescription
IntVectornewly calculated vector

Average

Calculates the average of the values in the vector

method : public : native : Average() ~ Int
Return
TypeDescription
Intcalculated average

BinarySearch

Performs a binary search O(log n)

method : public : native : BinarySearch(value:Int) ~ Int
Parameters
NameTypeDescription
valueIntvalue 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:(Int)~Bool) ~ IntVector
Parameters
NameTypeDescription
f(Int)~Boolfunction to use a filter. If the function evaluates to true the value is added to the collection.

Return
TypeDescription
IntVectorfilter vector

Find

Finds a given value in the vector via linear search

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

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

Get

Gets an indexed value

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

Return
TypeDescription
Intvalue

Has

Check of the given value is in the vector

method : public : Has(value:Int) ~ Bool
Parameters
NameTypeDescription
valueIntvalue 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

Max

Finds the largest value in the vector

method : public : native : Max() ~ Int
Return
TypeDescription
Intlargest found value

Min

Finds the smallest value in the vector

method : public : native : Min() ~ Int
Return
TypeDescription
Intsmallest found value

Reduce

Reduces elements in the vector

method : public : Reduce(f:(Int,Int)~Int) ~ Int
Parameters
NameTypeDescription
f(Int,Int)~Intfunction to apply

Return
TypeDescription
Intreduced value

Reduces elements in the vector

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

Return
TypeDescription
Intreduced value

Remove

Removes an indexed value

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

Return
TypeDescription
Intvalue

RemoveBack

Removes the last value

method : public : RemoveBack() ~ Int
Return
TypeDescription
Intvalue

Set

Sets an indexed value

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

method : public : native : ToArray() ~ Int[]
Return
TypeDescription
Int[]integer array