FastSelect class
一种快速的选择算法,来源于快速排序
重要:该方法会改变List中元素索引和位置
移植自 https://github.com/mourner/quickselect
重新排列项目,使List中的所有在left, k
的数据都是最小的。第K个元素的索引为left, right
中的 (k - left + 1)
array :要部分排序的数组(就地)
k :用于部分排序的中间索引(如上定义)
left :要排序的范围的左索引(默认 0 )
right :右索引(默认情况下是数组的最后一个索引)
compareFn :比较函数
example
var arr = 65, 28, 59, 33, 21, 56, 22, 95, 50, 12, 90, 53, 28, 77, 39
;
quickselect(arr, 8);
arr is 39, 28, 28, 33, 21, 12, 22, 50, 53, 56, 59, 65, 90, 77, 95
^^ middle index
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited