@Override public void enqueue(final int x) { if (inv[x] >= 0) throw new IllegalArgumentException("Index " + x + " belongs to the queue"); if (size == heap.length) heap = IntArrays.grow(heap, size + 1); inv[heap[size] = x] = size++; LongIndirectHeaps.upHeap(refArray, heap, inv, size, size - 1, c); } @Override
@Override public void enqueue(final int x) { if (inv[x] >= 0) throw new IllegalArgumentException("Index " + x + " belongs to the queue"); if (size == heap.length) heap = IntArrays.grow(heap, size + 1); inv[heap[size] = x] = size++; CharIndirectHeaps.upHeap(refArray, heap, inv, size, size - 1, c); } @Override
@Override public void enqueue(final int x) { if (inv[x] >= 0) throw new IllegalArgumentException("Index " + x + " belongs to the queue"); if (size == heap.length) heap = IntArrays.grow(heap, size + 1); inv[heap[size] = x] = size++; ByteIndirectHeaps.upHeap(refArray, heap, inv, size, size - 1, c); } @Override
@Override public void enqueue(final int x) { if (inv[x] >= 0) throw new IllegalArgumentException("Index " + x + " belongs to the queue"); if (size == heap.length) heap = IntArrays.grow(heap, size + 1); inv[heap[size] = x] = size++; IntIndirectHeaps.upHeap(refArray, heap, inv, size, size - 1, c); } @Override
@Override public void enqueue(int x) { if (size == heap.length) heap = IntArrays.grow(heap, size + 1); heap[size++] = x; IntHeaps.upHeap(heap, size, size - 1, c); } @Override
@Override public void enqueue(final int x) { if (inv[x] >= 0) throw new IllegalArgumentException("Index " + x + " belongs to the queue"); if (size == heap.length) heap = IntArrays.grow(heap, size + 1); inv[heap[size] = x] = size++; ObjectIndirectHeaps.upHeap(refArray, heap, inv, size, size - 1, c); } @Override
@Override public void enqueue(final int x) { if (inv[x] >= 0) throw new IllegalArgumentException("Index " + x + " belongs to the queue"); if (size == heap.length) heap = IntArrays.grow(heap, size + 1); inv[heap[size] = x] = size++; ShortIndirectHeaps.upHeap(refArray, heap, inv, size, size - 1, c); } @Override
@Override public void enqueue(final int x) { if (inv[x] >= 0) throw new IllegalArgumentException("Index " + x + " belongs to the queue"); if (size == heap.length) heap = IntArrays.grow(heap, size + 1); inv[heap[size] = x] = size++; FloatIndirectHeaps.upHeap(refArray, heap, inv, size, size - 1, c); } @Override
@Override public void enqueue(final int x) { if (inv[x] >= 0) throw new IllegalArgumentException("Index " + x + " belongs to the queue"); if (size == heap.length) heap = IntArrays.grow(heap, size + 1); inv[heap[size] = x] = size++; DoubleIndirectHeaps.upHeap(refArray, heap, inv, size, size - 1, c); } @Override
/** Writes the positions of an index iterator into an array; if the array is not large enough, it * will be reallocated using {@link IntArrays#grow(int[], int)}. * * <p>Note that this method just iterates {@link IndexIterator#nextPosition()}. If the * method has already been called, the positions that have been already returned will be missing. * * @return {@code position}, if it was large enough to contain all positions; a new, larger array otherwise. */ public static int[] positionArray( final IndexIterator indexIterator, int[] position ) throws IOException { for( int i = 0, p; ( p = indexIterator.nextPosition() ) != IndexIterator.END_OF_POSITIONS; ) { if ( i == position.length ) position = IntArrays.grow( position, position.length + 1 ); position[ i++ ] = p; } return position; }
@Override public void enqueue(int x) { ensureElement(x); if (size == heap.length) heap = IntArrays.grow(heap, size + 1); heap[size++] = x; ObjectSemiIndirectHeaps.upHeap(refArray, heap, size, size - 1, c); } @Override
@Override public void enqueue(int x) { ensureElement(x); if (size == heap.length) heap = IntArrays.grow(heap, size + 1); heap[size++] = x; DoubleSemiIndirectHeaps.upHeap(refArray, heap, size, size - 1, c); } @Override
@Override public void enqueue(int x) { ensureElement(x); if (size == heap.length) heap = IntArrays.grow(heap, size + 1); heap[size++] = x; LongSemiIndirectHeaps.upHeap(refArray, heap, size, size - 1, c); } @Override
@Override public void enqueue(int x) { ensureElement(x); if (size == heap.length) heap = IntArrays.grow(heap, size + 1); heap[size++] = x; ShortSemiIndirectHeaps.upHeap(refArray, heap, size, size - 1, c); } @Override
@Override public void enqueue(int x) { ensureElement(x); if (size == heap.length) heap = IntArrays.grow(heap, size + 1); heap[size++] = x; CharSemiIndirectHeaps.upHeap(refArray, heap, size, size - 1, c); } @Override
@Override public void enqueue(int x) { ensureElement(x); if (size == heap.length) heap = IntArrays.grow(heap, size + 1); heap[size++] = x; IntSemiIndirectHeaps.upHeap(refArray, heap, size, size - 1, c); } @Override
@Override public void enqueue(int x) { ensureElement(x); if (size == heap.length) heap = IntArrays.grow(heap, size + 1); heap[size++] = x; ByteSemiIndirectHeaps.upHeap(refArray, heap, size, size - 1, c); } @Override
@Override public void enqueue(int x) { ensureElement(x); if (size == heap.length) heap = IntArrays.grow(heap, size + 1); heap[size++] = x; FloatSemiIndirectHeaps.upHeap(refArray, heap, size, size - 1, c); } @Override
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; }
@Override public int nextInt() { curr++; outdegree = bg.sample(); successors.clear(); if (! loops) successors.add(curr); for(int i = 0; i < outdegree; i++) while(! successors.add(random.nextInt(n))); if (! loops) successors.remove(curr); successorArray = IntArrays.grow(successorArray, outdegree); successors.toArray(successorArray); IntArrays.quickSort(successorArray, 0, outdegree); return curr; }