1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.utils.datastructures;
14 import java.util.Collection;
15 import java.util.Iterator;
18 public class SetUnion<T> extends ImmutableCollection<T> {
23 public SetUnion(Set<T> set1, Set<T> set2) {
29 public boolean contains(Object o) {
30 return set1.contains(o) || set2.contains(o);
34 public boolean containsAll(Collection<?> c) {
42 public boolean isEmpty() {
43 return set1.isEmpty() && set2.isEmpty();
47 public Iterator<T> iterator() {
48 return new ImmutableIterator<T>() {
51 Iterator<T> it1 = set1.iterator();
52 Iterator<T> it2 = set2.iterator();
56 public boolean hasNext() {
68 while(it2.hasNext()) {
70 if(set1.contains(element))
95 while(it2.hasNext()) {
97 if(!set1.contains(ret))
109 int count = set1.size();
111 if(!set1.contains(o))