You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sc...@apache.org on 2003/09/02 01:56:06 UTC

cvs commit: jakarta-commons-sandbox/primitives/src/java/org/apache/commons/primitive/iterator IntIterator.java PrimitiveIterator.java

scolebourne    2003/09/01 16:56:06

  Added:       primitives/src/java/org/apache/commons/primitive/collection
                        PrimitiveCollection.java IntCollection.java
               primitives/src/java/org/apache/commons/primitive
                        PrimitiveCollectable.java PrimitiveCloneable.java
               primitives/src/java/org/apache/commons/primitive/iterator
                        IntIterator.java PrimitiveIterator.java
  Log:
  Initial checkin
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/primitives/src/java/org/apache/commons/primitive/collection/PrimitiveCollection.java
  
  Index: PrimitiveCollection.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.commons.primitive.collection;
  
  import java.util.Collection;
  
  import org.apache.commons.primitive.PrimitiveCollectable;
  
  /**
   * Base interface for all primitive collection interfaces.
   * <p>
   * This interface extends {@link Collection} allowing seamless integration with other APIs.
   * All Collection methods can be used, using the primitive wrapper class.
   * However, it will be <em>much</em> more efficient to use the direct primitive methods
   * in the subinterface.
   * 
   * @author Stephen Colebourne
   * @version $Id: PrimitiveCollection.java,v 1.1 2003/09/01 23:56:05 scolebourne Exp $
   * @since 1.0
   */
  public interface PrimitiveCollection extends PrimitiveCollectable, Collection {
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/primitives/src/java/org/apache/commons/primitive/collection/IntCollection.java
  
  Index: IntCollection.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.commons.primitive.collection;
  
  import java.util.Collection;
  
  import org.apache.commons.primitive.PrimitiveCollectable;
  import org.apache.commons.primitive.iterator.IntIterator;
  
  /**
   * Defines a collection of primitive <code>int</code> values.
   * <p>
   * This interface extends {@link Collection} allowing seamless integration with other APIs.
   * All Collection methods can be used, using the primitive wrapper class {@link Integer}.
   * However, it will be <em>much</em> more efficient to use the methods defined here.
   * 
   * @author Stephen Colebourne
   * @version $Id: IntCollection.java,v 1.1 2003/09/01 23:56:05 scolebourne Exp $
   * @since 1.0
   */
  public interface IntCollection extends PrimitiveCollectable, Collection {
  
      // Mandatory operations
      //-----------------------------------------------------------------------
      /**
       * Gets an iterator over this collection.
       *
       * @return an iterator over this collection
       */
      IntIterator valueIterator();
  
      /**
       * Checks whether this collection contains a specified primitive value.
       *
       * @param value  the value to search for
       * @return <code>true</code> if the value is found
       */
      boolean containsValue(int value);
  
      /**
       * Gets the elements of this collection as an array.
       *
       * @return a new array containing a copy of the elements of this collection
       */
      int[] toValueArray();
  
      /**
       * Copies the elements of this collection into an array at a specified position.
       * <p>
       * If the array specified is large enough, it will be modified.
       * If the array is not large enough, a new array will be created and all
       * elements copied before the insertion begins.
       *
       * @param array  the array to add the elements to
       * @param insertionIndex  the position in the array to add the elements to
       * @return the array with the inserted collection
       * @throws IndexOutOfBoundsException is the index is invalid
       */
      int[] toValueArray(int[] array, int insertionIndex);
  
      // Optional operations
      //-----------------------------------------------------------------------
      /**
       * Adds a primitive value to this collection (optional operation).
       * <p>
       * This method is optional, throwing an UnsupportedOperationException if the
       * collection cannot be added to.
       *
       * @param value  the value to add to this collection
       * @return <code>true</code> if this collection was modified by this method call
       * @throws IllegalArgumentException if value is rejected by this collection
       * @throws UnsupportedOperationException if not supported by this collection
       */
      boolean addValue(int value);
  
      /**
       * Removes the first occurrance of the specified primitive value from
       * this collection (optional operation).
       * <p>
       * This method is optional, throwing an UnsupportedOperationException if the
       * collection cannot be removed from.
       *
       * @param value  the value to remove
       * @return <code>true</code> if this collection was modified by this method call
       * @throws IllegalArgumentException if value is rejected by this collection
       * @throws UnsupportedOperationException if not supported by this collection
       */
      boolean removeValue(int value);
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/primitives/src/java/org/apache/commons/primitive/PrimitiveCollectable.java
  
  Index: PrimitiveCollectable.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.commons.primitive;
  
  /**
   * Interface that is shared between Collection and Map implementations.
   * 
   * @author Stephen Colebourne
   * @version $Id: PrimitiveCollectable.java,v 1.1 2003/09/01 23:56:05 scolebourne Exp $
   * @since 1.0
   */
  public interface PrimitiveCollectable extends PrimitiveCloneable {
  
      // Mandatory operations
      //-----------------------------------------------------------------------
      /**
       * Gets the number of elements in this collection/map.
       * <p>
       * If this collection contains more than <code>Integer.MAX_VALUE</code>
       * elements, <code>Integer.MAX_VALUE</code> is returned.
       * 
       * @return the size of the collection/map
       */
      int size();
  
      /**
       * Checks whether the collection/map currently has no elements.
       *
       * @return <code>true</code> if has a size of zero
       */
      boolean isEmpty();
  
      /**
       * Optimizes the implementation after initialization.
       * <p>
       * The exact nature of the optimization is undefined and is implementation specific.
       * A standard optimization is to trim the internal storage array to the size.
       * An implementation may choose to do nothing, but it should NOT throw an
       * UnsupportedOperationException.
       */
      void optimize();
  
      /**
       * Checks whether the collection/map can currently be modified.
       *
       * @return <code>true</code> if the collection/map allows some kind of modification
       */
      boolean isModifiable();
  
      // Optional operations
      //-----------------------------------------------------------------------
      /**
       * Clears the collection/map of all elements (optional operation).
       * <p>
       * The collection/map will have a zero size after this method completes.
       * This method is optional, throwing an UnsupportedOperationException if the
       * collection/map cannot be cleared.
       *
       * @throws UnsupportedOperationException if method not supported by this collection
       */
      void clear();
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/primitives/src/java/org/apache/commons/primitive/PrimitiveCloneable.java
  
  Index: PrimitiveCloneable.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.commons.primitive;
  
  /**
   * Defines the clone method in a public way so it can be used.
   * 
   * @author Stephen Colebourne
   * @version $Id: PrimitiveCloneable.java,v 1.1 2003/09/01 23:56:05 scolebourne Exp $
   * @since 1.0
   */
  public interface PrimitiveCloneable {
  
      /**
       * Clones the object.
       * 
       * @return a newly cloned object
       */
      public Object clone();
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/primitives/src/java/org/apache/commons/primitive/iterator/IntIterator.java
  
  Index: IntIterator.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.commons.primitive.iterator;
  
  /**
   * Defines an iterator over primitive <code>int</code> values.
   * 
   * @author Stephen Colebourne
   * @version $Id: IntIterator.java,v 1.1 2003/09/01 23:56:06 scolebourne Exp $
   * @since 1.0
   */
  public interface IntIterator extends PrimitiveIterator {
  
      // Mandatory operations
      //-----------------------------------------------------------------------
      /**
       * Gets the next value from the iterator
       *
       * @return the next available value
       * @throws NoSuchElementException if there are no more values available
       */
      int next();
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/primitives/src/java/org/apache/commons/primitive/iterator/PrimitiveIterator.java
  
  Index: PrimitiveIterator.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.commons.primitive.iterator;
  
  /**
   * Base interface for all primitive iterator interfaces.
   * 
   * @author Stephen Colebourne
   * @version $Id: PrimitiveIterator.java,v 1.1 2003/09/01 23:56:06 scolebourne Exp $
   * @since 1.0
   */
  public interface PrimitiveIterator {
  
      // Mandatory operations
      //-----------------------------------------------------------------------
      /**
       * Checks whether the iterator has another value.
       * 
       * @return <code>true</code> if there is another value available
       */
      boolean hasNext();
      
      // Optional operations
      //-----------------------------------------------------------------------
      /**
       * Removes the last retrieved value from the underlying collection (optional operation).
       * <p>
       * This method is optional, throwing an UnsupportedOperationException if the
       * collection cannot be removed from.
       * 
       * @return <code>true</code> if there is another value available
       * @throws IllegalStateException if <code>next</code> has not yet been called
       * @throws IllegalStateException if <code>remove</code> has already been called
       */
      void remove();
      
  }