Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "_shared/comparer"

Index

Interfaces

Type aliases

Functions

Object literals

Type aliases

CompareFunction

CompareFunction<T>: (a: T, b: T) => -1 | 0 | 1

A function that compares two elements a and b of the same type. It can be applied to any data type, including arrays or objects. It should return -1 if a considered inferior to b, 1 if superior, and zero if considered equals.

Type parameters

  • T

Type declaration

    • (a: T, b: T): -1 | 0 | 1
    • Parameters

      • a: T
      • b: T

      Returns -1 | 0 | 1

Functions

compare

  • compare<T>(a: T, b: T): -1 | 0 | 1
  • The function used to compare two elements in an ordered data structure. By default, it compares numbers so it must be replaced with a custom function (via setCompareFunction) when storing another data type.

    Type parameters

    • T

    Parameters

    • a: T

      Element a

    • b: T

      Element b

    Returns -1 | 0 | 1

    -1 if a < b, 1 if a > b, 0 if a === b

equal

  • equal<T>(this: any, a: T, b: T): boolean
  • Returns true if a and b are equal, false otherwise.

    Type parameters

    • T

    Parameters

    • this: any
    • a: T

      Element a

    • b: T

      Element b

    Returns boolean

    true / false

inf

  • inf<T>(this: any, a: T, b: T): boolean
  • Returns true if a is inferior to b, false otherwise.

    Type parameters

    • T

    Parameters

    • this: any
    • a: T

      Element a

    • b: T

      Element b

    Returns boolean

    true / false

infOrEqual

  • infOrEqual<T>(this: any, a: T, b: T): boolean
  • Returns true if a is inferior or equal to b, false otherwise.

    Type parameters

    • T

    Parameters

    • this: any
    • a: T

      Element a

    • b: T

      Element b

    Returns boolean

    true / false

sup

  • sup<T>(this: any, a: T, b: T): boolean
  • Returns true if a is superior to b, false otherwise.

    Type parameters

    • T

    Parameters

    • this: any
    • a: T

      Element a

    • b: T

      Element b

    Returns boolean

    true / false

supOrEqual

  • supOrEqual<T>(this: any, a: T, b: T): boolean
  • Returns true if a is superior or equal to b, false otherwise.

    Type parameters

    • T

    Parameters

    • this: any
    • a: T

      Element a

    • b: T

      Element b

    Returns boolean

    true / false

Object literals

Const compareMethods

compareMethods: object

compare

compare: compare

equal

equal: equal

inf

inf: inf

infOrEqual

infOrEqual: infOrEqual

sup

sup: sup

supOrEqual

supOrEqual: supOrEqual

Generated using TypeDoc