本文整理了Java中org.apache.hadoop.util.HeapSort
类的一些代码示例,展示了HeapSort
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HeapSort
类的具体详情如下:
包路径:org.apache.hadoop.util.HeapSort
类名称:HeapSort
[英]An implementation of the core algorithm of HeapSort.
[中]HeapSort核心算法的实现。
代码示例来源:origin: org.apache.hadoop/hadoop-common
@Override
public void sort(final IndexedSortable s, final int p, final int r,
final Progressable rep) {
final int N = r - p;
// build heap w/ reverse comparator, then write in-place from end
final int t = Integer.highestOneBit(N);
for (int i = t; i > 1; i >>>= 1) {
for (int j = i >>> 1; j < i; ++j) {
downHeap(s, p-1, j, N + 1);
}
if (null != rep) {
rep.progress();
}
}
for (int i = r - 1; i > p; --i) {
s.swap(p, i);
downHeap(s, p - 1, 1, i - p + 1);
}
}
}
代码示例来源:origin: org.apache.hadoop/hadoop-common
/**
* Sort the given range of items using heap sort.
* {@inheritDoc}
*/
@Override
public void sort(IndexedSortable s, int p, int r) {
sort(s, p, r, null);
}
代码示例来源:origin: stackoverflow.com
new HeapSort ().sort(arr); // you must create an instance of the class that contains
// the sort method in order to call it
System.out.println(Arrays.toString(arr));
代码示例来源:origin: stackoverflow.com
HeapSort myHeapSortObject = new HeapSort();
myHeapSortObject.heapSort(vec);
代码示例来源:origin: org.apache.hadoop/hadoop-common-test
public void testHeapSort() throws Exception {
HeapSort sorter = new HeapSort();
sortRandom(sorter);
sortSingleRecord(sorter);
sortSequential(sorter);
sortSorted(sorter);
sortAllEqual(sorter);
sortWritable(sorter);
}
代码示例来源:origin: com.github.jiayuhan-it/hadoop-common
/**
* Sort the given range of items using heap sort.
* {@inheritDoc}
*/
@Override
public void sort(IndexedSortable s, int p, int r) {
sort(s, p, r, null);
}
代码示例来源:origin: io.prestosql.hadoop/hadoop-apache
@Override
public void sort(final IndexedSortable s, final int p, final int r,
final Progressable rep) {
final int N = r - p;
// build heap w/ reverse comparator, then write in-place from end
final int t = Integer.highestOneBit(N);
for (int i = t; i > 1; i >>>= 1) {
for (int j = i >>> 1; j < i; ++j) {
downHeap(s, p-1, j, N + 1);
}
if (null != rep) {
rep.progress();
}
}
for (int i = r - 1; i > p; --i) {
s.swap(p, i);
downHeap(s, p - 1, 1, i - p + 1);
}
}
}
代码示例来源:origin: ch.cern.hadoop/hadoop-common
public void testHeapSort() throws Exception {
HeapSort sorter = new HeapSort();
sortRandom(sorter);
sortSingleRecord(sorter);
sortSequential(sorter);
sortSorted(sorter);
sortAllEqual(sorter);
sortWritable(sorter);
}
代码示例来源:origin: ch.cern.hadoop/hadoop-common
/**
* Sort the given range of items using heap sort.
* {@inheritDoc}
*/
@Override
public void sort(IndexedSortable s, int p, int r) {
sort(s, p, r, null);
}
代码示例来源:origin: io.hops/hadoop-common
@Override
public void sort(final IndexedSortable s, final int p, final int r,
final Progressable rep) {
final int N = r - p;
// build heap w/ reverse comparator, then write in-place from end
final int t = Integer.highestOneBit(N);
for (int i = t; i > 1; i >>>= 1) {
for (int j = i >>> 1; j < i; ++j) {
downHeap(s, p-1, j, N + 1);
}
if (null != rep) {
rep.progress();
}
}
for (int i = r - 1; i > p; --i) {
s.swap(p, i);
downHeap(s, p - 1, 1, i - p + 1);
}
}
}
代码示例来源:origin: com.github.jiayuhan-it/hadoop-common
public void testHeapSort() throws Exception {
HeapSort sorter = new HeapSort();
sortRandom(sorter);
sortSingleRecord(sorter);
sortSequential(sorter);
sortSorted(sorter);
sortAllEqual(sorter);
sortWritable(sorter);
}
代码示例来源:origin: org.jvnet.hudson.hadoop/hadoop-core
/**
* Sort the given range of items using heap sort.
* {@inheritDoc}
*/
public void sort(IndexedSortable s, int p, int r) {
sort(s, p, r, null);
}
代码示例来源:origin: com.facebook.hadoop/hadoop-core
/**
* {@inheritDoc}
*/
public void sort(final IndexedSortable s, final int p, final int r,
final Progressable rep) {
final int N = r - p;
// build heap w/ reverse comparator, then write in-place from end
final int t = Integer.highestOneBit(N);
for (int i = t; i > 1; i >>>= 1) {
for (int j = i >>> 1; j < i; ++j) {
downHeap(s, p-1, j, N + 1);
}
if (null != rep) {
rep.progress();
}
}
for (int i = r - 1; i > p; --i) {
s.swap(p, i);
downHeap(s, p - 1, 1, i - p + 1);
}
}
}
代码示例来源:origin: io.prestosql.hadoop/hadoop-apache
/**
* Sort the given range of items using heap sort.
* {@inheritDoc}
*/
@Override
public void sort(IndexedSortable s, int p, int r) {
sort(s, p, r, null);
}
代码示例来源:origin: ch.cern.hadoop/hadoop-common
@Override
public void sort(final IndexedSortable s, final int p, final int r,
final Progressable rep) {
final int N = r - p;
// build heap w/ reverse comparator, then write in-place from end
final int t = Integer.highestOneBit(N);
for (int i = t; i > 1; i >>>= 1) {
for (int j = i >>> 1; j < i; ++j) {
downHeap(s, p-1, j, N + 1);
}
if (null != rep) {
rep.progress();
}
}
for (int i = r - 1; i > p; --i) {
s.swap(p, i);
downHeap(s, p - 1, 1, i - p + 1);
}
}
}
代码示例来源:origin: io.hops/hadoop-common
/**
* Sort the given range of items using heap sort.
* {@inheritDoc}
*/
@Override
public void sort(IndexedSortable s, int p, int r) {
sort(s, p, r, null);
}
代码示例来源:origin: com.github.jiayuhan-it/hadoop-common
@Override
public void sort(final IndexedSortable s, final int p, final int r,
final Progressable rep) {
final int N = r - p;
// build heap w/ reverse comparator, then write in-place from end
final int t = Integer.highestOneBit(N);
for (int i = t; i > 1; i >>>= 1) {
for (int j = i >>> 1; j < i; ++j) {
downHeap(s, p-1, j, N + 1);
}
if (null != rep) {
rep.progress();
}
}
for (int i = r - 1; i > p; --i) {
s.swap(p, i);
downHeap(s, p - 1, 1, i - p + 1);
}
}
}
代码示例来源:origin: com.facebook.hadoop/hadoop-core
/**
* Sort the given range of items using heap sort.
* {@inheritDoc}
*/
public void sort(IndexedSortable s, int p, int r) {
sort(s, p, r, null);
}
代码示例来源:origin: org.jvnet.hudson.hadoop/hadoop-core
/**
* {@inheritDoc}
*/
public void sort(final IndexedSortable s, final int p, final int r,
final Progressable rep) {
final int N = r - p;
// build heap w/ reverse comparator, then write in-place from end
final int t = Integer.highestOneBit(N);
for (int i = t; i > 1; i >>>= 1) {
for (int j = i >>> 1; j < i; ++j) {
downHeap(s, p-1, j, N + 1);
}
if (null != rep) {
rep.progress();
}
}
for (int i = r - 1; i > p; --i) {
s.swap(p, i);
downHeap(s, p - 1, 1, i - p + 1);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!