array

Generated by tinox doc

Utility functions for List<Int64> arrays: search (contains/indexOf), aggregation (min/max/sum/average), transformation (reverse/filterPositive/bubbleSort), and generation (range/fill).

Basic operations

import tinox.core.array;

class Main
{
    fnc main() -> Int32
    {
        let numbers: List<Int64> = Arrays::range(1, 6);
        println("sum: " + Arrays::sum(numbers).toString());
        println("max: " + Arrays::findMax(numbers).toString());
        println("sorted: " + Arrays::isSorted(numbers).toString());

        let sorted: List<Int64> = Arrays::bubbleSort([5, 3, 1, 4, 2]);
        println("contains 4: " + Arrays::containsInt(sorted, 4).toString());
        return 0;
    }
}

class Arrays

* Arrays utility class providing operations on List<Int64> * including searching, transforming, sorting, and generating ranges

Methods

fn containsInt(arr: List<Int64>, value: Int64) → Bool
* Checks if the array contains the given value * @param arr the array to search * @param value the value to look for * @return true if value is found in arr
fn indexOfInt(arr: List<Int64>, value: Int64) → Int64
* Finds the index of the first occurrence of value * @param arr the array to search * @param value the value to look for * @return the index of value, or -1 if not found
fn findMin(arr: List<Int64>) → Int64
* Finds the minimum value in the array * @param arr the array to search (must not be empty) * @return the smallest element in arr
fn findMax(arr: List<Int64>) → Int64
* Finds the maximum value in the array * @param arr the array to search (must not be empty) * @return the largest element in arr
fn sum(arr: List<Int64>) → Int64
* Calculates the sum of all elements * @param arr the array of integers * @return the sum of all elements
fn average(arr: List<Int64>) → Int64
* Calculates the integer average of all elements * @param arr the array of integers (must not be empty) * @return the average (sum / length), truncated to integer
fn reverseInt(arr: List<Int64>) → List<Int64>
* Returns a new array with elements in reverse order * @param arr the input array * @return a new array with elements reversed
fn filterPositive(arr: List<Int64>) → List<Int64>
* Returns a new array containing only positive values * @param arr the input array * @return a new array with only elements > 0
fn bubbleSort(arr: List<Int64>) → List<Int64>
* Sorts the array using bubble sort algorithm * @param arr the array to sort * @return a new sorted array in ascending order
fn isSorted(arr: List<Int64>) → Bool
* Checks if the array is sorted in ascending order * @param arr the array to check * @return true if elements are in non-decreasing order
fn range(start: Int64, end: Int64) → List<Int64>
* Generates a range of integers from start to end (exclusive) * @param start the starting value (inclusive) * @param end the ending value (exclusive) * @return a list containing start, start+1, ..., end-1
fn fill(value: Int64, count: Int64) → List<Int64>
* Creates an array filled with the same value * @param value the value to fill with * @param count the number of elements (must be non-negative) * @return a list containing count copies of value