successiveIRanges <- function(width, gapwidth=0, from=1)
stop("'width' must be an integer vector")
width <- as.integer(width)  # this drops the names
names(width) <- NULL  # unname() used to be broken on 0-length vectors
stop("'width' cannot contain NAs or negative values")
stop("'gapwidth' must be an integer vector")
if (length(gapwidth) != length(width) - 1L) {
stop("'gapwidth' must a single integer or an integer vector ",
"with one less element than the 'width' vector")
gapwidth <- rep.int(gapwidth, length(width) - 1L)
ans_start <- cumsum(width[-length(width)] + gapwidth)
stop("'totalsize' must be a single integer")
stop("'totalsize' must be a non-negative integer")
stop("'chunksize' must be a single integer")
stop("'chunksize' must be a positive integer")
stop("'center' must be a numeric vector")
stop("'flank' must be a numeric vector")
.asNormalIRanges <- function(from) asNormalIRanges(from, force=TRUE)

### There are many ways to implement the "isConstant" method for integer
###   isConstant1 <- function(x) {length(x) <= 1L || all(x == x[1L])}
###   isConstant2 <- function(x) {length(unique(x)) <= 1L}
###   isConstant3 <- function(x) {length(x) <= 1L || all(duplicated(x)[-1L])}
###   isConstant4 <- function(x) {length(x) <= 1L ||
###                               sum(duplicated(x)) == length(x) - 1L}
###   isConstant5 <- function(x) {length(x) <= 1L || min(x) == max(x)}
###   isConstant6 <- function(x) {length(x) <= 1L ||
### Which one is faster is hard to guess. It happens to be isConstant5():
### it's 2.7x faster than isConstant1(), 6x faster than isConstant2(), 11x
### faster than isConstant3(), 5.2x faster than isConstant4() and 1.6x faster
### Results obtained on 'x0 <- rep.int(112L, 999999L)' with R-2.13 Under
### For this method we use a modified version of isConstant5() above that
## From here 'x' is guaranteed to have a length >= 2 and to contain
## 'min(x, na.rm=TRUE)' issues a warning if 'x' contains only NAs.
## In that case, and in that case only, it returns Inf.
## From here 'x' is guaranteed to contain a mix of NAs and non-NAs.
### Like the method for integer vectors this method also uses a comparison
### between min(x) and max(x). In addition it needs to handle rounding errors
### and special values: NA, NaN, Inf and -Inf.
### Using all.equal() ensures that TRUE is returned on c(11/3, 2/3+4/3+5/3).
# success means 'x' contains no NAs and no NaNs
## 'min(x, na.rm=TRUE)' issues a warning if 'x' contains only NAs
## Only possible values in 'x' are NAs, NaNs or Infs.
## From here 'x' is guaranteed to contain at least one value that is
## Only possible values in 'x' are NAs, NaNs or -Infs.