someone12345
May 23rd, 2007, 06:05 PM
Pretty simple code that works as excepted with org.apache.lucene.search.ScoreDoc.PriorityQueue. LimeWire's BinaryQueue is faster (in most situations) but sorts in a non-comprehensible manner:
final int qMax = 10;
final int max = 10000000;
org.limewire.collection.BinaryHeap heap = new org.limewire.collection.BinaryHeap( qMax );
for( int i = 0; i < max; i++ )
{
heap.insert( new Integer( i ) );
}
while (!heap.isEmpty()) {
System.out.println(heap.extractMax());
}
Result:
LimeWire:
9999999
9999998
9999997
9999996
6
5
4
3
1
0
(BTW where's the "2" gone?)
This looks correct:
Lucene:
9999990 9999990.0
9999991 9999991.0
9999992 9999992.0
9999993 9999993.0
9999994 9999994.0
9999995 9999995.0
9999996 9999996.0
9999997 9999997.0
9999998 9999998.0
9999999 9999999.0
final int qMax = 10;
final int max = 10000000;
org.limewire.collection.BinaryHeap heap = new org.limewire.collection.BinaryHeap( qMax );
for( int i = 0; i < max; i++ )
{
heap.insert( new Integer( i ) );
}
while (!heap.isEmpty()) {
System.out.println(heap.extractMax());
}
Result:
LimeWire:
9999999
9999998
9999997
9999996
6
5
4
3
1
0
(BTW where's the "2" gone?)
This looks correct:
Lucene:
9999990 9999990.0
9999991 9999991.0
9999992 9999992.0
9999993 9999993.0
9999994 9999994.0
9999995 9999995.0
9999996 9999996.0
9999997 9999997.0
9999998 9999998.0
9999999 9999999.0