### Comparing, ordering, and tabulating vector-like objects
### Funcions/operators for comparing, ordering, tabulating:
### Element-wise (aka "parallel") comparison of 2 Vector objects.
### The methods below are implemented on top of compare().
### The methods below are implemented on top of == and <=.
### The default "selfmatch" method below is implemented on top of match().
### Default "selfmatch" method. Args in ... are propagated to match().
### The "duplicated" method below is implemented on top of selfmatch().
### The "unique" method below is implemented on top of duplicated().
"the \"duplicated\" method for Vector objects "
### The method below is implemented on top of match().
### The default "findMatches" and "countMatches" methods below are
### Equivalent to 'countQueryHits(findMatches(x, table))' but the default
### "countMatches" method below has a more efficient implementation.
### Problem: using transpose=TRUE generates an invalid Hits object (hits are
###   > IRanges:::.findAllMatchesInSmallTable(1:6, c(7:5, 4:5), transpose=TRUE)
### and the cost of ordering them would probably defeat the purpose of the
### "put the smallest object on the right" optimization trick.
### Default "findMatches" method. Args in ... are propagated to match() and
"'select' is not supported yet. Note that you can use "
"match() if you want to do 'select=\"first\"'. Otherwise "
"you're welcome to request this on the Bioconductor "
## "put the smallest object on the right" optimization trick
#    return(.findAllMatchesInSmallTable(table, x, ..., transpose=TRUE))
### Default "countMatches" method. Args in ... are propagated to match() and
### The method below is implemented on top of order().
### The method below is implemented on top of selfmatch(), order(), and
### This is a copy/paste of the list.names() function locally defined inside

function(e1, e2) { compare(e1, e2) == 0L }
function(e1, e2) { compare(e1, e2) <= 0L }
setMethods("!=", .OP2_SIGNATURES, function(e1, e2) { !(e1 == e2) })
setMethods(">=", .OP2_SIGNATURES, function(e1, e2) { e2 <= e1 })
setMethods("<", .OP2_SIGNATURES, function(e1, e2) { !(e2 <= e1) })
setMethods(">", .OP2_SIGNATURES, function(e1, e2) { !(e1 <= e2) })
setMethod("selfmatch", "ANY", function(x, ...) match(x, x, ...))
duplicated.Vector <- function(x, incomparables=FALSE, ...)
stop("the \"duplicated\" method for Vector objects ",
xx <- do.call(selfmatch, c(list(x), args))
unique.Vector <- function(x, incomparables=FALSE, ...)
i <- !duplicated(x, incomparables=incomparables, ...)
function(x, table) { !is.na(match(x, table)) }
function(x, table, select=c("all", "first", "last"), ...)
.findAllMatchesInSmallTable <- function(x, table, ..., transpose=FALSE)
stop("'select' is not supported yet. Note that you can use ",
"match() if you want to do 'select=\"first\"'. Otherwise ",
"you're welcome to request this on the Bioconductor ",
.countMatches.default <- function(x, table, ...)
table2 <- match(table, x, ...)  # can contain NAs
table2 <- selfmatch(table, ...)  # no NAs
x2 <- match(x, table, nomatch=nbins, ...)
.sort.Vector <- function(x, decreasing=FALSE, na.last=NA)
i <- order(x, na.last=na.last, decreasing=decreasing)
sort.Vector <- function(x, decreasing=FALSE, ...)
stop("\"table\" method for Vector objects ",