本文整理了Java中java.util.ArrayList.iterator()
方法的一些代码示例,展示了ArrayList.iterator()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ArrayList.iterator()
方法的具体详情如下:
包路径:java.util.ArrayList
类名称:ArrayList
方法名:iterator
[英]Returns an iterator over the elements in this list in proper sequence.
The returned iterator is fail-fast.
[中]按正确的顺序返回此列表中元素的迭代器。
返回的迭代器是fail-fast。
代码示例来源:origin: jenkinsci/jenkins
@Override
public boolean hasNext() {
while ((delegate == null || !delegate.hasNext()) && (providers.hasNext())) {
final QueueItemAuthenticatorProvider provider = providers.next();
if (provider == null) {
continue;
}
delegate = new ArrayList<QueueItemAuthenticator>(provider.getAuthenticators()).iterator();
}
return delegate != null && delegate.hasNext();
}
代码示例来源:origin: apache/storm
private Iterator<Long> getIds() {
try {
partitionIdsLock.lock();
LOG.debug("Iterator partitionIds: {}", partitionIds);
return new ArrayList<>(partitionIds).iterator();
} finally {
partitionIdsLock.unlock();
}
}
代码示例来源:origin: alibaba/jstorm
@Override
public TaskMessage next() {
TaskMessage msg;
if (iter.hasNext()) {
msg = iter.next();
} else {
bundleOffset++;
iter = bundle.get(bundleOffset).iterator();
msg = iter.next();
}
if (null != msg) {
offset++;
}
return msg;
}
代码示例来源:origin: apache/storm
protected Iterator<String> listKeys(Path path) throws IOException {
ArrayList<String> ret = new ArrayList<String>();
FileStatus[] files = _fs.listStatus(new Path[]{path});
if (files != null) {
for (FileStatus sub : files) {
try {
ret.add(sub.getPath().getName().toString());
} catch (IllegalArgumentException e) {
//Ignored the file did not match
LOG.debug("Found an unexpected file in {} {}", path, sub.getPath().getName());
}
}
}
return ret.iterator();
}
代码示例来源:origin: apache/hbase
@Test
public void testUnsecure() throws ZooKeeperConnectionException, IOException {
Configuration conf = HBaseConfiguration.create();
conf.set(Superusers.SUPERUSER_CONF_KEY, "user1");
String node = "/hbase/testUnsecure";
ZKWatcher watcher = new ZKWatcher(conf, node, null, false);
List<ACL> aclList = ZKUtil.createACL(watcher, node, false);
assertEquals(1, aclList.size());
assertTrue(aclList.contains(Ids.OPEN_ACL_UNSAFE.iterator().next()));
}
代码示例来源:origin: google/guava
public void testIndexOf_consumedDataNoMatch() {
Iterator<String> iterator = Lists.newArrayList("manny", "mo", "mo", "jack").iterator();
assertEquals(-1, Iterators.indexOf(iterator, Predicates.equalTo("bob")));
assertFalse(iterator.hasNext());
}
代码示例来源:origin: apache/activemq
public MessageAck[] getAcks() {
ArrayList<Object> list = new ArrayList<Object>();
for (Iterator<TxOperation> iter = operations.iterator(); iter.hasNext();) {
TxOperation op = iter.next();
if (op.operationType == TxOperation.REMOVE_OPERATION_TYPE) {
list.add(op.data);
}
}
MessageAck rc[] = new MessageAck[list.size()];
list.toArray(rc);
return rc;
}
代码示例来源:origin: apache/storm
protected Iterator<LocalFsBlobStoreFile> listBlobStoreFiles(File path) throws IOException {
ArrayList<LocalFsBlobStoreFile> ret = new ArrayList<LocalFsBlobStoreFile>();
File[] files = path.listFiles();
if (files != null) {
for (File sub : files) {
try {
ret.add(new LocalFsBlobStoreFile(sub.getParentFile(), sub.getName()));
} catch (IllegalArgumentException e) {
//Ignored the file did not match
LOG.warn("Found an unexpected file in {} {}", path, sub.getName());
}
}
}
return ret.iterator();
}
代码示例来源:origin: libgdx/libgdx
private ArrayList<JniSection> getNativeCodeBodies (String classFile) {
ArrayList<JniSection> sections = getComments(classFile);
Iterator<JniSection> iter = sections.iterator();
while (iter.hasNext()) {
JniSection section = iter.next();
if (section.getNativeCode().startsWith("JNI")) iter.remove();
if (section.getNativeCode().startsWith("-{")) iter.remove();
if (!CustomIgnoreTag.isEmpty() && section.getNativeCode().startsWith(CustomIgnoreTag)) iter.remove();
}
return sections;
}
代码示例来源:origin: JetBrains/ideavim
@NotNull
@Override
public Iterator<List<KeyStroke>> iterator() {
return new ArrayList<List<KeyStroke>>(myKeys.keySet()).iterator();
}
代码示例来源:origin: apache/hbase
@Test
public void testSecuritySingleSuperuser() throws ZooKeeperConnectionException, IOException {
Configuration conf = HBaseConfiguration.create();
conf.set(Superusers.SUPERUSER_CONF_KEY, "user1");
String node = "/hbase/testSecuritySingleSuperuser";
ZKWatcher watcher = new ZKWatcher(conf, node, null, false);
List<ACL> aclList = ZKUtil.createACL(watcher, node, true);
assertEquals(2, aclList.size()); // 1+1, since ACL will be set for the creator by default
assertTrue(aclList.contains(new ACL(Perms.ALL, new Id("sasl", "user1"))));
assertTrue(aclList.contains(Ids.CREATOR_ALL_ACL.iterator().next()));
}
代码示例来源:origin: apache/activemq
public Message[] getMessages() {
ArrayList<Object> list = new ArrayList<Object>();
for (Iterator<TxOperation> iter = operations.iterator(); iter.hasNext();) {
TxOperation op = iter.next();
if (op.operationType == TxOperation.ADD_OPERATION_TYPE) {
list.add(op.data);
}
}
Message rc[] = new Message[list.size()];
list.toArray(rc);
return rc;
}
代码示例来源:origin: apache/storm
protected Iterator<BlobStoreFile> listBlobStoreFiles(Path path) throws IOException {
ArrayList<BlobStoreFile> ret = new ArrayList<BlobStoreFile>();
FileStatus[] files = _fs.listStatus(new Path[]{path});
if (files != null) {
for (FileStatus sub : files) {
try {
ret.add(new HdfsBlobStoreFile(sub.getPath().getParent(), sub.getPath().getName(),
_hadoopConf));
} catch (IllegalArgumentException e) {
//Ignored the file did not match
LOG.warn("Found an unexpected file in {} {}", path, sub.getPath().getName());
}
}
}
return ret.iterator();
}
代码示例来源:origin: libgdx/libgdx
private ArrayList<JniSection> getNativeCodeBodies (String classFile) {
ArrayList<JniSection> sections = getComments(classFile);
Iterator<JniSection> iter = sections.iterator();
while (iter.hasNext()) {
JniSection section = iter.next();
if (section.getNativeCode().startsWith("JNI")) iter.remove();
if (section.getNativeCode().startsWith("-{")) iter.remove();
if (!CustomIgnoreTag.isEmpty() && section.getNativeCode().startsWith(CustomIgnoreTag)) iter.remove();
}
return sections;
}
代码示例来源:origin: commons-collections/commons-collections
public Iterator makeEmptyIterator() {
ArrayList list = new ArrayList();
return new IteratorChain(list.iterator());
}
代码示例来源:origin: AltBeacon/android-beacon-library
private synchronized void refreshMeasurements() {
ArrayList<Measurement> newMeasurements = new ArrayList<Measurement>();
Iterator<Measurement> iterator = mMeasurements.iterator();
while (iterator.hasNext()) {
Measurement measurement = iterator.next();
if (SystemClock.elapsedRealtime() - measurement.timestamp < sampleExpirationMilliseconds ) {
newMeasurements.add(measurement);
}
}
mMeasurements = newMeasurements;
Collections.sort(mMeasurements);
}
代码示例来源:origin: alibaba/jstorm
protected Iterator<LocalFsBlobStoreFile> listBlobStoreFiles(File path) throws IOException {
ArrayList<LocalFsBlobStoreFile> ret = new ArrayList<LocalFsBlobStoreFile>();
File[] files = path.listFiles();
if (files != null) {
for (File sub: files) {
try {
ret.add(new LocalFsBlobStoreFile(sub.getParentFile(), sub.getName()));
} catch (IllegalArgumentException e) {
//Ignored the file did not match
LOG.warn("Found an unexpected file in {} {}",path, sub.getName());
}
}
}
return ret.iterator();
}
代码示例来源:origin: redisson/redisson
protected String getExpressionSetSummary(java.util.ArrayList<Integer> list) {
if (list.contains(NO_SPEC)) {
return "?";
}
if (list.contains(ALL_SPEC)) {
return "*";
}
StringBuilder buf = new StringBuilder();
Iterator<Integer> itr = list.iterator();
boolean first = true;
while (itr.hasNext()) {
Integer iVal = itr.next();
String val = iVal.toString();
if (!first) {
buf.append(",");
}
buf.append(val);
first = false;
}
return buf.toString();
}
代码示例来源:origin: commons-collections/commons-collections
public Iterator makeEmptyIterator() {
ArrayList list = new ArrayList();
return new ObjectGraphIterator(list.iterator(), null);
}
代码示例来源:origin: Sable/soot
public void addMetric(MetricData data) {
Iterator<MetricData> it = metricData.iterator();
while (it.hasNext()) {
MetricData temp = it.next();
if (temp.metricName.equals(data.metricName)) {
// System.out.println("Not adding same metric again......"+temp.metricName);
return;
}
}
metricData.add(data);
}
内容来源于网络,如有侵权,请联系作者删除!