BinarySearch

mdoc.internal.pos.BinarySearch
object BinarySearch

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Type members

Classlikes

sealed trait ComparisonResult

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Equal.type
object Greater.type
object Smaller.type
case object Equal extends ComparisonResult

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Self type
Equal.type
case object Greater extends ComparisonResult

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Self type
Greater.type
case object Smaller extends ComparisonResult

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Self type
Smaller.type

Value members

Concrete methods

def array[T](array: Array[T], compare: T => ComparisonResult): Option[T]

Binary search using a custom compare function.

Binary search using a custom compare function.

scala.util.Searching does not support the ability to search an IndexedSeq by a custom mapping function, you must search by an element of the same type as the elements of the Seq.

Value parameters

array

Must be sorted according to compare function so that for all i > j, compare(array(i), array(i)) == Greater.

compare

Callback used at every guess index to determine whether the search element has been found, or whether to search above or below the guess index.

Attributes

Returns

The first element where compare(element) == Equal. There is no guarantee which element is chosen if many elements return Equal.