本文整理汇总了Java中it.unimi.dsi.fastutil.ints.IntArrays.EMPTY_ARRAY属性的典型用法代码示例。如果您正苦于以下问题:Java IntArrays.EMPTY_ARRAY属性的具体用法?Java IntArrays.EMPTY_ARRAY怎么用?Java IntArrays.EMPTY_ARRAY使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类it.unimi.dsi.fastutil.ints.IntArrays
的用法示例。
在下文中一共展示了IntArrays.EMPTY_ARRAY属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: nodeIterator
public NodeIterator nodeIterator() {
return new NodeIterator() {
final NodeIterator nodeIterator = graph.nodeIterator();
@SuppressWarnings("hiding") int[] succ = IntArrays.EMPTY_ARRAY;
int outdegree = -1;
public int outdegree() {
if ( outdegree == -1 ) throw new IllegalStateException();
return outdegree;
}
public int nextInt() {
final int currNode = nodeIterator.nextInt();
final int oldOutdegree = nodeIterator.outdegree();
int[] oldSucc = nodeIterator.successorArray();
succ = IntArrays.ensureCapacity( succ, oldOutdegree, 0 );
outdegree = 0;
for( int i = 0; i < oldOutdegree; i++ ) if ( filter.accept( currNode, oldSucc[ i ] ) ) succ[ outdegree++ ] = oldSucc[ i ];
return currNode;
}
public int[] successorArray() {
if ( outdegree == -1 ) throw new IllegalStateException();
return succ;
}
public boolean hasNext() {
return nodeIterator.hasNext();
}
};
}
示例2: nodeIterator
public NodeIterator nodeIterator( final int from ) {
/** The invariant that we are assuming here is the following: at any time, <code>node</code> is the next (subgraph)
* node to be returned by {@link #nextInt()}. This variable contain sensible data
* only when <code>node</code> < <code>subgraphSize</code>. Moreover, if outdegree >= 0 then it is
* the outdegree of <code>node</code>-1, and <code>successorsCache</code> contains the successors. */
// TODO: decide for a strategy. Note that super.nodeIterator is very dangerous, as it uses random access.
return supergraph.randomAccess() && subgraphSize < supergraphNumNodes / 8 ? super.nodeIterator( from ) :
new NodeIterator() {
/** The current node (the next to be returned. */
int node = from;
/** This array caches the successors of the node that was returned last (<code>from</code>-1). */
int[] successorsCache = IntArrays.EMPTY_ARRAY;
/** The outdegree of the node that was returned last (<code>node</code>-1). */
int outdegree = -1;
final NodeIterator supergraphNodeIterator = supergraph.nodeIterator( subgraphNode[ from ] );
public int nextInt() {
if ( ! hasNext() ) throw new java.util.NoSuchElementException();
if ( node != from ) supergraphNodeIterator.skip( subgraphNode[ node ] - subgraphNode[ node - 1 ] );
else supergraphNodeIterator.nextInt();
outdegree = -1;
return node++;
}
public boolean hasNext() {
return ( node < subgraphSize );
}
private void unwrapSuccessors() {
int start = 0, done;
final LazyIntIterator i = ImmutableSubgraph.this.successors( node - 1, supergraphNodeIterator.successors() );
// ALERT: we removed i.hasNext() at the end of this check, but it is not necessary
while( ( done = LazyIntIterators.unwrap( i, successorsCache, start, successorsCache.length - start ) ) == successorsCache.length - start ) {
start = successorsCache.length;
successorsCache = IntArrays.grow( successorsCache, successorsCache.length + 1 );
}
outdegree = start + done;
}
public int[] successorArray() {
if ( node == from ) throw new IllegalStateException();
if ( outdegree == -1 ) unwrapSuccessors();
return successorsCache;
}
public LazyIntIterator successors() {
if ( node == from ) throw new IllegalStateException();
if ( outdegree == -1 ) unwrapSuccessors();
return LazyIntIterators.wrap( successorsCache, outdegree );
}
public int outdegree() {
if ( node == from ) throw new IllegalStateException();
if ( outdegree == -1 ) unwrapSuccessors();
return outdegree;
}
};
}
示例3: nodeIterator
public NodeIterator nodeIterator( final int from ) {
return new NodeIterator() {
/** If outdegree is nonnegative, the successors of the current node (this array may be, however, larger). */
@SuppressWarnings("hiding")
private int cache[] = IntArrays.EMPTY_ARRAY;
/** The outdegree of the current node, or -1 if the successor array for the current node has not been computed yet. */
@SuppressWarnings("hiding")
private int outdegree = -1;
private NodeIterator i0 = from < n0? g0.nodeIterator( from ) : null;
private NodeIterator i1 = from < n1? g1.nodeIterator( from ) : null;
public boolean hasNext() {
return i0 != null && i0.hasNext() || i1 != null && i1.hasNext();
}
public int nextInt() {
if ( ! hasNext() ) throw new java.util.NoSuchElementException();
outdegree = -1;
int result = -1;
if ( i0 != null ) {
if ( i0.hasNext() ) result = i0.nextInt();
else i0 = null;
}
if ( i1 != null ) {
if ( i1.hasNext() ) result = i1.nextInt();
else i1 = null;
}
return result;
}
public int[] successorArray() {
if ( outdegree != -1 ) return cache;
if ( i0 == null ) {
outdegree = i1.outdegree();
return cache = i1.successorArray();
}
if ( i1 == null ) {
outdegree = i0.outdegree();
return cache = i0.successorArray();
}
MergedIntIterator merge = new MergedIntIterator( i0.successors(), i1.successors() );
outdegree = LazyIntIterators.unwrap( merge, cache );
int upto, t;
while ( ( t = merge.nextInt() ) != -1 ) {
upto = cache.length;
cache = IntArrays.grow( cache, upto + 1 );
cache[ upto++ ] = t;
outdegree++;
outdegree += LazyIntIterators.unwrap( merge, cache, upto, cache.length - upto );
}
return cache;
}
public int outdegree() {
successorArray(); // So that the cache is filled up
return outdegree;
}
};
}
示例4: FixedWidthIntListLabel
/** Creates a new fixed-width label with an empty list.
*
* @param key the (only) key of this label.
* @param width the label width (in bits).
*/
public FixedWidthIntListLabel( String key, int width ) {
this( key, width, IntArrays.EMPTY_ARRAY );
}