Class AbstractCharIterator
- java.lang.Object
-
- org.codelibs.jhighlight.fastutil.chars.AbstractCharIterator
-
- All Implemented Interfaces:
Iterator<Character>
,CharIterator
- Direct Known Subclasses:
AbstractCharBidirectionalIterator
,CharIterators.UnmodifiableIterator
public abstract class AbstractCharIterator extends Object implements CharIterator
An abstract class facilitating the creation of type-specific iterators.To create a type-specific iterator you need both a method returning the next element as primitive type and a method returning the next element as an object. However, if you inherit from this class you need just one (anyone).
This class implements also a trivial version of
skip(int)
that uses type-specific methods; moreover,remove()
will throw anUnsupportedOperationException
.- See Also:
Iterator
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractCharIterator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Character
next()
Delegates to the corresponding type-specific method.char
nextChar()
Delegates to the corresponding generic method.void
remove()
This method just throws anUnsupportedOperationException
.int
skip(int n)
This method just iterates the type-specific version ofnext()
for at mostn
times, stopping ifIterator.hasNext()
becomes false.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining, hasNext
-
-
-
-
Method Detail
-
nextChar
public char nextChar()
Delegates to the corresponding generic method.- Specified by:
nextChar
in interfaceCharIterator
- Returns:
- the next element in the iteration.
- See Also:
Iterator.next()
-
next
public Character next()
Delegates to the corresponding type-specific method.
-
remove
public void remove()
This method just throws anUnsupportedOperationException
.
-
skip
public int skip(int n)
This method just iterates the type-specific version ofnext()
for at mostn
times, stopping ifIterator.hasNext()
becomes false.- Specified by:
skip
in interfaceCharIterator
- Parameters:
n
- the number of elements to skip.- Returns:
- the number of elements actually skipped.
- See Also:
Iterator.next()
-
-