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

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
value

value of ANY type to be added to the Set.

name

character optional name attribute of the value.

Returns

the Set object.


Method diff()

Set difference

Usage
Set$diff(s)
Arguments
s

Set object 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
s

Set object 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
s

Set object 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
s

Set object 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
s

Set object 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
s

Set object 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
deep

Whether to make a deep clone.

See Also

Container, set()

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

[Package container version 1.0.4 Index]