/*
 * Jakelib2 - General purpose C++ library
 * Copyright (C) 2001 Florian Wolff  (florian@donuz.de)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but 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.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * $Id: Iterator.h,v 1.6 2003/08/17 15:07:46 florian Exp $
 */

#ifndef INCLUDE_JAKELIB2_UTIL_ITERATOR_H
# define INCLUDE_JAKELIB2_UTIL_ITERATOR_H

namespace jakelib {
  namespace util {

    /**
     * @brief An object which iterates over a collection. An \c Iterator is used to return
     * the items once only, in sequence, by successive calls to the next method.
     * 
     * @class Iterator
     * @version $Id: Iterator.h,v 1.6 2003/08/17 15:07:46 florian Exp $
     * @author Eric Blake <ebb9@email.byu.edu>
     * @author Florian 'Overflo' Wolff (florian@donuz.de)
     */
    class Iterator : public jakelib::lang::Interface
      {
      public:

	/**
	 * @brief Tests whether there are elements remaining
	 * in the collection. In other
	 * words, calling \c next will not throw an exception.
	 *
	 * @return true if there is at least one more element in the collection
	 */
	virtual jboolean hasNext() = 0;

	/**
	 * @brief Obtain the next element in the collection.
	 *
	 * @return the next element in the collection
	 * @throws NoSuchElementException if there are no more elements
	 */
	virtual jakelib::lang::Object* next() = 0;

	/**
	 * @brief Remove from the underlying collection the
	 * last element returned by next
	 * (optional operation). This method can be called only once after each
	 * call to \c next. It does not affect what will be returned
	 * by subsequent calls to next.
	 *
	 * @throws IllegalStateException if next has not yet been called or remove
	 *         has already been called since the last call to next.
	 * @throws UnsupportedOperationException if this Iterator does not support
	 *         the remove operation.
	 */
	virtual void remove() = 0;

        JAKELIB_DECLARE_INTERFACE(Iterator);
      };
  }
}

#endif

