bit_sort | R Documentation |
fast sorting of integers
bit_sort(x, decreasing = FALSE, na.last = NA, has.dup = TRUE)
x |
an integer vector |
decreasing |
(currently only |
na.last |
|
has.dup |
TRUE (the default) assumes that |
determines the range of the integers and checks if the density justifies use of a bit vector; if yes, sorts the first occurences of each integer in the range using a bit vector, sorts the rest and merges; if no, falls back to quicksort.
a sorted vector
sort
, ramsort
,
bit_sort_unique
bit_sort(c(2L,1L,NA,NA,1L,2L))
bit_sort(c(2L,1L,NA,NA,1L,2L), na.last=FALSE)
bit_sort(c(2L,1L,NA,NA,1L,2L), na.last=TRUE)
## Not run:
x <- sample(1e7, replace=TRUE)
system.time(bit_sort(x))
system.time(sort(x))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.