com.mapinfo.midev.feature

## Interface IFeatureIterator

All Known Subinterfaces:
  ICursor

    public interface IFeatureIterator

An iterator over `IFeatures`.

It is important to note that when done with an `IFeatureIterator` that its `IFeatureIterator.dispose()` method be called or a potential resource leak may occur. A typical pattern for using an `IFeatureIterator` is as follows:

    // this assumes there is an iterator() method returning an IFeatureIterator
    IFeatureIterator iterator = iterator();
    try {
        while (iterator.hasNext()) {
            IFeature feature = iterator.next();
            // do something with each feature
        }
    } finally {
        iterator.dispose();
    }

### Method Summary

All Methods Instance Methods Abstract Methods Default Methods
`void` `dispose()` Disposes of the resources held by this feature iterator.
`default void` `forEachRemaining(Consumer action)` Performs the given action for each remaining feature in this feature iterator until all features have been processed or the action throws an exception.
`boolean` `hasNext()` Returns true if `next` will return a feature; false if it will throw an exception.
`boolean` `isDisposed()` Returns true if this feature iterator has been closed; false if not.
`boolean` `isTransient()` Returns true if this feature iterator will produce transient features; false if not.
`IFeature` `next()` Returns the next feature from this feature iterator.
`default void` `remove()` Removes the most recently returned feature from `next`.

### Method Detail

#### next

    IFeature next()

Returns the next feature from this feature iterator.

Returns:
  the next feature from this feature iterator.
Throws:
  `NoSuchElementException` - iteration has no more elements.
  `IllegalStateException` - if this feature iterator has been disposed.

#### dispose

    void dispose()

Disposes of the resources held by this feature iterator. Feature iterators are intended to be used as forward-only accessors to a set of feature instances.

It is good practice to always dispose of a feature iterator (including implementations of `ICursor`) to indicate that it may release its resources. In some cases, such as when the iterator is managing a database cursor, it is required to release the resources so that the database connection may be reused.

Calling dispose on an iterator that has already been disposed does not throw an exception.

#### isDisposed

    boolean isDisposed()

Returns true if this feature iterator has been closed; false if not.

Returns:
  true if this feature iterator has been closed; false if not.

#### isTransient

    boolean isTransient()

Returns true if this feature iterator will produce transient features; false if not.

Returns:
  true if this feature iterator will produce transient features; false if not.
Throws:
  `IllegalStateException` - if this feature iterator has been disposed.

#### hasNext

    boolean hasNext()

Returns true if `next` will return a feature; false if it will throw an exception.

Returns:
  true if `next` will return a feature; false if it will throw an exception.
Throws:
  `IllegalStateException` - if this feature iterator has been disposed.

#### remove

    default void remove()

Removes the most recently returned feature from `next`. This is an optional operation.

The default implementation throws an instance of `UnsupportedOperationException` and performs no other action.

Throws:
  `UnsupportedOperationException` - if the `remove` operation is not supported by this feature iterator.
  `IllegalStateException` - if `next()` has not been called or this feature iterator has been disposed.

#### forEachRemaining

    default void forEachRemaining(Consumer action)

Performs the given action for each remaining feature in this feature iterator until all features have been processed or the action throws an exception. The feature iterator will be disposed when returned. Exceptions thrown by the action are relayed to the caller.

The default implementation behaves as if:

            try {
              while (hasNext()) {
                action.accept(next());
              }
            } finally {
              dispose();
            }

Parameters:
  `action` - The action to be performed for each IFeature
Throws:
  `NullPointerException` - if the specified action is null
  `IllegalStateException` - if this feature iterator has been disposed.