Module std::vec

Vec utility functions.

Pure Hew implementations for common vector operations. These replace the equivalent Rust FFI functions for simple linear scans.

Contents

Functions

Function contains_i32

pub fn contains_i32(v: Vec<i32>, val: i32) -> bool

Check if a Vec<i32> contains val. Returns true if found.

Function contains_i64

pub fn contains_i64(v: Vec<i64>, val: i64) -> bool

Check if a Vec<i64> contains val.

Function contains_f64

pub fn contains_f64(v: Vec<f64>, val: f64) -> bool

Check if a Vec<f64> contains val. Uses exact equality.

Examples

let v: Vec<f64> = Vec::new();
v.push(3.14);
println(vec.contains_f64(v, 3.14));  // true
println(vec.contains_f64(v, 0.0));   // false

Function contains_str

pub fn contains_str(v: Vec<string>, val: string) -> bool

Check if a Vec<string> contains val. Uses string equality.

Examples

let v: Vec<string> = Vec::new();
v.push("hello");
println(vec.contains_str(v, "hello"));  // true
println(vec.contains_str(v, "world"));  // false

Function index_of_i32

pub fn index_of_i32(v: Vec<i32>, val: i32) -> i64

Return the index of val in a Vec<i32>, or -1 if not found.

Function index_of_i64

pub fn index_of_i64(v: Vec<i64>, val: i64) -> i64

Return the index of val in a Vec<i64>, or -1 if not found.

Function index_of_f64

pub fn index_of_f64(v: Vec<f64>, val: f64) -> i64

Return the index of the first occurrence of val in v, or -1 if not found. Uses exact equality; NaN will never match.

Examples

let v: Vec<f64> = Vec::new();
v.push(1.5);
v.push(2.5);
println(vec.index_of_f64(v, 2.5));  // 1
println(vec.index_of_f64(v, 9.9));  // -1

Function index_of_str

pub fn index_of_str(v: Vec<string>, val: string) -> i64

Return the index of the first occurrence of val in v, or -1 if not found.

Examples

let v: Vec<string> = Vec::new();
v.push("a");
v.push("b");
println(vec.index_of_str(v, "b"));   // 1
println(vec.index_of_str(v, "z"));   // -1

Function first_i64

pub fn first_i64(v: Vec<i64>) -> Option<i64>

Return Some of the first element of a Vec<i64>, or None if empty.

Function first_f64

pub fn first_f64(v: Vec<f64>) -> Option<f64>

Return Some of the first element of v, or None if v is empty.

Function first_str

pub fn first_str(v: Vec<string>) -> Option<string>

Return Some of the first element of v, or None if v is empty.

Function last_i64

pub fn last_i64(v: Vec<i64>) -> Option<i64>

Return Some of the last element of a Vec<i64>, or None if empty.

Function last_f64

pub fn last_f64(v: Vec<f64>) -> Option<f64>

Return Some of the last element of v, or None if v is empty.

Function last_str

pub fn last_str(v: Vec<string>) -> Option<string>

Return Some of the last element of v, or None if v is empty.

Function min_i32

pub fn min_i32(v: Vec<i32>) -> Option<i64>

Return Some of the smallest element in a Vec<i32>, or None if empty.

Function min_i64

pub fn min_i64(v: Vec<i64>) -> Option<i64>

Return Some of the smallest element in a Vec<i64>, or None if empty.

Function min_f64

pub fn min_f64(v: Vec<f64>) -> Option<f64>

Return Some of the smallest element in v, or None if v is empty. NaN propagates: if any element is NaN the result is unspecified.

Function max_i32

pub fn max_i32(v: Vec<i32>) -> Option<i64>

Return Some of the largest element in a Vec<i32>, or None if empty.

Function max_i64

pub fn max_i64(v: Vec<i64>) -> Option<i64>

Return Some of the largest element in a Vec<i64>, or None if empty.

Function max_f64

pub fn max_f64(v: Vec<f64>) -> Option<f64>

Return Some of the largest element in v, or None if v is empty. NaN propagates: if any element is NaN the result is unspecified.