### Method signatures for binary comparison operators.
### By default, List objects compare recursively. Exceptions to the rule
### (e.g. Ranges, XString, etc...) must define a "compareRecursively" method
### .op1_apply() and .op2_apply() internal helpers
## 'ans' is guaranteed to have the length of 'x' or 'y'.
### Element-wise (aka "parallel") comparison of 2 List objects.
### TODO: Add fast "==" and "<=" methods for CompressedList objects.
### The remaining comparison binary operators (!=, >=, <, >) will work
### out-of-the-box on List objects thanks to the "!" methods below and to the
### 2 of the 3 "match" methods defined above have signatures List,list and
### List,List and therefore are more specific than the 2 methods below.
### So in the methods below 'table' is guaranteed to be a vector that is not
### a list or a Vector that is not a List.
### S3/S4 combo for duplicated.CompressedList
"\"duplicated\" method for CompressedList objects "
"does not support the 'incomparables' argument"
### S3/S4 combo for unique.CompressedList
"\"unique\" method for CompressedList objects "
### %in% will work out-of-the-box on List objects thanks to the "is.na"
### methods below and to the method for Vector objects.

.op1_apply <- function(OP1, x, ..., ANS_CONSTRUCTOR)
.op2_apply <- function(OP2, x, y, ..., ANS_CONSTRUCTOR)
OP2_Vector_method <- selectMethod(OP2, c("Vector", "Vector"))
compress_ans <- !((is(x, "SimpleList") || is.list(x)) &&
ans <- ANS_CONSTRUCTOR(mapply(OP2, x, y, MoreArgs=list(...),
if (!(is.null(x_names) && is.null(y_names))) {
function(x, y) .op2_apply(compare, x, y, ANS_CONSTRUCTOR=IntegerList)
function(e1, e2) .op2_apply(`==`, e1, e2, ANS_CONSTRUCTOR=LogicalList)
function(e1, e2) .op2_apply(`<=`, e1, e2, ANS_CONSTRUCTOR=LogicalList)
function(x, table, nomatch=NA_integer_, incomparables=NULL, ...)
setMethods("match", list(c("List", "vector"), c("List", "Vector")),
stop("\"duplicated\" method for CompressedList objects ",
"does not support the 'incomparables' argument")
sm <- match(x_unlistData, x_unlistData)  # doesn't work on an Rle
ans_unlistData <- duplicatedIntegerPairs(x_group, sm, fromLast=fromLast)
unique.List <- function(x, incomparables=FALSE, ...)
i <- !duplicated(x, incomparables=incomparables, ...)  # LogicalList
stop("\"unique\" method for CompressedList objects ",
is_dup <- duplicated(x, incomparables=incomparables, fromLast=fromLast)
unique.CompressedList <- function(x, incomparables=FALSE, ...)
stop("\"order\" method for List objects ",
.sort.List <- function(x, decreasing=FALSE, na.last=NA)
i <- order(x, na.last=na.last, decreasing=decreasing)  # IntegerList
sort.List <- function(x, decreasing=FALSE, ...)
ties.method=c("average", "first", "random", "max", "min"))