/** * Copies the contents of the stack into a native array. Note that this will NOT * pop them out of the stack. The front of the list will be the top of the stack. * * @return an <code>int[]</code> value */ public int[] toArray() { int[] retval = _list.toArray(); reverse( retval, 0, size() ); return retval; }
/** * Reverse the order of the elements in the range of the list. * * @param dest the array of data * @param from the inclusive index at which to start reversing * @param to the exclusive index at which to stop reversing */ private void reverse( int[] dest, int from, int to ) { if ( from == to ) { return; // nothing to do } if ( from > to ) { throw new IllegalArgumentException( "from cannot be greater than to" ); } for ( int i = from, j = to - 1; i < j; i++, j-- ) { swap( dest, i, j ); } }
/** * beginning with startNode add all following nodes to LIFO queue. If node has been already * explored before, skip reexploration. */ @Override public void start( EdgeExplorer explorer, int startNode ) { TIntArrayStack stack = new TIntArrayStack(); GHBitSet explored = createBitSet(); stack.push(startNode); int current; while (stack.size() > 0) { current = stack.pop(); if (!explored.contains(current) && goFurther(current)) { EdgeIterator iter = explorer.setBaseNode(current); while (iter.next()) { int connectedId = iter.getAdjNode(); if (checkAdjacent(iter)) { stack.push(connectedId); } } explored.add(current); } } }
public TarjanIslandPruner(StreetLayer streetLayer, int minComponentSize, StreetMode mode) { this.streets = streetLayer; this.minComponentSize = minComponentSize; this.mode = mode; tarjanStack = new TIntArrayStack(); onTarjanStack = new BitSet(); toExplore = new TIntArrayStack(); lowestDiscoveryIndexOfReachableVertexKnownToBePredecessor = new int[streets.getVertexCount()]; Arrays.fill(lowestDiscoveryIndexOfReachableVertexKnownToBePredecessor, -1); discoveryIndex = new int[streets.getVertexCount()]; Arrays.fill(discoveryIndex, -1); edgeCursor = streetLayer.edgeStore.getCursor(); }
/** * Returns a String representation of the list, top to bottom. * * @return a <code>String</code> value */ public String toString() { final StringBuilder buf = new StringBuilder( "{" ); for ( int i = _list.size() - 1; i > 0; i-- ) { buf.append( _list.get( i ) ); buf.append( ", " ); } if ( size() > 0 ) { buf.append( _list.get( 0 ) ); } buf.append( "}" ); return buf.toString(); }
public TarjanIslandPruner(StreetLayer streetLayer, int minComponentSize, StreetMode mode) { this.streets = streetLayer; this.minComponentSize = minComponentSize; this.mode = mode; tarjanStack = new TIntArrayStack(); onTarjanStack = new BitSet(); toExplore = new TIntArrayStack(); lowestDiscoveryIndexOfReachableVertexKnownToBePredecessor = new int[streets.getVertexCount()]; Arrays.fill(lowestDiscoveryIndexOfReachableVertexKnownToBePredecessor, -1); discoveryIndex = new int[streets.getVertexCount()]; Arrays.fill(discoveryIndex, -1); edgeCursor = streetLayer.edgeStore.getCursor(); }
/** * Returns a String representation of the list, top to bottom. * * @return a <code>String</code> value */ public String toString() { final StringBuilder buf = new StringBuilder( "{" ); for ( int i = _list.size() - 1; i > 0; i-- ) { buf.append( _list.get( i ) ); buf.append( ", " ); } if ( size() > 0 ) { buf.append( _list.get( 0 ) ); } buf.append( "}" ); return buf.toString(); }
/** * Copies a slice of the list into a native array. Note that this will NOT * pop them out of the stack. The front of the list will be the top * of the stack. * <p> * If the native array is smaller than the stack depth, * the native array will be filled with the elements from the top * of the array until it is full and exclude the remainder. * * @param dest the array to copy into. */ public void toArray( int[] dest ) { int size = size(); int start = size - dest.length; if ( start < 0 ) { start = 0; } int length = Math.min( size, dest.length ); _list.toArray( dest, start, length ); reverse( dest, 0, length ); if ( dest.length > size ) { dest[size] = _list.getNoEntryValue(); } }
/** * Creates a new <code>PropSort</code> instance. * * @param x the first array of integer variables * @param y the second array of integer variables */ public PropSort(IntVar[] x, IntVar[] y) { super(ArrayUtils.append(x, y), PropagatorPriority.LINEAR, false); if (x.length != y.length || x.length == 0) { throw new IllegalArgumentException("PropSort Error: the two vectors " + "must be of the same (non zero) size"); } this.n = x.length; this.x = x; this.y = y; this.f = new int[this.n]; this.fPrime = new int[this.n]; this.xyGraph = new int[this.n][this.n]; this.sccSequences = new int[this.n][this.n]; this.dfsNodes = new int[this.n]; this.sccNumbers = new int[this.n]; this.tmpArray = new int[this.n]; this.pQueue = new PriorityQueue(this.n); this.s1 = new TIntArrayStack(this.n); this.s2 = new Stack2(this.n); }
/** * Returns a String representation of the list, top to bottom. * * @return a <code>String</code> value */ public String toString() { final StringBuilder buf = new StringBuilder( "{" ); for ( int i = _list.size() - 1; i > 0; i-- ) { buf.append( _list.get( i ) ); buf.append( ", " ); } if ( size() > 0 ) { buf.append( _list.get( 0 ) ); } buf.append( "}" ); return buf.toString(); }
/** * Reverse the order of the elements in the range of the list. * * @param dest the array of data * @param from the inclusive index at which to start reversing * @param to the exclusive index at which to stop reversing */ private void reverse( int[] dest, int from, int to ) { if ( from == to ) { return; // nothing to do } if ( from > to ) { throw new IllegalArgumentException( "from cannot be greater than to" ); } for ( int i = from, j = to - 1; i < j; i++, j-- ) { swap( dest, i, j ); } }
/** * Copies the contents of the stack into a native array. Note that this will NOT * pop them out of the stack. The front of the list will be the top of the stack. * * @return an <code>int[]</code> value */ public int[] toArray() { int[] retval = _list.toArray(); reverse( retval, 0, size() ); return retval; }
this.map.put(vars[i], i); this.toRemove = new TIntArrayStack(); this.toUpdateLeft = new TIntArrayStack[nbR + 1]; this.toUpdateRight = new TIntArrayStack[nbR + 1]; this.toUpdateLeft[i] = new TIntArrayStack(); this.toUpdateRight[i] = new TIntArrayStack();
/** * Returns a String representation of the list, top to bottom. * * @return a <code>String</code> value */ @Override public String toString() { final StringBuilder buf = new StringBuilder( "{" ); for ( int i = _list.size() - 1; i > 0; i-- ) { buf.append( _list.get( i ) ); buf.append( ", " ); } if ( size() > 0 ) { buf.append( _list.get( 0 ) ); } buf.append( "}" ); return buf.toString(); }
/** * Reverse the order of the elements in the range of the list. * * @param dest the array of data * @param from the inclusive index at which to start reversing * @param to the exclusive index at which to stop reversing */ private void reverse( int[] dest, int from, int to ) { if ( from == to ) { return; // nothing to do } if ( from > to ) { throw new IllegalArgumentException( "from cannot be greater than to" ); } for ( int i = from, j = to - 1; i < j; i++, j-- ) { swap( dest, i, j ); } }
/** * Copies the contents of the stack into a native array. Note that this will NOT * pop them out of the stack. The front of the list will be the top of the stack. * * @return an <code>int[]</code> value */ public int[] toArray() { int[] retval = _list.toArray(); reverse( retval, 0, size() ); return retval; }
public TarjansSCCAlgorithm( GraphHopperStorage graph, GHBitSet ignoreSet, final EdgeFilter edgeFilter ) { this.graph = graph; this.nodeStack = new TIntArrayStack(); this.onStack = new GHBitSetImpl(graph.getNodes()); this.nodeIndex = new int[graph.getNodes()]; this.nodeLowLink = new int[graph.getNodes()]; this.edgeFilter = edgeFilter; this.ignoreSet = ignoreSet; }
/** * Returns a String representation of the list, top to bottom. * * @return a <code>String</code> value */ public String toString() { final StringBuilder buf = new StringBuilder( "{" ); for ( int i = _list.size() - 1; i > 0; i-- ) { buf.append( _list.get( i ) ); buf.append( ", " ); } if ( size() > 0 ) { buf.append( _list.get( 0 ) ); } buf.append( "}" ); return buf.toString(); }
/** * Reverse the order of the elements in the range of the list. * * @param dest the array of data * @param from the inclusive index at which to start reversing * @param to the exclusive index at which to stop reversing */ private void reverse( int[] dest, int from, int to ) { if ( from == to ) { return; // nothing to do } if ( from > to ) { throw new IllegalArgumentException( "from cannot be greater than to" ); } for ( int i = from, j = to - 1; i < j; i++, j-- ) { swap( dest, i, j ); } }