Class: ShellSortArray

sort/comparative/shell. ShellSortArray

Uses the Tokuda gap sequence by default.


new ShellSortArray( [interrupt] [, compare] [, sequence])

Parameters:
Name Type Argument Default Description
interrupt module:sort/virtual.interruptCallback <optional>
compare module:sort/virtual.compareCallback <optional>
sequence iterable | module:sort/virtual.sequenceCallback <optional>
ShellSortArray.tokuda

If an iterable is passed, it is converted to a sequenceCallback.

See:
Throws:

sequence must be iterable or function.

Type
TypeError

Extends

Methods


<generator, static> sequence(length, gaps)

Generates an ordered gap sequence sufficient for given length.

Parameters:
Name Type Description
length number
gaps module:sort/virtual.sequenceCallback

<static> tokuda(index)

Parameters:
Name Type Description
index number
Returns:
Type
number

<generator> compare(i, j [, a] [, b])

A method to interruptably compare two elements in the array. a and b are optional, since i and j can sometimes be used to represent indices that are virtual in the comparsion.

Parameters:
Name Type Argument Default Description
i number

Index of left-hand element to compare.

j number

Index of right-hand element to compare.

a * <optional>
this[i]

Value of left-hand element to compare.

b * <optional>
this[j]

Value of right-hand element to compare.

Inherited From:
Returns:

result - See compareFunction

Type
number

delete(key)

Parameters:
Name Type Description
key *

Reference key of scoped variable.

Inherited From:
Implements:
Returns:

successful - Is true if removed, false if element does not exist.

Type
boolean

<generator> fill(factory [, length])

A method to interruptably populate the array with elements generated from factory.

Parameters:
Name Type Argument Default Description
factory module:sort/virtual.fillCallback
length number <optional>
this.length
Inherited From:
Throws:

factory must be a function.

Type
TypeError

get(key)

Parameters:
Name Type Description
key *

Reference key of scoped variable.

Inherited From:
Implements:
Returns:

value - Scoped variable for the given key or undefined if none exists.

Type
*

has(key)

Parameters:
Name Type Description
key *

Reference key of scoped variable.

Inherited From:
Implements:
Returns:

exists - Instance contains a scoped variable for the given key.

Type
boolean

<generator> put(index, value)

A method to interruptably put an element in the array.

Parameters:
Name Type Description
index number

Index to put element value.

value *

Value to put in index.

Inherited From:

set(key, value)

Parameters:
Name Type Description
key *

Reference key of scoped variable.

value *

Value of scoped variable to set.

Inherited From:
Implements:
Returns:
Type
this

<generator> shuffle()

A method to interruptably randomize the order of elements in the array. Uses the Knuth Fisher Yates method.

Inherited From:

slice( [begin] [, end])

Shallow copy a portion of an array into a new array object.

Parameters:
Name Type Argument Default Description
begin number <optional>
0

First index of shallow copy.

end number <optional>
this.length

Last index of shallow copy, not included.

Inherited From:
Returns:
Type
Array

<generator> sort()

Abstract method to interruptably sort array of elements.

Inherited From:
Overrides:
Throws:

Illegal invocation.

Type
TypeError

<generator> swap(i, j)

A method to interruptably swap two elements in the array.

Parameters:
Name Type Description
i number

Index of first element to swap.

j number

Index of second element to swap.

Inherited From: