core
core copied to clipboard
[Consistency Review] APIs around `find`
Currently, the functions related to find has different naming conventions and different semantics.
Operation that find the index using a given predicate
-
fn Array::search_by[T](self : Array[T], f : (T) -> Bool) -> Int? -
fn Array::binary_search_by[T](self : Array[T], cmp : (T) -> Int) -> Result[Int, Int] -
fn String::find_by(self : String, pred : (Char) -> Bool) -> Int? -
fn View::find_by(self : View, pred : (Char) -> Bool) -> Int? -
fn find[A](self : T[A], f : (A) -> Bool) -> A?// @immut/list -
fn findi[A](self : T[A], f : (A, Int) -> Bool) -> A?//@immut/list
Operation that find the index using a given value
-
fn Array::search[T : Eq](self : Array[T], value : T) -> Int? -
fn Array::binary_search[T : Compare](self : Array[T], value : T) -> Result[Int, Int] -
fn FixedArray::search[T : Eq](self : FixedArray[T], value : T) -> Int? -
fn String::find(self : String, str : View) -> Int? -
fn View::find(self : View, str : View) -> Int? -
fn search[A : Eq](self : T[A], value : A) -> Int?//@deque
Operation that find the given value using a given predicate
-
fn Iter::find_first[T](self : Iter[T], f : (T) -> Bool) -> T?
Operation that find the given value using a given key
-
fn lookup[A : Eq, B](self : T[(A, B)], v : A) -> B?//@imut/list
cc @bobzhang
Additional notes:
Operation that find the given value using a given key
- op_get
- get
We align to find and find_by.
Would we introduce a new type SortedArray of Array? So that we can just use SortedArray::find and not use Array::binary_find.