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.
For the standard S3 interface, see setnew().
container::Iterable -> container::Container -> Set
new()Set constructor
Set$new(...)
...initial elements put into the Set
returns the Set object
add()Add element
Set$add(value, name = NULL)
valuevalue of ANY type to be added to the Set.
namecharacter optional name attribute of the value.
the Set object.
diff()Set difference
Set$diff(s)
sSet object to 'subtract'
the Set object updated as a result of the set difference
between this and s.
intersect()Set intersection
Set$intersect(s)
sSet object to 'intersect'
the Set object as a result of the intersection of this and s.
union()Set union
Set$union(s)
sSet object to be 'unified'
the Set object as a result of the union of this and s.
is_equal()Set equality
Set$is_equal(s)
sSet object to compare against
TRUE if this is equal to s, otherwise FALSE
is_subset()Set proper subset
Set$is_subset(s)
sSet object to compare against
TRUE if this is subset of s, otherwise FALSE
is_proper_subset()Set subset
Set$is_proper_subset(s)
sSet object to compare against
TRUE if this is proper subset of s, otherwise FALSE
values()Get Set values
Set$values()
elements of the set as a base list
clone()The objects of this class are cloneable with this method.
Set$clone(deep = FALSE)
deepWhether to make a deep clone.
# NOT RUN {
s1 = Set$new(1, 2)
s1
s1$add(1)
s1$add(3)
s2 = Set$new(3, 4, 5)
s1$union(s2)
s1
s1 = Set$new(1, 2, 3)
s1$intersect(s2)
s1
s1$diff(s2)
s1$diff(s1)
s1
# }
Run the code above in your browser using DataLab