Package dev.zemco.codegame.execution.io
Class IterableInputSource
java.lang.Object
dev.zemco.codegame.execution.io.IterableInputSource
- All Implemented Interfaces:
IInputSource
Input source that uses an iterable as source of inputs.- Author:
- Erik Zemčík
-
Constructor Summary
ConstructorsConstructorDescriptionIterableInputSource(Iterable<Integer> iterable) Creates an instance ofIterableInputSourceby wrapping aniterable. -
Method Summary
-
Constructor Details
-
IterableInputSource
Creates an instance ofIterableInputSourceby wrapping aniterable.- Parameters:
iterable- iterable to use as source of inputs- Throws:
IllegalArgumentException- if iterable is null
-
-
Method Details
-
hasNextValue
public boolean hasNextValue()Returns if the underlyingiteratorhas next value.- Specified by:
hasNextValuein interfaceIInputSource- Returns:
- true if iterator has next value, else false
-
getNextValue
public int getNextValue()Returns next value from the underlyingiterator.- Specified by:
getNextValuein interfaceIInputSource- Returns:
- next value from iterator
- Throws:
NoSuchElementException- if iterator has no next value
-