001/*
002 *                    BioJava development code
003 *
004 * This code may be freely distributed and modified under the
005 * terms of the GNU Lesser General Public Licence.  This should
006 * be distributed with the code.  If you do not have a copy,
007 * see:
008 *
009 *      http://www.gnu.org/copyleft/lesser.html
010 *
011 * Copyright for this code is held jointly by the individual
012 * authors.  These should be listed in @author doc comments.
013 *
014 * For more information on the BioJava project and its aims,
015 * or to join the biojava-l mailing list, visit the home page
016 * at:
017 *
018 *      http://www.biojava.org/
019 *
020 */
021
022package org.biojava.bio.program.homologene;
023
024
025import java.util.HashSet;
026import java.util.Set;
027
028public class SimpleOrthoPairCollection
029    extends AbstractOrthoPairCollection
030{
031    protected Set groups;
032
033    public class Iterator 
034        implements OrthoPairCollection.Iterator
035    {
036        private java.util.Iterator groupsI;
037
038        /**
039         * constructor where the iterator is already created
040         */
041        private Iterator(java.util.Iterator groupsI) { this.groupsI = groupsI; }
042
043        public boolean hasNext()
044        {
045            return groupsI.hasNext();
046        }
047
048        public OrthoPairSet nextSet()
049        {
050            return (OrthoPairSet) groupsI.next();
051        }
052    }
053
054    public SimpleOrthoPairCollection()
055    {
056        groups = new HashSet();
057    }
058
059    SimpleOrthoPairCollection(Set groups)
060    {
061        this.groups = groups;
062    }
063
064    public void add(OrthoPairSet group)
065    {
066        groups.add(group);
067    }
068
069    public boolean contains(OrthoPairSet group)
070    {
071        return groups.contains(group);
072    }
073
074    public boolean isEmpty() { return groups.isEmpty(); }
075
076    public OrthoPairCollection.Iterator iterator()
077    {
078        return new Iterator(groups.iterator());
079    }
080/*
081    public OrthoPairCollection filter(OrthoPairSetFilter filters)
082    {
083        OrthoPairCollection results = new SimpleOrthoPairCollection();
084
085        // this method uses its privileged access to groups
086        for (java.util.Iterator groupsI = groups.iterator();
087               groupsI.hasNext(); )
088        {
089            OrthoPairSet group = (OrthoPairSet) groupsI.next();
090
091            if (filters.accept(group)) {
092                try {
093                    results.add(group);
094                }
095                catch (ChangeVetoException cve) {
096                    // should be impossible as this group was created by me
097                }
098            }
099        }
100        return results;
101    }
102*/
103}
104