public final Iterator < Double > iteratorDouble ( ) { return new Iterator < Double > ( ) { private final Iterator < Object > objectIterator = ( Iterator < Object > ) internalData . iterator ( ) ; /** {@inheritDoc} */ @ Override public boolean hasNext ( ) { return objectIterator . hasNext ( ) ; } /** {@inheritDoc} */ @ Override public Double next ( ) { return TypeInference . toDouble ( objectIterator . next ( ) ) ; } /** {@inheritDoc} */ @ Override public void remove ( ) { objectIterator . remove ( ) ; } } ; }
Iterator which casts the values of the Data Structure from Object to Double . This iterator should be used only when the underling Data Structure contains Numeric or Boolean values . Accessing this iterator when other data types are stored will lead to an Exception .