| Set {container} | R Documentation |
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.
For the standard S3 interface, see setnew().
Super classes
container::Iterable -> container::Container -> Set
Methods
Public methods
Inherited methods
container::Iterable$iter()container::Container$at()container::Container$at2()container::Container$clear()container::Container$count()container::Container$delete()container::Container$delete_at()container::Container$discard()container::Container$discard_at()container::Container$empty()container::Container$get_compare_fun()container::Container$has()container::Container$has_name()container::Container$is_empty()container::Container$length()container::Container$names()container::Container$peek_at()container::Container$peek_at2()container::Container$pop()container::Container$print()container::Container$remove()container::Container$rename()container::Container$replace()container::Container$replace_at()container::Container$size()container::Container$type()container::Container$update()
Method new()
Set constructor
Usage
Set$new(...)
Arguments
...initial elements put into the
Set
Returns
returns the Set object
Method add()
Add element
Usage
Set$add(value, name = NULL)
Arguments
valuevalue of
ANYtype to be added to theSet.namecharacteroptional name attribute of the value.
Returns
the Set object.
Method diff()
Set difference
Usage
Set$diff(s)
Arguments
sSetobject to 'subtract'
Returns
the Set object updated as a result of the set difference
between this and s.
Method intersect()
Set intersection
Usage
Set$intersect(s)
Arguments
sSetobject to 'intersect'
Returns
the Set object as a result of the intersection of this and s.
Method union()
Set union
Usage
Set$union(s)
Arguments
sSetobject to be 'unified'
Returns
the Set object as a result of the union of this and s.
Method is_equal()
Set equality
Usage
Set$is_equal(s)
Arguments
sSetobject to compare against
Returns
TRUE if this is equal to s, otherwise FALSE
Method is_subset()
Set proper subset
Usage
Set$is_subset(s)
Arguments
sSetobject to compare against
Returns
TRUE if this is subset of s, otherwise FALSE
Method is_proper_subset()
Set subset
Usage
Set$is_proper_subset(s)
Arguments
sSetobject to compare against
Returns
TRUE if this is proper subset of s, otherwise FALSE
Method values()
Get Set values
Usage
Set$values()
Returns
elements of the set as a base list
Method clone()
The objects of this class are cloneable with this method.
Usage
Set$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Examples
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