/** The union of an OclSet and an OclBag is an OclBag. */ public OclBag union(OclBag bag) { if (isUndefined()) return new OclBag(0, getUndefinedReason()); if (bag.isUndefined()) return bag; ArrayList list = new ArrayList(collection.size() + bag.collection.size()); list.addAll(collection); list.addAll(bag.collection); return new OclBag(list); }
/** * @return an OclSet containing all elements found both in this OclSet and in the OclBag given as * parameter */ public OclSet intersection(OclBag bag) { if (isUndefined()) return this; if (bag.isUndefined()) return new OclSet(0, bag.getUndefinedReason()); Set set = intersection(bag.collection); return new OclSet(set); }