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
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()
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.
sSet object to 'subtract'
the Set object updated as a result of the set difference
between this and s.
sSet object to 'intersect'
the Set object as a result of the intersection of this and 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.
Container, setnew()
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