Bulk operations are particularly well suited to
Set
s; when applied, they perform standard set-algebraic operations. Suppose s1
and s2
are sets. Here's what bulk operations do:s1.containsAll(s2)
— returnstrue
ifs2
is a subset ofs1
. (s2
is a subset ofs1
if sets1
contains all of the elements ins2
.)s1.addAll(s2)
— transformss1
into the union ofs1
ands2
. (The union of two sets is the set containing all of the elements contained in either set.)s1.retainAll(s2)
— transformss1
into the intersection ofs1
ands2
. (The intersection of two sets is the set containing only the elements common to both sets.)s1.removeAll(s2)
— transformss1
into the (asymmetric) set difference ofs1
ands2
. (For example, the set difference ofs1
minuss2
is the set containing all of the elements found ins1
but not ins2
.)
Refrences:
No comments:
Post a Comment