diff --git a/CHANGES.txt b/CHANGES.txt index efa7d984b2d..de63ab6c505 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -39,6 +39,8 @@ API Changes * LUCENE-1961: Remove remaining deprecations from document package. (Michael Busch) +* LUCENE-1968: Remove deprecated methods in PriorityQueue. (Michael Busch) + Bug fixes * LUCENE-1951: When the text provided to WildcardQuery has no wildcard diff --git a/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/utils/QualityQueriesFinder.java b/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/utils/QualityQueriesFinder.java index 2100fa7eb9d..5c879712728 100755 --- a/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/utils/QualityQueriesFinder.java +++ b/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/utils/QualityQueriesFinder.java @@ -84,7 +84,7 @@ public class QualityQueriesFinder { } private String [] bestTerms(String field,int numTerms) throws IOException { - PriorityQueue pq = new TermsDfQueue(numTerms); + PriorityQueue pq = new TermsDfQueue(numTerms); IndexReader ir = IndexReader.open(dir, true); try { int threshold = ir.maxDoc() / 10; // ignore words too common. @@ -96,7 +96,7 @@ public class QualityQueriesFinder { int df = terms.docFreq(); if (df { TermsDfQueue (int maxSize) { initialize(maxSize); } - protected boolean lessThan(Object a, Object b) { - TermDf tf1 = (TermDf) a; - TermDf tf2 = (TermDf) b; + protected boolean lessThan(TermDf tf1, TermDf tf2) { return tf1.df < tf2.df; } } diff --git a/contrib/misc/src/java/org/apache/lucene/misc/HighFreqTerms.java b/contrib/misc/src/java/org/apache/lucene/misc/HighFreqTerms.java index 596034521f9..e5e3b21a370 100644 --- a/contrib/misc/src/java/org/apache/lucene/misc/HighFreqTerms.java +++ b/contrib/misc/src/java/org/apache/lucene/misc/HighFreqTerms.java @@ -55,13 +55,13 @@ public class HighFreqTerms { if (field != null) { while (terms.next()) { if (terms.term().field().equals(field)) { - tiq.insert(new TermInfo(terms.term(), terms.docFreq())); + tiq.insertWithOverflow(new TermInfo(terms.term(), terms.docFreq())); } } } else { while (terms.next()) { - tiq.insert(new TermInfo(terms.term(), terms.docFreq())); + tiq.insertWithOverflow(new TermInfo(terms.term(), terms.docFreq())); } } while (tiq.size() != 0) { @@ -88,13 +88,11 @@ final class TermInfo { Term term; } -final class TermInfoQueue extends PriorityQueue { +final class TermInfoQueue extends PriorityQueue { TermInfoQueue(int size) { initialize(size); } - protected final boolean lessThan(Object a, Object b) { - TermInfo termInfoA = (TermInfo) a; - TermInfo termInfoB = (TermInfo) b; + protected final boolean lessThan(TermInfo termInfoA, TermInfo termInfoB) { return termInfoA.docFreq < termInfoB.docFreq; } } diff --git a/contrib/queries/src/java/org/apache/lucene/search/FuzzyLikeThisQuery.java b/contrib/queries/src/java/org/apache/lucene/search/FuzzyLikeThisQuery.java index 37a937d6265..a7aa8081fef 100644 --- a/contrib/queries/src/java/org/apache/lucene/search/FuzzyLikeThisQuery.java +++ b/contrib/queries/src/java/org/apache/lucene/search/FuzzyLikeThisQuery.java @@ -215,7 +215,7 @@ public class FuzzyLikeThisQuery extends Query float score=fe.difference(); if(variantsQ.size() < MAX_VARIANTS_PER_TERM || score > minScore){ ScoreTerm st=new ScoreTerm(possibleMatch,score,startTerm); - variantsQ.insert(st); + variantsQ.insertWithOverflow(st); minScore = ((ScoreTerm)variantsQ.top()).score; // maintain minScore } } @@ -237,7 +237,7 @@ public class FuzzyLikeThisQuery extends Query { ScoreTerm st = (ScoreTerm) variantsQ.pop(); st.score=(st.score*st.score)*sim.idf(df,corpusNumDocs); - q.insert(st); + q.insertWithOverflow(st); } } } @@ -326,7 +326,7 @@ public class FuzzyLikeThisQuery extends Query } } - private static class ScoreTermQueue extends PriorityQueue { + private static class ScoreTermQueue extends PriorityQueue { public ScoreTermQueue(int size){ initialize(size); } @@ -334,9 +334,7 @@ public class FuzzyLikeThisQuery extends Query /* (non-Javadoc) * @see org.apache.lucene.util.PriorityQueue#lessThan(java.lang.Object, java.lang.Object) */ - protected boolean lessThan(Object a, Object b) { - ScoreTerm termA = (ScoreTerm)a; - ScoreTerm termB = (ScoreTerm)b; + protected boolean lessThan(ScoreTerm termA, ScoreTerm termB) { if (termA.score== termB.score) return termA.term.compareTo(termB.term) > 0; else diff --git a/contrib/queries/src/java/org/apache/lucene/search/similar/MoreLikeThis.java b/contrib/queries/src/java/org/apache/lucene/search/similar/MoreLikeThis.java index 8983f659435..2abe0cfaa65 100644 --- a/contrib/queries/src/java/org/apache/lucene/search/similar/MoreLikeThis.java +++ b/contrib/queries/src/java/org/apache/lucene/search/similar/MoreLikeThis.java @@ -668,7 +668,7 @@ public final class MoreLikeThis { float score = tf * idf; // only really need 1st 3 entries, other ones are for troubleshooting - res.insert(new Object[]{word, // the word + res.insertWithOverflow(new Object[]{word, // the word topField, // the top field Float.valueOf(score), // overall score Float.valueOf(idf), // idf @@ -953,14 +953,12 @@ public final class MoreLikeThis { /** * PriorityQueue that orders words by score. */ - private static class FreqQ extends PriorityQueue { + private static class FreqQ extends PriorityQueue { FreqQ (int s) { initialize(s); } - protected boolean lessThan(Object a, Object b) { - Object[] aa = (Object[]) a; - Object[] bb = (Object[]) b; + protected boolean lessThan(Object[] aa, Object[] bb) { Float fa = (Float) aa[2]; Float fb = (Float) bb[2]; return fa.floatValue() > fb.floatValue(); diff --git a/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java b/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java index b5bb7a2233d..0fc93dfc224 100755 --- a/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java +++ b/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java @@ -246,7 +246,7 @@ public class SpellChecker { continue; } } - sugQueue.insert(sugWord); + sugQueue.insertWithOverflow(sugWord); if (sugQueue.size() == numSug) { // if queue full, maintain the minScore score min = ((SuggestWord) sugQueue.top()).score; diff --git a/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SuggestWordQueue.java b/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SuggestWordQueue.java index fc78a9eae75..5870f4bcbbb 100755 --- a/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SuggestWordQueue.java +++ b/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SuggestWordQueue.java @@ -25,15 +25,13 @@ import org.apache.lucene.util.PriorityQueue; * Sorts SuggestWord instances * */ -final class SuggestWordQueue extends PriorityQueue { +final class SuggestWordQueue extends PriorityQueue { SuggestWordQueue (int size) { initialize(size); } - protected final boolean lessThan (Object a, Object b) { - SuggestWord wa = (SuggestWord) a; - SuggestWord wb = (SuggestWord) b; + protected final boolean lessThan (SuggestWord wa, SuggestWord wb) { int val = wa.compareTo(wb); return val < 0; } diff --git a/src/java/org/apache/lucene/index/DirectoryReader.java b/src/java/org/apache/lucene/index/DirectoryReader.java index 60a3967aa04..13fb1622a39 100644 --- a/src/java/org/apache/lucene/index/DirectoryReader.java +++ b/src/java/org/apache/lucene/index/DirectoryReader.java @@ -980,7 +980,7 @@ class DirectoryReader extends IndexReader implements Cloneable { SegmentMergeInfo smi = new SegmentMergeInfo(starts[i], termEnum, reader); smi.ord = i; if (t == null ? smi.next() : termEnum.term() != null) - queue.put(smi); // initialize queue + queue.add(smi); // initialize queue else smi.close(); } @@ -995,7 +995,7 @@ class DirectoryReader extends IndexReader implements Cloneable { SegmentMergeInfo smi = matchingSegments[i]; if (smi==null) break; if (smi.next()) - queue.put(smi); + queue.add(smi); else smi.close(); // done with segment } diff --git a/src/java/org/apache/lucene/index/MultipleTermPositions.java b/src/java/org/apache/lucene/index/MultipleTermPositions.java index 168e09ef48a..ca68af210f8 100644 --- a/src/java/org/apache/lucene/index/MultipleTermPositions.java +++ b/src/java/org/apache/lucene/index/MultipleTermPositions.java @@ -32,7 +32,7 @@ import java.util.List; */ public class MultipleTermPositions implements TermPositions { - private static final class TermPositionsQueue extends PriorityQueue { + private static final class TermPositionsQueue extends PriorityQueue { TermPositionsQueue(List termPositions) throws IOException { initialize(termPositions.size()); @@ -40,7 +40,7 @@ public class MultipleTermPositions implements TermPositions { while (i.hasNext()) { TermPositions tp = (TermPositions) i.next(); if (tp.next()) - put(tp); + add(tp); } } @@ -48,8 +48,8 @@ public class MultipleTermPositions implements TermPositions { return (TermPositions) top(); } - public final boolean lessThan(Object a, Object b) { - return ((TermPositions) a).doc() < ((TermPositions) b).doc(); + public final boolean lessThan(TermPositions a, TermPositions b) { + return a.doc() < b.doc(); } } @@ -126,7 +126,7 @@ public class MultipleTermPositions implements TermPositions { _posList.add(tp.nextPosition()); if (tp.next()) - _termPositionsQueue.adjustTop(); + _termPositionsQueue.updateTop(); else { _termPositionsQueue.pop(); tp.close(); @@ -147,7 +147,7 @@ public class MultipleTermPositions implements TermPositions { while (_termPositionsQueue.peek() != null && target > _termPositionsQueue.peek().doc()) { TermPositions tp = (TermPositions) _termPositionsQueue.pop(); if (tp.skipTo(target)) - _termPositionsQueue.put(tp); + _termPositionsQueue.add(tp); else tp.close(); } diff --git a/src/java/org/apache/lucene/index/SegmentMergeQueue.java b/src/java/org/apache/lucene/index/SegmentMergeQueue.java index ea13194603f..264e91deace 100644 --- a/src/java/org/apache/lucene/index/SegmentMergeQueue.java +++ b/src/java/org/apache/lucene/index/SegmentMergeQueue.java @@ -20,14 +20,12 @@ package org.apache.lucene.index; import java.io.IOException; import org.apache.lucene.util.PriorityQueue; -final class SegmentMergeQueue extends PriorityQueue { +final class SegmentMergeQueue extends PriorityQueue { SegmentMergeQueue(int size) { initialize(size); } - protected final boolean lessThan(Object a, Object b) { - SegmentMergeInfo stiA = (SegmentMergeInfo)a; - SegmentMergeInfo stiB = (SegmentMergeInfo)b; + protected final boolean lessThan(SegmentMergeInfo stiA, SegmentMergeInfo stiB) { int comparison = stiA.term.compareTo(stiB.term); if (comparison == 0) return stiA.base < stiB.base; diff --git a/src/java/org/apache/lucene/search/ExactPhraseScorer.java b/src/java/org/apache/lucene/search/ExactPhraseScorer.java index 843c9db49bd..04e3ffa6ebf 100644 --- a/src/java/org/apache/lucene/search/ExactPhraseScorer.java +++ b/src/java/org/apache/lucene/search/ExactPhraseScorer.java @@ -32,7 +32,7 @@ final class ExactPhraseScorer extends PhraseScorer { pq.clear(); for (PhrasePositions pp = first; pp != null; pp = pp.next) { pp.firstPosition(); - pq.put(pp); // build pq from list + pq.add(pp); // build pq from list } pqToList(); // rebuild list from pq diff --git a/src/java/org/apache/lucene/search/FieldDocSortedHitQueue.java b/src/java/org/apache/lucene/search/FieldDocSortedHitQueue.java index 16157a91686..d171af8861a 100644 --- a/src/java/org/apache/lucene/search/FieldDocSortedHitQueue.java +++ b/src/java/org/apache/lucene/search/FieldDocSortedHitQueue.java @@ -31,7 +31,7 @@ import java.util.Locale; * @since lucene 1.4 */ class FieldDocSortedHitQueue -extends PriorityQueue { +extends PriorityQueue { // this cannot contain AUTO fields - any AUTO fields should // have been resolved by the time this class is used. @@ -99,9 +99,7 @@ extends PriorityQueue { * @param b ScoreDoc * @return true if document a should be sorted after document b. */ - protected final boolean lessThan (final Object a, final Object b) { - final FieldDoc docA = (FieldDoc) a; - final FieldDoc docB = (FieldDoc) b; + protected final boolean lessThan (final FieldDoc docA, final FieldDoc docB) { final int n = fields.length; int c = 0; for (int i=0; i { private boolean prePopulate; @@ -68,16 +68,14 @@ final class HitQueue extends PriorityQueue { } // Returns null if prePopulate is false. - protected Object getSentinelObject() { + protected ScoreDoc getSentinelObject() { // Always set the doc Id to MAX_VALUE so that it won't be favored by // lessThan. This generally should not happen since if score is not NEG_INF, // TopScoreDocCollector will always add the object to the queue. return !prePopulate ? null : new ScoreDoc(Integer.MAX_VALUE, Float.NEGATIVE_INFINITY); } - protected final boolean lessThan(Object a, Object b) { - ScoreDoc hitA = (ScoreDoc)a; - ScoreDoc hitB = (ScoreDoc)b; + protected final boolean lessThan(ScoreDoc hitA, ScoreDoc hitB) { if (hitA.score == hitB.score) return hitA.doc > hitB.doc; else diff --git a/src/java/org/apache/lucene/search/MultiSearcher.java b/src/java/org/apache/lucene/search/MultiSearcher.java index c25413c5cb3..d7688264907 100644 --- a/src/java/org/apache/lucene/search/MultiSearcher.java +++ b/src/java/org/apache/lucene/search/MultiSearcher.java @@ -191,7 +191,7 @@ public class MultiSearcher extends Searcher { for (int j = 0; j < scoreDocs.length; j++) { // merge scoreDocs into hq ScoreDoc scoreDoc = scoreDocs[j]; scoreDoc.doc += starts[i]; // convert doc - if(!hq.insert(scoreDoc)) + if(scoreDoc == hq.insertWithOverflow(scoreDoc)) break; // no more scores > minScore } } @@ -234,7 +234,7 @@ public class MultiSearcher extends Searcher { for (int j = 0; j < scoreDocs.length; j++) { // merge scoreDocs into hq ScoreDoc scoreDoc = scoreDocs[j]; scoreDoc.doc += starts[i]; // convert doc - if (!hq.insert (scoreDoc)) + if (scoreDoc == hq.insertWithOverflow((FieldDoc) scoreDoc)) break; // no more scores > minScore } } diff --git a/src/java/org/apache/lucene/search/ParallelMultiSearcher.java b/src/java/org/apache/lucene/search/ParallelMultiSearcher.java index aa4dc3665ff..41f4ec0b36c 100644 --- a/src/java/org/apache/lucene/search/ParallelMultiSearcher.java +++ b/src/java/org/apache/lucene/search/ParallelMultiSearcher.java @@ -269,7 +269,7 @@ class MultiSearcherThread extends Thread { scoreDoc.doc += starts[i]; // convert doc //it would be so nice if we had a thread-safe insert synchronized (hq) { - if (!hq.insert(scoreDoc)) + if (scoreDoc == hq.insertWithOverflow(scoreDoc)) break; } // no more scores > minScore } diff --git a/src/java/org/apache/lucene/search/PhraseQueue.java b/src/java/org/apache/lucene/search/PhraseQueue.java index e9392b3fcd5..5dcc9bf309c 100644 --- a/src/java/org/apache/lucene/search/PhraseQueue.java +++ b/src/java/org/apache/lucene/search/PhraseQueue.java @@ -19,14 +19,12 @@ package org.apache.lucene.search; import org.apache.lucene.util.PriorityQueue; -final class PhraseQueue extends PriorityQueue { +final class PhraseQueue extends PriorityQueue { PhraseQueue(int size) { initialize(size); } - protected final boolean lessThan(Object o1, Object o2) { - PhrasePositions pp1 = (PhrasePositions)o1; - PhrasePositions pp2 = (PhrasePositions)o2; + protected final boolean lessThan(PhrasePositions pp1, PhrasePositions pp2) { if (pp1.doc == pp2.doc) if (pp1.position == pp2.position) // same doc and pp.position, so decide by actual term positions. diff --git a/src/java/org/apache/lucene/search/SloppyPhraseScorer.java b/src/java/org/apache/lucene/search/SloppyPhraseScorer.java index 00410bba555..aa83fa2237a 100644 --- a/src/java/org/apache/lucene/search/SloppyPhraseScorer.java +++ b/src/java/org/apache/lucene/search/SloppyPhraseScorer.java @@ -83,7 +83,7 @@ final class SloppyPhraseScorer extends PhraseScorer { if (pp.position > end) end = pp.position; - pq.put(pp); // restore pq + pq.add(pp); // restore pq } return freq; @@ -101,10 +101,10 @@ final class SloppyPhraseScorer extends PhraseScorer { } //insert back all but pp2 for (n--; n>=0; n--) { - pq.insert(tmpPos[n]); + pq.insertWithOverflow(tmpPos[n]); } //insert pp back - pq.put(pp); + pq.add(pp); return pp2; } @@ -133,7 +133,7 @@ final class SloppyPhraseScorer extends PhraseScorer { pp.firstPosition(); if (pp.position > end) end = pp.position; - pq.put(pp); // build pq from list + pq.add(pp); // build pq from list } return end; } @@ -182,7 +182,7 @@ final class SloppyPhraseScorer extends PhraseScorer { for (PhrasePositions pp = first; pp != null; pp = pp.next) { if (pp.position > end) end = pp.position; - pq.put(pp); // build pq from list + pq.add(pp); // build pq from list } if (repeats!=null) { diff --git a/src/java/org/apache/lucene/search/spans/NearSpansUnordered.java b/src/java/org/apache/lucene/search/spans/NearSpansUnordered.java index 0114e5d4295..8362846c25b 100644 --- a/src/java/org/apache/lucene/search/spans/NearSpansUnordered.java +++ b/src/java/org/apache/lucene/search/spans/NearSpansUnordered.java @@ -51,14 +51,12 @@ public class NearSpansUnordered extends Spans { private boolean more = true; // true iff not done private boolean firstTime = true; // true before first next() - private class CellQueue extends PriorityQueue { + private class CellQueue extends PriorityQueue { public CellQueue(int size) { initialize(size); } - protected final boolean lessThan(Object o1, Object o2) { - SpansCell spans1 = (SpansCell)o1; - SpansCell spans2 = (SpansCell)o2; + protected final boolean lessThan(SpansCell spans1, SpansCell spans2) { if (spans1.doc() == spans2.doc()) { return NearSpansOrdered.docSpansOrdered(spans1, spans2); } else { @@ -147,7 +145,7 @@ public class NearSpansUnordered extends Spans { firstTime = false; } else if (more) { if (min().next()) { // trigger further scanning - queue.adjustTop(); // maintain queue + queue.updateTop(); // maintain queue } else { more = false; } @@ -185,7 +183,7 @@ public class NearSpansUnordered extends Spans { more = min().next(); if (more) { - queue.adjustTop(); // maintain queue + queue.updateTop(); // maintain queue } } return false; // no more matches @@ -204,7 +202,7 @@ public class NearSpansUnordered extends Spans { } else { // normal case while (more && min().doc() < target) { // skip as needed if (min().skipTo(target)) { - queue.adjustTop(); + queue.updateTop(); } else { more = false; } @@ -290,7 +288,7 @@ public class NearSpansUnordered extends Spans { private void listToQueue() { queue.clear(); // rebuild queue for (SpansCell cell = first; cell != null; cell = cell.next) { - queue.put(cell); // add to queue from list + queue.add(cell); // add to queue from list } } diff --git a/src/java/org/apache/lucene/search/spans/SpanOrQuery.java b/src/java/org/apache/lucene/search/spans/SpanOrQuery.java index a2e5996280a..c65d261e998 100644 --- a/src/java/org/apache/lucene/search/spans/SpanOrQuery.java +++ b/src/java/org/apache/lucene/search/spans/SpanOrQuery.java @@ -181,7 +181,7 @@ public class SpanOrQuery extends SpanQuery implements Cloneable { Spans spans = ((SpanQuery)i.next()).getSpans(reader); if ( ((target == -1) && spans.next()) || ((target != -1) && spans.skipTo(target))) { - queue.put(spans); + queue.add(spans); } } return queue.size() != 0; @@ -197,7 +197,7 @@ public class SpanOrQuery extends SpanQuery implements Cloneable { } if (top().next()) { // move to next - queue.adjustTop(); + queue.updateTop(); return true; } @@ -215,7 +215,7 @@ public class SpanOrQuery extends SpanQuery implements Cloneable { boolean skipCalled = false; while (queue.size() != 0 && top().doc() < target) { if (top().skipTo(target)) { - queue.adjustTop(); + queue.updateTop(); } else { queue.pop(); } @@ -232,7 +232,6 @@ public class SpanOrQuery extends SpanQuery implements Cloneable { public int start() { return top().start(); } public int end() { return top().end(); } - // TODO: Remove warning after API has been finalized public Collection/**/ getPayload() throws IOException { ArrayList result = null; Spans theTop = top(); @@ -242,7 +241,6 @@ public class SpanOrQuery extends SpanQuery implements Cloneable { return result; } - // TODO: Remove warning after API has been finalized public boolean isPayloadAvailable() { Spans top = top(); return top != null && top.isPayloadAvailable(); diff --git a/src/java/org/apache/lucene/util/PriorityQueue.java b/src/java/org/apache/lucene/util/PriorityQueue.java index aaa816097fe..288f739cbea 100644 --- a/src/java/org/apache/lucene/util/PriorityQueue.java +++ b/src/java/org/apache/lucene/util/PriorityQueue.java @@ -101,20 +101,6 @@ public abstract class PriorityQueue { } } - /** - * Adds an Object to a PriorityQueue in log(size) time. If one tries to add - * more objects than maxSize from initialize a RuntimeException - * (ArrayIndexOutOfBound) is thrown. - * - * @deprecated use {@link #add(T)} which returns the new top object, - * saving an additional call to {@link #top()}. - */ - public final void put(T element) { - size++; - heap[size] = element; - upHeap(); - } - /** * Adds an Object to a PriorityQueue in log(size) time. If one tries to add * more objects than maxSize from initialize an @@ -129,19 +115,6 @@ public abstract class PriorityQueue { return heap[1]; } - /** - * Adds element to the PriorityQueue in log(size) time if either the - * PriorityQueue is not full, or not lessThan(element, top()). - * - * @param element - * @return true if element is added, false otherwise. - * @deprecated use {@link #insertWithOverflow(T)} instead, which - * encourages objects reuse. - */ - public boolean insert(T element) { - return insertWithOverflow(element) != element; - } - /** * insertWithOverflow() is the same as insert() except its * return value: it returns the object (if any) that was @@ -154,12 +127,12 @@ public abstract class PriorityQueue { */ public T insertWithOverflow(T element) { if (size < maxSize) { - put(element); + add(element); return null; } else if (size > 0 && !lessThan(element, heap[1])) { T ret = heap[1]; heap[1] = element; - adjustTop(); + updateTop(); return ret; } else { return element; @@ -187,30 +160,6 @@ public abstract class PriorityQueue { } else return null; } - - /** - * Should be called when the Object at top changes values. Still log(n) worst - * case, but it's at least twice as fast to - * - *
-   * pq.top().change();
-   * pq.adjustTop();
-   * 
- * - * instead of - * - *
-   * o = pq.pop();
-   * o.change();
-   * pq.push(o);
-   * 
- * - * @deprecated use {@link #updateTop()} which returns the new top element and - * saves an additional call to {@link #top()}. - */ - public final void adjustTop() { - downHeap(); - } /** * Should be called when the Object at top changes values. Still log(n) worst diff --git a/src/test/org/apache/lucene/util/TestPriorityQueue.java b/src/test/org/apache/lucene/util/TestPriorityQueue.java index 5c81fc5abea..1e55b31a22d 100644 --- a/src/test/org/apache/lucene/util/TestPriorityQueue.java +++ b/src/test/org/apache/lucene/util/TestPriorityQueue.java @@ -47,7 +47,7 @@ public class TestPriorityQueue extends LuceneTestCase { { int next = gen.nextInt(); sum += next; - pq.put(next); + pq.add(next); } // Date end = new Date(); @@ -75,9 +75,9 @@ public class TestPriorityQueue extends LuceneTestCase { public void testClear() { PriorityQueue pq = new IntegerQueue(3); - pq.put(2); - pq.put(3); - pq.put(1); + pq.add(2); + pq.add(3); + pq.add(1); assertEquals(3, pq.size()); pq.clear(); assertEquals(0, pq.size()); @@ -85,12 +85,12 @@ public class TestPriorityQueue extends LuceneTestCase { public void testFixedSize() { PriorityQueue pq = new IntegerQueue(3); - pq.insert(2); - pq.insert(3); - pq.insert(1); - pq.insert(5); - pq.insert(7); - pq.insert(1); + pq.insertWithOverflow(2); + pq.insertWithOverflow(3); + pq.insertWithOverflow(1); + pq.insertWithOverflow(5); + pq.insertWithOverflow(7); + pq.insertWithOverflow(1); assertEquals(3, pq.size()); assertEquals((Integer) 3, pq.top()); }