API Docs for: 1.0.0
Show:

Array~algorithms Class

Useful algorithms not provided by browsers.

Item Index

Methods

binarySearch

(
  • list
  • target
  • [compare=Y.Array.compareStringsCaseSensitive]
)
Int static

Binary search.

Parameters:

  • list Array

    the list to search (sorted on the compare function)

  • target Mixed

    the object to search for

  • [compare=Y.Array.compareStringsCaseSensitive] Function optional

    the comparison function

Returns:

Int:

index of matched item or -1 if no match

compareStringsCaseInsensitive

(
  • s1
  • s2
)
static

A -1,0,+1 comparator for case-insensitive string comparison.

Parameters:

  • s1 String

    first string

  • s2 String

    second string

Returns:

-1 if s1<s2, 0 if s1==s2, +1 if s1>s2

compareStringsCaseSensitive

(
  • s1
  • s2
)
static

A -1,0,+1 comparator for case-sensitive string comparison.

Parameters:

  • s1 String

    first string

  • s2 String

    second string

Returns:

-1 if s1<s2, 0 if s1==s2, +1 if s1>s2

quickSort

(
  • list
  • compare=Y.Array.compareStringsCaseSensitive
)
static

Quick sort the given list.

Parameters:

  • list Array

    the list to search (sorted on the compare function)

  • compare=Y.Array.compareStringsCaseSensitive Function

    the comparison function

swap

(
  • list
  • i
  • j
)
static

Swaps two elements.

Parameters:

  • list Array

    the list on which to operate

  • i Int

    first index

  • j Int

    second index