X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.utils.datastructures%2Fsrc%2Forg%2Fsimantics%2Futils%2Fdatastructures%2FEssentiallyIterableCollection.java;h=bb25363f3219025164246b65a63218080c971a87;hb=refs%2Fchanges%2F38%2F238%2F2;hp=af92cb078b88fe1e0665993e0ce502990a3462e1;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/EssentiallyIterableCollection.java b/bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/EssentiallyIterableCollection.java index af92cb078..bb25363f3 100644 --- a/bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/EssentiallyIterableCollection.java +++ b/bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/EssentiallyIterableCollection.java @@ -1,57 +1,57 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.utils.datastructures; - -import java.util.Collection; -import java.util.Iterator; - - -/** - * Immutable Collection adapter that uses iterator method to implement all - * its methods. - */ -public abstract class EssentiallyIterableCollection extends ImmutableCollection { - - @Override - public boolean contains(Object o) { - Iterator iterator = iterator(); - while(iterator.hasNext()) - if(iterator.next().equals(o)) - return true; - return false; - } - - @Override - public boolean containsAll(Collection c) { - for(Object o : c) - if(!contains(o)) - return false; - return true; - } - - @Override - public boolean isEmpty() { - return iterator().hasNext(); - } - - @Override - public int size() { - int count = 0; - Iterator iterator = iterator(); - while(iterator.hasNext()) { - ++ count; - iterator.next(); - } - return count; - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.utils.datastructures; + +import java.util.Collection; +import java.util.Iterator; + + +/** + * Immutable Collection adapter that uses iterator method to implement all + * its methods. + */ +public abstract class EssentiallyIterableCollection extends ImmutableCollection { + + @Override + public boolean contains(Object o) { + Iterator iterator = iterator(); + while(iterator.hasNext()) + if(iterator.next().equals(o)) + return true; + return false; + } + + @Override + public boolean containsAll(Collection c) { + for(Object o : c) + if(!contains(o)) + return false; + return true; + } + + @Override + public boolean isEmpty() { + return iterator().hasNext(); + } + + @Override + public int size() { + int count = 0; + Iterator iterator = iterator(); + while(iterator.hasNext()) { + ++ count; + iterator.next(); + } + return count; + } + +}