Learn R Programming

container (version 0.3.0)

Set: A Set class

Description

The Set is considered and implemented as a specialized Container, that is, elements are always unique in the Container and it provides typical set operations such as union and intersect.

Usage

Set

Arguments

Format

An object of class R6ClassGenerator of length 24.

R6 constructor

Set$new(x=list())

Inherited methods

Inherits all methods from Container, but overrides add:

add(elem)

If not already in set, add elem.

Set methods

union(s)

Return new Set as a result of the union of this and s.

intersect(s)

Return new Set as a result of the intersection of this and s.

diff(s)

Return new Set as a result of the set difference between this and s.

is.subset(s)

TRUE if this is a subset of s, else FALSE.

is.superset(s)

TRUE if this is a superset of s, else FALSE.

See Also

Container

Examples

Run this code
# NOT RUN {
s1 <- Set$new()$add("A")
s1$values()                     # "A"
s1$add(2)$add("A")$values()     # "A" 2
s1$remove("A")$values()         # 2

#' \dontrun{
#' s1$remove(3)              # Error: 3 not in Set
#' }
# }

Run the code above in your browser using DataLab