Array~algorithms Class
Useful algorithms not provided by browsers.
Item Index
Methods
- binarySearch static
- compareStringsCaseInsensitive static
- compareStringsCaseSensitive static
- quickSort static
- swap static
Methods
binarySearch
(
Int
static
-
list -
target -
[compare=Y.Array.compareStringsCaseSensitive]
Binary search.
Parameters:
-
listArraythe list to search (sorted on the compare function)
-
targetMixedthe object to search for
-
[compare=Y.Array.compareStringsCaseSensitive]Function optionalthe comparison function
Returns:
Int:
index of matched item or -1 if no match
compareStringsCaseInsensitive
(
static
-
s1 -
s2
A -1,0,+1 comparator for case-insensitive string comparison.
Parameters:
-
s1Stringfirst string
-
s2Stringsecond string
Returns:
-1 if s1<s2, 0 if s1==s2, +1 if s1>s2
compareStringsCaseSensitive
(
static
-
s1 -
s2
A -1,0,+1 comparator for case-sensitive string comparison.
Parameters:
-
s1Stringfirst string
-
s2Stringsecond string
Returns:
-1 if s1<s2, 0 if s1==s2, +1 if s1>s2
quickSort
(
static
-
list -
compare=Y.Array.compareStringsCaseSensitive
Quick sort the given list.
Parameters:
-
listArraythe list to search (sorted on the compare function)
-
compare=Y.Array.compareStringsCaseSensitiveFunctionthe comparison function
swap
(
static
-
list -
i -
j
Swaps two elements.
Parameters:
-
listArraythe list on which to operate
-
iIntfirst index
-
jIntsecond index
