本文整理汇总了Java中it.unimi.dsi.fastutil.ints.AbstractIntIterator类的典型用法代码示例。如果您正苦于以下问题:Java AbstractIntIterator类的具体用法?Java AbstractIntIterator怎么用?Java AbstractIntIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AbstractIntIterator类属于it.unimi.dsi.fastutil.ints包,在下文中一共展示了AbstractIntIterator类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: keySet
import it.unimi.dsi.fastutil.ints.AbstractIntIterator; //导入依赖的package包/类
/** Returns a type-specific-set view of the keys of this map.
*
* <P>The view is backed by the set returned by {@link #entrySet()}. Note that
* <em>no attempt is made at caching the result of this method</em>, as this would
* require adding some attributes that lightweight implementations would
* not need. Subclasses may easily override this policy by calling
* this method and caching the result, but implementors are encouraged to
* write more efficient ad-hoc implementations.
*
* @return a set view of the keys of this map; it may be safely cast to a type-specific interface.
*/
public IntSet keySet() {
return new AbstractIntSet () {
public boolean contains( final int k ) { return containsKey( k ); }
public int size() { return AbstractInt2IntMap.this.size(); }
public void clear() { AbstractInt2IntMap.this.clear(); }
public IntIterator iterator() {
return new AbstractIntIterator () {
final ObjectIterator<Map.Entry<Integer,Integer>> i = entrySet().iterator();
public int nextInt() { return ((Int2IntMap.Entry )i.next()).getIntKey(); };
public boolean hasNext() { return i.hasNext(); }
};
}
};
}
示例2: values
import it.unimi.dsi.fastutil.ints.AbstractIntIterator; //导入依赖的package包/类
/** Returns a type-specific-set view of the values of this map.
*
* <P>The view is backed by the set returned by {@link #entrySet()}. Note that
* <em>no attempt is made at caching the result of this method</em>, as this would
* require adding some attributes that lightweight implementations would
* not need. Subclasses may easily override this policy by calling
* this method and caching the result, but implementors are encouraged to
* write more efficient ad-hoc implementations.
*
* @return a set view of the values of this map; it may be safely cast to a type-specific interface.
*/
public IntCollection values() {
return new AbstractIntCollection () {
public boolean contains( final int k ) { return containsValue( k ); }
public int size() { return AbstractInt2IntMap.this.size(); }
public void clear() { AbstractInt2IntMap.this.clear(); }
public IntIterator iterator() {
return new AbstractIntIterator () {
final ObjectIterator<Map.Entry<Integer,Integer>> i = entrySet().iterator();
public int nextInt() { return ((Int2IntMap.Entry )i.next()).getIntValue(); };
public boolean hasNext() { return i.hasNext(); }
};
}
};
}
示例3: outdegrees
import it.unimi.dsi.fastutil.ints.AbstractIntIterator; //导入依赖的package包/类
/** Returns an iterator enumerating the outdegrees of the nodes of this graph.
*
* @return an iterator enumerating the outdegrees of the nodes of this graph.
*/
public IntIterator outdegrees() {
return randomAccess() ?
new AbstractIntIterator() {
private final int n = numNodes();
private int next = 0;
@Override
public boolean hasNext() {
return next < n;
}
@Override
public int nextInt() {
if ( ! hasNext() ) throw new NoSuchElementException();
return outdegree( next++ );
}
} :
new AbstractIntIterator() {
private final NodeIterator nodeIterator = nodeIterator();
@Override
public boolean hasNext() {
return nodeIterator.hasNext();
}
@Override
public int nextInt() {
nodeIterator.nextInt();
return nodeIterator.outdegree();
}
};
}