3.0.0 • Published 4 months ago

quickselect v3.0.0

Weekly downloads
743,616
License
ISC
Repository
github
Last release
4 months ago

quickselect

A tiny and fast selection algorithm in JavaScript (specifically, Floyd-Rivest selection).

quickselect(array, k[, left, right, compareFn]);

Rearranges items so that all items in the [left, k] are the smallest. The k-th element will have the (k - left + 1)-th smallest value in [left, right].

  • array: the array to partially sort (in place)
  • k: middle index for partial sorting (as defined above)
  • left: left index of the range to sort (0 by default)
  • right: right index (last index of the array by default)
  • compareFn: compare function

Example:

const 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
@simosol/mapbox-gl-js-offlinebst-map-gl@mapcreator/mapbox-gl@saeon/ol-react@everything-registry/sub-chunk-2515@langge-data/mapbox-glkarn-mapkarn-mapbox-gllg-mapbox-glpbf-basic-renderp-mapbox-glpetr-maplibre-glmapglvmapbox-gl-custom-layermapbox-glmapbox-gl--custom-stretchmapbox-gl-ahtmapbox-with-shapesmapsi-glmapbox-gl-htmapbox-gl-hxmapbox-gl-tdtsdmapbox-gl-testmapbox-gl-testingmapbox-gl-tultmapbox-gl-encryptedmapbox-gl-epsg4490mapbox-gl-js-with-shapesmapbox-gl-kyemapbox-gl-mapmagicmapbox-gl-mbtilesmapbox-gl-mdorymaplibre-glmaplibre-gl-ashmaplibre-gl-reduce-functionalitiesmaplibre-gl-tdtsdmapmagic-glkt-maplibre-gl@hubmap/vitessce-image-viewer@inelo/maplibre-gl@loonride/rbush@loadmill/universal@luqh_mapbox/mapbox-gl@maptalks/vt@maptalks/vector-packer@mapcat/mapbox-gl@mapgis/mapbox-gl@mapcat/mapcat-gl@maps-gl/maps-gl@maplibre/maplibre-gl-style-spec@mapbox/mapbox-gl-style-spec@curio/mapbox-gl@hansdo/maplibre-gl@gvol-org/mapbox-gl@geomatico/mapbox-gl@geops/maplibre-gl@jingsam/mapbox-gl@koordinates/maplibre-gl@kantas/vector-js@ivelander/mapbox-gl@krisdages/mapbox-gldingi-gldmap-glcomments-mapf-mapbox-glgrid-like@openmapvn/maplibre-glrpd-mapbox-glrif-mapbox-glswsk-mapboxgltest-map-azsftwr@bewithjonam/mapbox-gl@cczbby/mapbox-gl@cczbby/maplibre-gl@bestest/math@carto/mapbox-gl@cgcs2000/mapbox-glzelibobla-vivx-mapbox-gl@ark-org/map@3drobotics/mapbox-gl@americana/maplibre-gl@autoxing/mapbox-gl@bcherny/mapbox-glvicapow-mapbox-glvizzuality-mapbox-glvnmapvwake_jsthinknetmapsucsc-xena-vivtrackasia-glvietmap-glvietmaps-glxyd-mapbox-glxtal-gl@alantgeo/mapbox-gl@appearhere/mapbox-gl@globalfishingwatch/mapbox-gl@globalfishingwatch/maplibre-gl@goongmaps/goong-js
3.0.0

4 months ago

2.0.0

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

9 years ago