]> Cypherpunks repositories - gostls13.git/commit
adopt suggestions from Bentley and McIlroy (SP&E Nov 1993)
authorRuss Cox <rsc@golang.org>
Mon, 17 Nov 2008 19:51:34 +0000 (11:51 -0800)
committerRuss Cox <rsc@golang.org>
Mon, 17 Nov 2008 19:51:34 +0000 (11:51 -0800)
commit5aa7dc5daf821d1bdacde2fe23523a5406c70e8e
tree938b4c7405fb38d37cffc55c12d1aa8b5a9375f7
parenta1c85ed83ef0c9e11374caf14ec7aff6b716329d
adopt suggestions from Bentley and McIlroy (SP&E Nov 1993)
to make qsort more robust:

* use "ninther" to choose pivot.
* use three-way partition to avoid quadratic
    behavior on all-one-value arrays.

also add tests suggested in that paper.

the immediate cause of the slowness we observed was
in fact none of these: the recursive call was sorting
data[0:m] instead of data[a:m].

also rename package to "sort" to match convention.

R=r,gri
DELTA=358  (255 added, 21 deleted, 82 changed)
OCL=19341
CL=19373
src/lib/sort.go
test/sorting.go