本文整理汇总了Java中edu.jhu.prim.list.IntStack类的典型用法代码示例。如果您正苦于以下问题:Java IntStack类的具体用法?Java IntStack怎么用?Java IntStack使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IntStack类属于edu.jhu.prim.list包,在下文中一共展示了IntStack类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNumReachable
import edu.jhu.prim.list.IntStack; //导入依赖的package包/类
private int getNumReachable(int root) {
boolean[] marked = new boolean[n+1];
Arrays.fill(marked, false);
// Run a depth-first search (excluding edges to the root) starting at the given token, and mark all reachable tokens.
IntStack stack = new IntStack();
stack.push(root);
int numMarked = 0;
while (stack.size() > 0) {
int p = stack.pop();
if (marked[p+1]) {
continue;
}
for (int c=0; c<n; c++) {
if (p != c && !marked[c+1] && this.isKept(p, c)) {
stack.push(c);
}
}
marked[p+1] = true;
numMarked++;
}
return numMarked;
}
示例2: quicksort
import edu.jhu.prim.list.IntStack; //导入依赖的package包/类
private static void quicksort(double[] array, int left, int right, boolean asc) {
IntStack leftStack = new IntStack();
IntStack rightStack = new IntStack();
leftStack.add(left);
rightStack.add(right);
while (leftStack.size() > 0) {
left = leftStack.pop();
right = rightStack.pop();
if (left < right) {
// Choose a pivot index.
// --> Here we choose the rightmost element which does the least
// amount of work if the array is already sorted.
int pivotIndex = right;
// Partition the array so that everything less than
// values[pivotIndex] is on the left of pivotNewIndex and everything
// greater than or equal is on the right.
int pivotNewIndex = partition(array, left, right, pivotIndex, asc);
// "Recurse" on the left side.
leftStack.push(left);
rightStack.push(pivotNewIndex - 1);
// "Recurse" on the right side.
leftStack.push(pivotNewIndex + 1);
rightStack.push(right);
}
}
}
示例3: quicksortValues
import edu.jhu.prim.list.IntStack; //导入依赖的package包/类
private static void quicksortValues(double[] array, long[] index, int left, int right, boolean asc) {
IntStack leftStack = new IntStack();
IntStack rightStack = new IntStack();
leftStack.add(left);
rightStack.add(right);
while (leftStack.size() > 0) {
left = leftStack.pop();
right = rightStack.pop();
if (left < right) {
// Choose a pivot index.
// --> Here we choose the rightmost element which does the least
// amount of work if the array is already sorted.
int pivotIndex = right;
// Partition the array so that everything less than
// values[pivotIndex] is on the left of pivotNewIndex and everything
// greater than or equal is on the right.
int pivotNewIndex = partitionValues(array, index, left, right, pivotIndex, asc);
// "Recurse" on the left side.
leftStack.push(left);
rightStack.push(pivotNewIndex - 1);
// "Recurse" on the right side.
leftStack.push(pivotNewIndex + 1);
rightStack.push(right);
}
}
}
示例4: quicksortIndex
import edu.jhu.prim.list.IntStack; //导入依赖的package包/类
private static void quicksortIndex(long[] array, double[] values, int left, int right, boolean asc) {
IntStack leftStack = new IntStack();
IntStack rightStack = new IntStack();
leftStack.add(left);
rightStack.add(right);
while (leftStack.size() > 0) {
left = leftStack.pop();
right = rightStack.pop();
if (left < right) {
// Choose a pivot index.
// --> Here we choose the rightmost element which does the least
// amount of work if the array is already sorted.
int pivotIndex = right;
// Partition the array so that everything less than
// values[pivotIndex] is on the left of pivotNewIndex and everything
// greater than or equal is on the right.
int pivotNewIndex = partitionIndex(array, values, left, right, pivotIndex, asc);
// "Recurse" on the left side.
leftStack.push(left);
rightStack.push(pivotNewIndex - 1);
// "Recurse" on the right side.
leftStack.push(pivotNewIndex + 1);
rightStack.push(right);
}
}
}
示例5: quicksort
import edu.jhu.prim.list.IntStack; //导入依赖的package包/类
private static void quicksort(long[] array, int left, int right, boolean asc) {
IntStack leftStack = new IntStack();
IntStack rightStack = new IntStack();
leftStack.add(left);
rightStack.add(right);
while (leftStack.size() > 0) {
left = leftStack.pop();
right = rightStack.pop();
if (left < right) {
// Choose a pivot index.
// --> Here we choose the rightmost element which does the least
// amount of work if the array is already sorted.
int pivotIndex = right;
// Partition the array so that everything less than
// values[pivotIndex] is on the left of pivotNewIndex and everything
// greater than or equal is on the right.
int pivotNewIndex = partition(array, left, right, pivotIndex, asc);
// "Recurse" on the left side.
leftStack.push(left);
rightStack.push(pivotNewIndex - 1);
// "Recurse" on the right side.
leftStack.push(pivotNewIndex + 1);
rightStack.push(right);
}
}
}
示例6: quicksort
import edu.jhu.prim.list.IntStack; //导入依赖的package包/类
private static void quicksort(byte[] array, int left, int right, boolean asc) {
IntStack leftStack = new IntStack();
IntStack rightStack = new IntStack();
leftStack.add(left);
rightStack.add(right);
while (leftStack.size() > 0) {
left = leftStack.pop();
right = rightStack.pop();
if (left < right) {
// Choose a pivot index.
// --> Here we choose the rightmost element which does the least
// amount of work if the array is already sorted.
int pivotIndex = right;
// Partition the array so that everything less than
// values[pivotIndex] is on the left of pivotNewIndex and everything
// greater than or equal is on the right.
int pivotNewIndex = partition(array, left, right, pivotIndex, asc);
// "Recurse" on the left side.
leftStack.push(left);
rightStack.push(pivotNewIndex - 1);
// "Recurse" on the right side.
leftStack.push(pivotNewIndex + 1);
rightStack.push(right);
}
}
}
示例7: quicksortValues
import edu.jhu.prim.list.IntStack; //导入依赖的package包/类
private static void quicksortValues(double[] array, int[] index, int left, int right, boolean asc) {
IntStack leftStack = new IntStack();
IntStack rightStack = new IntStack();
leftStack.add(left);
rightStack.add(right);
while (leftStack.size() > 0) {
left = leftStack.pop();
right = rightStack.pop();
if (left < right) {
// Choose a pivot index.
// --> Here we choose the rightmost element which does the least
// amount of work if the array is already sorted.
int pivotIndex = right;
// Partition the array so that everything less than
// values[pivotIndex] is on the left of pivotNewIndex and everything
// greater than or equal is on the right.
int pivotNewIndex = partitionValues(array, index, left, right, pivotIndex, asc);
// "Recurse" on the left side.
leftStack.push(left);
rightStack.push(pivotNewIndex - 1);
// "Recurse" on the right side.
leftStack.push(pivotNewIndex + 1);
rightStack.push(right);
}
}
}
示例8: quicksortIndex
import edu.jhu.prim.list.IntStack; //导入依赖的package包/类
private static void quicksortIndex(int[] array, double[] values, int left, int right, boolean asc) {
IntStack leftStack = new IntStack();
IntStack rightStack = new IntStack();
leftStack.add(left);
rightStack.add(right);
while (leftStack.size() > 0) {
left = leftStack.pop();
right = rightStack.pop();
if (left < right) {
// Choose a pivot index.
// --> Here we choose the rightmost element which does the least
// amount of work if the array is already sorted.
int pivotIndex = right;
// Partition the array so that everything less than
// values[pivotIndex] is on the left of pivotNewIndex and everything
// greater than or equal is on the right.
int pivotNewIndex = partitionIndex(array, values, left, right, pivotIndex, asc);
// "Recurse" on the left side.
leftStack.push(left);
rightStack.push(pivotNewIndex - 1);
// "Recurse" on the right side.
leftStack.push(pivotNewIndex + 1);
rightStack.push(right);
}
}
}
示例9: quicksort
import edu.jhu.prim.list.IntStack; //导入依赖的package包/类
private static void quicksort(float[] array, int left, int right, boolean asc) {
IntStack leftStack = new IntStack();
IntStack rightStack = new IntStack();
leftStack.add(left);
rightStack.add(right);
while (leftStack.size() > 0) {
left = leftStack.pop();
right = rightStack.pop();
if (left < right) {
// Choose a pivot index.
// --> Here we choose the rightmost element which does the least
// amount of work if the array is already sorted.
int pivotIndex = right;
// Partition the array so that everything less than
// values[pivotIndex] is on the left of pivotNewIndex and everything
// greater than or equal is on the right.
int pivotNewIndex = partition(array, left, right, pivotIndex, asc);
// "Recurse" on the left side.
leftStack.push(left);
rightStack.push(pivotNewIndex - 1);
// "Recurse" on the right side.
leftStack.push(pivotNewIndex + 1);
rightStack.push(right);
}
}
}
示例10: quicksortValues
import edu.jhu.prim.list.IntStack; //导入依赖的package包/类
private static void quicksortValues(int[] array, long[] index, int left, int right, boolean asc) {
IntStack leftStack = new IntStack();
IntStack rightStack = new IntStack();
leftStack.add(left);
rightStack.add(right);
while (leftStack.size() > 0) {
left = leftStack.pop();
right = rightStack.pop();
if (left < right) {
// Choose a pivot index.
// --> Here we choose the rightmost element which does the least
// amount of work if the array is already sorted.
int pivotIndex = right;
// Partition the array so that everything less than
// values[pivotIndex] is on the left of pivotNewIndex and everything
// greater than or equal is on the right.
int pivotNewIndex = partitionValues(array, index, left, right, pivotIndex, asc);
// "Recurse" on the left side.
leftStack.push(left);
rightStack.push(pivotNewIndex - 1);
// "Recurse" on the right side.
leftStack.push(pivotNewIndex + 1);
rightStack.push(right);
}
}
}
示例11: quicksortIndex
import edu.jhu.prim.list.IntStack; //导入依赖的package包/类
private static void quicksortIndex(long[] array, int[] values, int left, int right, boolean asc) {
IntStack leftStack = new IntStack();
IntStack rightStack = new IntStack();
leftStack.add(left);
rightStack.add(right);
while (leftStack.size() > 0) {
left = leftStack.pop();
right = rightStack.pop();
if (left < right) {
// Choose a pivot index.
// --> Here we choose the rightmost element which does the least
// amount of work if the array is already sorted.
int pivotIndex = right;
// Partition the array so that everything less than
// values[pivotIndex] is on the left of pivotNewIndex and everything
// greater than or equal is on the right.
int pivotNewIndex = partitionIndex(array, values, left, right, pivotIndex, asc);
// "Recurse" on the left side.
leftStack.push(left);
rightStack.push(pivotNewIndex - 1);
// "Recurse" on the right side.
leftStack.push(pivotNewIndex + 1);
rightStack.push(right);
}
}
}
示例12: quicksortValues
import edu.jhu.prim.list.IntStack; //导入依赖的package包/类
private static void quicksortValues(int[] array, int[] index, int left, int right, boolean asc) {
IntStack leftStack = new IntStack();
IntStack rightStack = new IntStack();
leftStack.add(left);
rightStack.add(right);
while (leftStack.size() > 0) {
left = leftStack.pop();
right = rightStack.pop();
if (left < right) {
// Choose a pivot index.
// --> Here we choose the rightmost element which does the least
// amount of work if the array is already sorted.
int pivotIndex = right;
// Partition the array so that everything less than
// values[pivotIndex] is on the left of pivotNewIndex and everything
// greater than or equal is on the right.
int pivotNewIndex = partitionValues(array, index, left, right, pivotIndex, asc);
// "Recurse" on the left side.
leftStack.push(left);
rightStack.push(pivotNewIndex - 1);
// "Recurse" on the right side.
leftStack.push(pivotNewIndex + 1);
rightStack.push(right);
}
}
}
示例13: quicksortIndex
import edu.jhu.prim.list.IntStack; //导入依赖的package包/类
private static void quicksortIndex(int[] array, int[] values, int left, int right, boolean asc) {
IntStack leftStack = new IntStack();
IntStack rightStack = new IntStack();
leftStack.add(left);
rightStack.add(right);
while (leftStack.size() > 0) {
left = leftStack.pop();
right = rightStack.pop();
if (left < right) {
// Choose a pivot index.
// --> Here we choose the rightmost element which does the least
// amount of work if the array is already sorted.
int pivotIndex = right;
// Partition the array so that everything less than
// values[pivotIndex] is on the left of pivotNewIndex and everything
// greater than or equal is on the right.
int pivotNewIndex = partitionIndex(array, values, left, right, pivotIndex, asc);
// "Recurse" on the left side.
leftStack.push(left);
rightStack.push(pivotNewIndex - 1);
// "Recurse" on the right side.
leftStack.push(pivotNewIndex + 1);
rightStack.push(right);
}
}
}
示例14: quicksort
import edu.jhu.prim.list.IntStack; //导入依赖的package包/类
private static void quicksort(int[] array, int left, int right, boolean asc) {
IntStack leftStack = new IntStack();
IntStack rightStack = new IntStack();
leftStack.add(left);
rightStack.add(right);
while (leftStack.size() > 0) {
left = leftStack.pop();
right = rightStack.pop();
if (left < right) {
// Choose a pivot index.
// --> Here we choose the rightmost element which does the least
// amount of work if the array is already sorted.
int pivotIndex = right;
// Partition the array so that everything less than
// values[pivotIndex] is on the left of pivotNewIndex and everything
// greater than or equal is on the right.
int pivotNewIndex = partition(array, left, right, pivotIndex, asc);
// "Recurse" on the left side.
leftStack.push(left);
rightStack.push(pivotNewIndex - 1);
// "Recurse" on the right side.
leftStack.push(pivotNewIndex + 1);
rightStack.push(right);
}
}
}
示例15: quicksortValues
import edu.jhu.prim.list.IntStack; //导入依赖的package包/类
private static void quicksortValues(float[] array, int[] index, int left, int right, boolean asc) {
IntStack leftStack = new IntStack();
IntStack rightStack = new IntStack();
leftStack.add(left);
rightStack.add(right);
while (leftStack.size() > 0) {
left = leftStack.pop();
right = rightStack.pop();
if (left < right) {
// Choose a pivot index.
// --> Here we choose the rightmost element which does the least
// amount of work if the array is already sorted.
int pivotIndex = right;
// Partition the array so that everything less than
// values[pivotIndex] is on the left of pivotNewIndex and everything
// greater than or equal is on the right.
int pivotNewIndex = partitionValues(array, index, left, right, pivotIndex, asc);
// "Recurse" on the left side.
leftStack.push(left);
rightStack.push(pivotNewIndex - 1);
// "Recurse" on the right side.
leftStack.push(pivotNewIndex + 1);
rightStack.push(right);
}
}
}