File: bit_sort.Rd

package info (click to toggle)
r-cran-bit 4.0.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 996 kB
  • sloc: ansic: 5,083; makefile: 6
file content (45 lines) | stat: -rw-r--r-- 1,188 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bitsort.R
\name{bit_sort}
\alias{bit_sort}
\title{bit sort}
\usage{
bit_sort(x, decreasing = FALSE, na.last = NA, has.dup = TRUE)
}
\arguments{
\item{x}{an integer vector}

\item{decreasing}{(currently only \code{FALSE} is supported)}

\item{na.last}{\code{NA} removes NAs, \code{FALSE} puts NAs at the beginning,
\code{TRUE} puts NAs at the end}

\item{has.dup}{TRUE (the default) assumes that \code{x} might have 
duplicates, set to \code{FALSE} if duplicates are impossible}
}
\value{
a sorted vector
}
\description{
fast sorting of integers
}
\details{
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.
}
\examples{
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)

\dontrun{
x <- sample(1e7, replace=TRUE)
system.time(bit_sort(x))
system.time(sort(x))
}
}
\seealso{
\code{\link{sort}}, \code{\link{ramsort}}, 
  \code{\link{bit_sort_unique}}
}