OrderedComparator<T, U> Type alias

A function that returns a numerical value indicating how two objects are ordered in relation to one another. Such functions are used by various collection classes in the iModel.js library. Given values lhs and rhs, the function returns:

  • Zero if lhs == rhs
  • A negative number if lhs < rhs
  • A positive number if lhs > rhs

An OrderedComparator must implement strict weak ordering, which can be summarized by the following rules:

  • compare(x, x) returns zero.
  • If compare(x, y) returns zero, then so does compare(y, x) (i.e., x == y implies y == x).
  • If compare(x, y) returns non-zero, then compare(y, x) returns a value with an opposite sign (i.e., x < y implies y > x).
  • If compare(x, y) and compare(y, z) return non-zero values with the same sign, then compare(x, z) returns a value with the same sign (i.e., x < y < z implies x < z).

see SortedArray

see Dictionary

see IndexMap

see PriorityQueue

OrderedComparator = (lhs: T, rhs: U) => number

Defined in

Last Updated: 01 December, 2021