Logo
Distributed Genetic Programming Framework
print print

File org.sfc.collections.IteratorBase.java

Here you can find all the information about the file org.sfc.collections.IteratorBase.java. You may explore it here or download it onto your local disk.
/*
 * Copyright (c) 2006 Thomas Weise
 * 
 * E-Mail           : tweise@gmx.de
 * Creation Date    : 2006-05-24 08:35:18
 * Original Filename: org.sfc.collections.IteratorBase.java
 * Version          : 1.0.0
 * Last modification: 2006-05-24
 *                by: Thomas Weise
 * 
 * License          : GNU LESSER GENERAL PUBLIC LICENSE
 *                    Version 2.1, February 1999
 *                    You should have received a copy of this license along
 *                    with this library; if not, write to the Free Software
 *                    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *                    MA 02111-1307, USA or download the license under
 *                    http://www.gnu.org/copyleft/lesser.html.
 *                    
 * Warranty         : This software is provided "as is" without any
 *                    warranty; without even the implied warranty of
 *                    merchantability or fitness for a particular purpose.
 *                    See the Gnu Lesser General Public License for more
 *                    details.
 */

 
package org.sfc.collections;

import java.util.Enumeration;
import java.util.Iterator;
import java.util.NoSuchElementException;

import org.sfc.utils.ICloneable;

/**
 * This class should be used as base class for all iterators.
 * @param <ItemType>  The type of items to iterate over.
 * @author Thomas Weise
 */

public abstract class       IteratorBase<ItemType> 
                implements  Iterator<ItemType>,
                            Enumeration<ItemType>, ICloneable,
                            IVisitable<ItemType>
  {

/**
 * Tests if this enumeration contains more elements.
 *
 * @return  <code>true</code> if and only if this enumeration object
 *           contains at least one more element to provide;
 *          <code>false</code> otherwise.
 */

  public  final boolean hasMoreElements()
    {
    return hasNext();
    }

/**
 * Returns the next element of this enumeration if this enumeration
 * object has at least one more element to provide.
 *
 * @return     the next element of this enumeration.
 * @exception  NoSuchElementException  if no more elements exist.
 */

  public  final ItemType nextElement()
    {
    return next();
    }
  
/**
 * Clone this list iterator.
 * @return  A perfect copy of this iterator.
 */

  @Override
  public  Object  clone()
    {
    try
      {
      return super.clone();
      }
    catch(Throwable l_t)
      {
      return this;
      }
    }
  

/**
 * Visit all ids in this id manager.
 * @param p_visitor The visitor to be carried around.
 * @return  <code>true</code> if the visitor successfully visited all
 *          elements, <code>false</code> if it aborted its visit.
 */

  public  final boolean  visit (final IVisitor<ItemType> p_visitor)
    {
    while(this.hasNext())
      {
      if(!(p_visitor.visit(this.next()))) return false;
      }
    return true;
    }
  
 /**
   * This default implementation throws an exception.
   *
   * @exception UnsupportedOperationException if the <tt>remove</tt>
   *      operation is not supported by this Iterator.
   */

  public  void remove()
    {
    throw new UnsupportedOperationException();
    }
  }

File Information:

file name:IteratorBase.java
package:org.sfc.collections
qualified name:org.sfc.collections.IteratorBase.java
file type:Java Source File
download location:download http://dgpf.sourceforge.net/source/org/sfc/collections/IteratorBase.java
size:3.253 KB (3332 B)
uploaded: 2018-01-07 12:03:36 GMT+0000
last update: 2006-06-27 11:18:35 GMT+0000
last access: 2018-04-24 12:40:24 GMT+0000

statistics online since 2006-01-02.   RSS Feed
Contact us by sending an email to tweise@gmx.de to receive further information, to report errors, or to join our project.
All content on this site (http://dgpf.sourceforge.net/) is LGPL-licensed.
http://dgpf.sourceforge.net/scripts/source/source.php last modified at 2018-01-07 12:03:34 GMT+0000 served at 2018-04-24 12:40:24 GMT+0000.
Valid CSS Valid XHTML 1.1
Valid RSS SourceForge.net Logo