E - 元素类型public class ArrayIterator<E> extends Object implements ResettableIterator<E>
Iterator 任何数组的迭代器
数组可以是对象数组,也可以是基元数组 如果你知道
class是更好的选择,因为它会表现得更好
迭代器实现了一个reset()方法,允许重置
如果需要,迭代器返回到开始| Constructor and Description |
|---|
ArrayIterator(Object array)
构造
|
ArrayIterator(Object array,
int startIndex)
构造
|
ArrayIterator(Object array,
int startIndex,
int endIndex)
构造
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkBound(int bound,
int len,
String type) |
Object |
getArray() |
int |
getEndIndex() |
int |
getStartIndex() |
boolean |
hasNext() |
E |
next() |
void |
remove() |
void |
reset()
将迭代器重置为创建迭代器的位置.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEachRemainingpublic ArrayIterator(Object array)
array - 数组IllegalArgumentException - array对象不为数组抛出此异常NullPointerException - array对象为nullpublic ArrayIterator(Object array, int startIndex)
array - 数组startIndex - 起始位置,当起始位置小于0或者大于结束位置,置为0。IllegalArgumentException - array对象不为数组抛出此异常NullPointerException - array对象为nullpublic ArrayIterator(Object array, int startIndex, int endIndex)
array - 数组startIndex - 起始位置,当起始位置小于0或者大于结束位置,置为0。endIndex - 结束位置,当结束位置小于0或者大于数组长度,置为数组长度。IllegalArgumentException - array对象不为数组抛出此异常NullPointerException - array对象为nullprotected void checkBound(int bound,
int len,
String type)
public Object getArray()
public int getStartIndex()
public int getEndIndex()
public void reset()
ResettableIteratorreset in interface ResettableIterator<E>Copyright © 2020. All rights reserved.