@Override
public Iterator<Numeric> iterator() {
return new UnmodifiableIterator<Numeric>() {
private int index = 0;
@Override
public final boolean hasNext() {
return index < components.length;
}
@Override
public final Numeric next() {
return components[index++];
}
};
}
java类com.google.common.collect.UnmodifiableIterator的实例源码
ClusterCentroid.java 文件源码
项目:thesis-cilib
阅读 18
收藏 0
点赞 0
评论 0
Vector.java 文件源码
项目:thesis-cilib
阅读 25
收藏 0
点赞 0
评论 0
/**
* Obtain an unmodifiable iterator to traverse the {@code Vector} iteratively.
* @return An {@code Iterator} of {@code Numeric}s.
* @throws UnsupportedOperationException if {@code remove()} is called.
*/
@Override
public Iterator<Numeric> iterator() {
return new UnmodifiableIterator<Numeric>() {
private int index = 0;
@Override
public final boolean hasNext() {
return index < components.length;
}
@Override
public final Numeric next() {
return components[index++];
}
};
}
ConstantArrayCollection.java 文件源码
项目:yangtools
阅读 20
收藏 0
点赞 0
评论 0
@Nonnull
@Override
public Iterator<E> iterator() {
return new UnmodifiableIterator<E>() {
private int offset = 0;
@Override
public boolean hasNext() {
return offset < array.length;
}
@Override
public E next() {
if (offset >= array.length) {
throw new NoSuchElementException();
}
return array[offset++];
}
};
}
ImmutableOffsetMap.java 文件源码
项目:yangtools
阅读 20
收藏 0
点赞 0
评论 0
@Nonnull
@Override
public Iterator<Entry<K, V>> iterator() {
final Iterator<Entry<K, Integer>> it = offsets.entrySet().iterator();
return new UnmodifiableIterator<Entry<K, V>>() {
@Override
public boolean hasNext() {
return it.hasNext();
}
@Override
public Entry<K, V> next() {
final Entry<K, Integer> e = it.next();
return new SimpleImmutableEntry<>(e.getKey(), objects[e.getValue()]);
}
};
}
SchemaNodeIdentifier.java 文件源码
项目:yangtools
阅读 21
收藏 0
点赞 0
评论 0
/**
* Returns the list of nodes which need to be traversed to get from this
* node to the starting point (root for absolute SchemaPaths).
*
* @return list of <code>qname</code> instances which represents
* path from the schema node towards the root.
*/
public Iterable<QName> getPathTowardsRoot() {
return () -> new UnmodifiableIterator<QName>() {
private SchemaNodeIdentifier current = SchemaNodeIdentifier.this;
@Override
public boolean hasNext() {
return current.parent != null;
}
@Override
public QName next() {
if (current.parent != null) {
final QName ret = current.qname;
current = current.parent;
return ret;
} else {
throw new NoSuchElementException("No more elements available");
}
}
};
}
SchemaPath.java 文件源码
项目:yangtools
阅读 24
收藏 0
点赞 0
评论 0
/**
* Returns the list of nodes which need to be traversed to get from this
* node to the starting point (root for absolute SchemaPaths).
*
* @return list of <code>qname</code> instances which represents
* path from the schema node towards the root.
*/
public Iterable<QName> getPathTowardsRoot() {
return () -> new UnmodifiableIterator<QName>() {
private SchemaPath current = SchemaPath.this;
@Override
public boolean hasNext() {
return current.parent != null;
}
@Override
public QName next() {
if (current.parent != null) {
final QName ret = current.qname;
current = current.parent;
return ret;
}
throw new NoSuchElementException("No more elements available");
}
};
}
RelCollationImpl.java 文件源码
项目:calcite
阅读 20
收藏 0
点赞 0
评论 0
public int compareTo(@Nonnull RelMultipleTrait o) {
final RelCollationImpl that = (RelCollationImpl) o;
final UnmodifiableIterator<RelFieldCollation> iterator =
that.fieldCollations.iterator();
for (RelFieldCollation f : fieldCollations) {
if (!iterator.hasNext()) {
return 1;
}
final RelFieldCollation f2 = iterator.next();
int c = Utilities.compare(f.getFieldIndex(), f2.getFieldIndex());
if (c != 0) {
return c;
}
}
return iterator.hasNext() ? -1 : 0;
}
Bug62456849TestDataGenerator.java 文件源码
项目:bazel
阅读 20
收藏 0
点赞 0
评论 0
public static void main(String[] args) throws IOException {
checkArgument(
args.length == 2,
"Usage: %s <input-jar> <output-jar>",
Bug62456849TestDataGenerator.class.getName());
Path inputJar = Paths.get(args[0]);
checkArgument(Files.isRegularFile(inputJar), "The input jar %s is not a file", inputJar);
Path outputJar = Paths.get(args[1]);
try (ZipFile inputZip = new ZipFile(inputJar.toFile());
ZipOutputStream outZip =
new ZipOutputStream(new BufferedOutputStream(Files.newOutputStream(outputJar)))) {
for (UnmodifiableIterator<? extends ZipEntry> it =
Iterators.forEnumeration(inputZip.entries());
it.hasNext(); ) {
ZipEntry entry = it.next();
String entryName = entry.getName();
byte[] content =
entryName.endsWith(".class")
? convertClass(inputZip, entry)
: readEntry(inputZip, entry);
writeToZipFile(outZip, entryName, content);
}
}
}
InMemoryDataSource.java 文件源码
项目:jrunalyzer
阅读 20
收藏 0
点赞 0
评论 0
@Override
public Iterable<Track> loadTracks(final Iterable<Id> ids)
throws IOException {
return new Iterable<Track>() {
@Override
public Iterator<Track> iterator() {
return new UnmodifiableIterator<Track>() {
Iterator<Id> delegate = ids.iterator();
@Override
public boolean hasNext() {
return this.delegate.hasNext();
}
@Override
public Track next() {
return loadTrack(this.delegate.next());
}
};
}
};
}
CssNode.java 文件源码
项目:closure-stylesheets
阅读 21
收藏 0
点赞 0
评论 0
/**
* This node and the transitive closure of its {@link #parent}s.
*/
public Iterable<CssNode> ancestors() {
return new Iterable<CssNode>() {
@Override
public Iterator<CssNode> iterator() {
return new UnmodifiableIterator<CssNode>() {
private CssNode current = CssNode.this;
@Override
public boolean hasNext() {
return current != null;
}
@Override
public CssNode next() {
CssNode result = current;
current = current.getParent();
return result;
}
};
}
};
}