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.security.InvalidParameterException;
15 import java.util.Collection;
16 import java.util.Iterator;
17 import java.util.List;
20 public class SetUnion2<T> extends ImmutableCollection<T> {
25 public boolean contains(Object o) {
26 for(Set<T> set : sets)
33 public boolean containsAll(Collection<?> c) {
41 public boolean isEmpty() {
42 for(Set<T> set : sets)
49 public Iterator<T> iterator() {
50 return new ImmutableIterator<T>() {
53 Iterator<T> it = sets.get(0).iterator();
57 public boolean hasNext() {
63 for(int i=0;i<setId;++i)
64 if(sets.get(i).contains(element)) {
71 if(setId < sets.size())
72 it = sets.get(setId).iterator();
86 for(int i=0;i<setId;++i)
87 if(sets.get(i).contains(element)) {
94 if(setId < sets.size())
95 it = sets.get(setId).iterator();
97 throw new InvalidParameterException();
107 int count = sets.get(0).size();
108 for(int i=1;i<sets.size();++i) {
110 for(T o : sets.get(i)) {
112 if(sets.get(j).contains(o))