CompressedList-class {IRanges} | R Documentation

## CompressedList objects

### Description

Like the SimpleList class defined in the S4Vectors package, the CompressedList class extends the List virtual class.

### Details

Unlike the SimpleList class, CompressedList is virtual, that is, it cannot be instantiated. Many concrete (i.e. non-virtual) CompressedList subclasses are defined and documented in this package (e.g. CompressedIntegerList, CompressedCharacterList, CompressedRleList, etc...), as well as in other packages (e.g. GRangesList in the GenomicRanges package, GAlignmentsList in the GenomicAlignments package, etc...). It's easy for developers to extend CompressedList to create a new CompressedList subclass and there is generally very little work involved to make this new subclass fully operational.

In a CompressedList object the list elements are concatenated together in a single vector-like object. The partitioning of this single vector-like object (i.e. the information about where each original list element starts and ends) is also kept in the CompressedList object. This internal representation is generally more memory efficient than SimpleList, especially if the object has many list elements (e.g. thousands or millions). Also it makes it possible to implement many basic list operations very efficiently.

Many objects like LogicalList, IntegerList, CharacterList, RleList, etc... exist in 2 flavors: CompressedList and SimpleList. Each flavor is incarnated by a concrete subclass: CompressedLogicalList and SimpleLogicalList for virtual class LogicalList, CompressedIntegerList and SimpleIntegerList for virtual class IntegerList, etc... It's easy to switch from one representation to the other with `as(x, "CompressedList")` and `as(x, "SimpleList")`. Also the constructor function for those virtual classes have a switch that lets the user choose the representation at construction time e.g. `CharacterList(..., compress=TRUE)` or `CharacterList(..., compress=FALSE)`. See below for more information.

### Constructor

See the List man page in the S4Vectors package for a quick overview of how to construct List objects in general.

Unlike for SimpleList objects, there is no `CompressedList` constructor function.

However, many constructor functions for List objects have a switch that lets the user choose between the CompressedList and SimpleList representation at construction time. For example, a CompressedCharacterList object can be constructed with `CharacterList(..., compress=TRUE)`.

### Accessors

Same as for List objects. See the List man page in the S4Vectors package for more information.

### Coercion

All the coercions documented in the List man page apply to CompressedList objects.

### Subsetting

Same as for List objects. See the List man page for more information.

### Looping and functional programming

Same as for List objects. See `?`List-utils`` in the S4Vectors package for more information.

### Displaying

When a CompressedList object is displayed, the "Compressed" prefix is removed from the real class name of the object. See `classNameForDisplay` in the S4Vectors package for more information about this.

### See Also

- The List class defined and documented in the S4Vectors package for the parent class.

- The SimpleList class defined and documented in the S4Vectors package for an alternative to CompressedList.

- The CompressedIntegerList class for a CompressedList subclass example.

### Examples

    ## Displaying a CompressedList object:
    x <- IntegerList(11:12, integer(0), 3:-2, compress=TRUE)
    class(x)

    ## The "Simple" prefix is removed from the real class name of the
    ## object:
    x

    ## This is controlled by internal helper classNameForDisplay():
    classNameForDisplay(x)

[Package IRanges version 2.14.12 Index]