You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by sy...@apache.org on 2015/03/01 20:41:04 UTC
[1/5] lucenenet git commit: Added resizing functionality to the PQ.
This is needed to support usages in which the maximum size cannot be
predefined. Discarded a test which checked correct overflow. Added a test to
check resizing.
Repository: lucenenet
Updated Branches:
refs/heads/master 781e1c2cf -> bdf4ec7b0
Added resizing functionality to the PQ. This is needed to support usages in which the maximum size cannot be predefined. Discarded a test which checked correct overflow. Added a test to check resizing.
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/abce0d52
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/abce0d52
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/abce0d52
Branch: refs/heads/master
Commit: abce0d52410f20bcc89cdc3682669eb6ae289d19
Parents: f1a2b50
Author: Guido Tagliavini Ponce <t-...@microsoft.com>
Authored: Wed Feb 18 11:30:14 2015 -0800
Committer: Guido Tagliavini Ponce <t-...@microsoft.com>
Committed: Wed Feb 18 11:30:14 2015 -0800
----------------------------------------------------------------------
src/Lucene.Net.Core/Util/PriorityQueue.cs | 41 ++++++++++++++------
.../core/Util/TestPriorityQueue.cs | 38 ++++++++++++++++--
2 files changed, 64 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/abce0d52/src/Lucene.Net.Core/Util/PriorityQueue.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/PriorityQueue.cs b/src/Lucene.Net.Core/Util/PriorityQueue.cs
index 3938745..9b76121 100644
--- a/src/Lucene.Net.Core/Util/PriorityQueue.cs
+++ b/src/Lucene.Net.Core/Util/PriorityQueue.cs
@@ -28,7 +28,8 @@ namespace Lucene.Net.Util
/// <p><b>NOTE</b>: this class will pre-allocate a full array of
/// length <code>maxSize+1</code> if instantiated via the
/// <seealso cref="#PriorityQueue(int,boolean)"/> constructor with
- /// <code>prepopulate</code> set to <code>true</code>.
+ /// <code>prepopulate</code> set to <code>true</code>. That maximum
+ /// size can grow as we insert elements over the time.
///
/// @lucene.internal
/// </summary>
@@ -36,8 +37,13 @@ namespace Lucene.Net.Util
public abstract class PriorityQueue<T>
{
private int QueueSize = 0;
- private readonly int MaxSize;
- private readonly T[] Heap;
+ private int MaxSize;
+ private T[] Heap;
+
+ public PriorityQueue()
+ : this(0, false)
+ {
+ }
public PriorityQueue(int maxSize)
: this(maxSize, true)
@@ -56,7 +62,7 @@ namespace Lucene.Net.Util
if (0 == maxSize)
{
// We allocate 1 extra to avoid if statement in top()
- heapSize = 2;
+ maxSize++;
}
else
{
@@ -73,14 +79,12 @@ namespace Lucene.Net.Util
// Throw exception to prevent confusing OOME:
throw new System.ArgumentException("maxSize must be < " + ArrayUtil.MAX_ARRAY_LENGTH + "; got: " + maxSize);
}
- else
- {
- // NOTE: we add +1 because all access to heap is
- // 1-based not 0-based. heap[0] is unused.
- heapSize = maxSize + 1;
- }
}
}
+
+ // NOTE: we add +1 because all access to heap is
+ // 1-based not 0-based. heap[0] is unused.
+ heapSize = maxSize + 1;
// T is unbounded type, so this unchecked cast works always:
T[] h = new T[heapSize];
@@ -158,13 +162,17 @@ namespace Lucene.Net.Util
/// <summary>
/// Adds an Object to a PriorityQueue in log(size) time. If one tries to add
- /// more objects than maxSize from initialize an
- /// <seealso cref="IndexOutOfRangeException"/> is thrown.
+ /// more objects than maxSize from initialize and it is not possible to resize
+ /// the heap, an <seealso cref="IndexOutOfRangeException"/> is thrown.
/// </summary>
/// <returns> the new 'top' element in the queue. </returns>
public T Add(T element)
{
QueueSize++;
+ if (QueueSize > MaxSize)
+ {
+ Resize();
+ }
Heap[QueueSize] = element;
UpHeap();
return Heap[1];
@@ -274,6 +282,15 @@ namespace Lucene.Net.Util
QueueSize = 0;
}
+ private void Resize()
+ {
+ int newSize = Math.Min(ArrayUtil.MAX_ARRAY_LENGTH - 1, 2*MaxSize);
+ T[] newHeap = new T[newSize + 1];
+ Array.Copy(Heap, newHeap, MaxSize + 1);
+ MaxSize = newSize;
+ Heap = newHeap;
+ }
+
private void UpHeap()
{
int i = QueueSize;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/abce0d52/src/Lucene.Net.Tests/core/Util/TestPriorityQueue.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Util/TestPriorityQueue.cs b/src/Lucene.Net.Tests/core/Util/TestPriorityQueue.cs
index 0c94de5..eed8cc0 100644
--- a/src/Lucene.Net.Tests/core/Util/TestPriorityQueue.cs
+++ b/src/Lucene.Net.Tests/core/Util/TestPriorityQueue.cs
@@ -302,6 +302,8 @@ namespace Lucene.Net.Util
Assert.AreEqual(pq.Top().Field, 1);
}
+ /*
+ * With the resizing feature, this test has no longer sense.
[Test]
public static void TestOverflow()
{
@@ -338,6 +340,37 @@ namespace Lucene.Net.Util
{
}
}
+ */
+
+ [Test]
+ public static void TestResize()
+ {
+ // Initialize a queue with maximum size 4
+ PriorityQueue<int?> pq = new IntegerQueue(4);
+ pq.Add(3);
+ pq.Add(-2);
+ pq.Add(1);
+ pq.Add(-10);
+
+ Assert.AreEqual(pq.Size(), 4);
+
+ // Should resize the queue
+ pq.Add(7);
+
+ Assert.AreEqual(pq.Size(), 5);
+
+ pq.Add(10);
+ pq.Add(1);
+ pq.Add(5);
+
+ Assert.AreEqual(pq.Size(), 8);
+
+ // Should resize again
+ pq.Add(100);
+ pq.Add(16);
+
+ Assert.AreEqual(pq.Size(), 10);
+ }
[Test]
public virtual void TestClear()
@@ -494,9 +527,8 @@ namespace Lucene.Net.Util
[Test, Timeout(0)]
public static void TestStress()
{
- int atLeast = 10000000;
+ int atLeast = 1000000;
int maxSize = AtLeast(atLeast);
- int size;
PriorityQueue<int?> pq = new IntegerQueue(maxSize);
// Add a lot of elements
@@ -532,7 +564,7 @@ namespace Lucene.Net.Util
Assert.AreEqual(pq.Size(), 0);
// One last time
- for (int i = 0; i < 2 * maxSize; i++)
+ for (int i = 0; 2 * i < maxSize; i++)
{
pq.Add(Random().Next());
}
[2/5] lucenenet git commit: Added ToArray method to the PQ. Added
more tests to check resizing.
Posted by sy...@apache.org.
Added ToArray method to the PQ. Added more tests to check resizing.
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/bf98bcab
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/bf98bcab
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/bf98bcab
Branch: refs/heads/master
Commit: bf98bcabf991085f6cf35a62db12011e403769d1
Parents: abce0d5
Author: Guido Tagliavini Ponce <t-...@microsoft.com>
Authored: Wed Feb 18 12:01:33 2015 -0800
Committer: Guido Tagliavini Ponce <t-...@microsoft.com>
Committed: Wed Feb 18 12:01:33 2015 -0800
----------------------------------------------------------------------
src/Lucene.Net.Core/Util/PriorityQueue.cs | 7 +++++
.../core/Util/TestPriorityQueue.cs | 29 ++++++++++++++++++++
2 files changed, 36 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/bf98bcab/src/Lucene.Net.Core/Util/PriorityQueue.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/PriorityQueue.cs b/src/Lucene.Net.Core/Util/PriorityQueue.cs
index 9b76121..296cac6 100644
--- a/src/Lucene.Net.Core/Util/PriorityQueue.cs
+++ b/src/Lucene.Net.Core/Util/PriorityQueue.cs
@@ -282,6 +282,13 @@ namespace Lucene.Net.Util
QueueSize = 0;
}
+ public T[] ToArray()
+ {
+ T[] copy = new T[QueueSize];
+ Array.Copy(Heap, 1, copy, 0, QueueSize);
+ return copy;
+ }
+
private void Resize()
{
int newSize = Math.Min(ArrayUtil.MAX_ARRAY_LENGTH - 1, 2*MaxSize);
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/bf98bcab/src/Lucene.Net.Tests/core/Util/TestPriorityQueue.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Util/TestPriorityQueue.cs b/src/Lucene.Net.Tests/core/Util/TestPriorityQueue.cs
index eed8cc0..4f2f70e 100644
--- a/src/Lucene.Net.Tests/core/Util/TestPriorityQueue.cs
+++ b/src/Lucene.Net.Tests/core/Util/TestPriorityQueue.cs
@@ -373,6 +373,35 @@ namespace Lucene.Net.Util
}
[Test]
+ public static void TestIntegrityAfterResize()
+ {
+ // Tests that after a resize, the queue keeps working fine
+ PriorityQueue<int?> pq = new IntegerQueue(4);
+ pq.Add(3);
+ pq.Add(-2);
+ pq.Add(1);
+ pq.Add(-10);
+ pq.Add(-100); // Resize
+ Assert.AreEqual(pq.Top(), -100);
+
+ pq.Add(-1000);
+ Assert.AreEqual(pq.Top(), -1000);
+
+ pq.Pop();
+ Assert.AreEqual(pq.Top(), -100);
+
+ pq.Add(0);
+ Assert.AreEqual(pq.Top(), -100);
+
+ for(int i = 0; i < 100; i++)
+ {
+ pq.Add(5); // Lots of resizes
+ }
+
+ Assert.AreEqual(pq.Top(), -100);
+ }
+
+ [Test]
public virtual void TestClear()
{
PriorityQueue<int?> pq = new IntegerQueue(3);
[4/5] lucenenet git commit: The queue is resizable only when
constructed with no parameters.
Posted by sy...@apache.org.
The queue is resizable only when constructed with no parameters.
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/ee021b68
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/ee021b68
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/ee021b68
Branch: refs/heads/master
Commit: ee021b683284db8aed81c015b572c5cd4b20d9bb
Parents: 9428451
Author: Guido Tagliavini Ponce <t-...@microsoft.com>
Authored: Mon Feb 23 10:14:09 2015 -0800
Committer: Guido Tagliavini Ponce <t-...@microsoft.com>
Committed: Mon Feb 23 10:14:09 2015 -0800
----------------------------------------------------------------------
src/Lucene.Net.Core/Util/PriorityQueue.cs | 11 ++--
.../core/Util/TestPriorityQueue.cs | 55 ++++++++++++--------
2 files changed, 40 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ee021b68/src/Lucene.Net.Core/Util/PriorityQueue.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/PriorityQueue.cs b/src/Lucene.Net.Core/Util/PriorityQueue.cs
index 296cac6..83e60a4 100644
--- a/src/Lucene.Net.Core/Util/PriorityQueue.cs
+++ b/src/Lucene.Net.Core/Util/PriorityQueue.cs
@@ -39,10 +39,12 @@ namespace Lucene.Net.Util
private int QueueSize = 0;
private int MaxSize;
private T[] Heap;
+ private bool resizable;
public PriorityQueue()
- : this(0, false)
+ : this(8, false)
{
+ resizable = true;
}
public PriorityQueue(int maxSize)
@@ -52,7 +54,8 @@ namespace Lucene.Net.Util
public PriorityQueue(int maxSize, bool prepopulate)
{
- int heapSize;
+ resizable = false;
+
if (maxSize < 0)
{
throw new System.ArgumentException("maxSize must be >= 0; got: " + maxSize);
@@ -84,7 +87,7 @@ namespace Lucene.Net.Util
// NOTE: we add +1 because all access to heap is
// 1-based not 0-based. heap[0] is unused.
- heapSize = maxSize + 1;
+ int heapSize = maxSize + 1;
// T is unbounded type, so this unchecked cast works always:
T[] h = new T[heapSize];
@@ -169,7 +172,7 @@ namespace Lucene.Net.Util
public T Add(T element)
{
QueueSize++;
- if (QueueSize > MaxSize)
+ if (resizable && QueueSize > MaxSize)
{
Resize();
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ee021b68/src/Lucene.Net.Tests/core/Util/TestPriorityQueue.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Util/TestPriorityQueue.cs b/src/Lucene.Net.Tests/core/Util/TestPriorityQueue.cs
index 4f2f70e..441e49e 100644
--- a/src/Lucene.Net.Tests/core/Util/TestPriorityQueue.cs
+++ b/src/Lucene.Net.Tests/core/Util/TestPriorityQueue.cs
@@ -30,6 +30,11 @@ namespace Lucene.Net.Util
private class IntegerQueue : PriorityQueue<int?>
{
+ public IntegerQueue()
+ : base()
+ {
+ }
+
public IntegerQueue(int count)
: base(count)
{
@@ -302,8 +307,6 @@ namespace Lucene.Net.Util
Assert.AreEqual(pq.Top().Field, 1);
}
- /*
- * With the resizing feature, this test has no longer sense.
[Test]
public static void TestOverflow()
{
@@ -340,65 +343,74 @@ namespace Lucene.Net.Util
{
}
}
- */
[Test]
public static void TestResize()
{
- // Initialize a queue with maximum size 4
- PriorityQueue<int?> pq = new IntegerQueue(4);
+ // Initialize a resizable queue
+ PriorityQueue<int?> pq = new IntegerQueue();
pq.Add(3);
pq.Add(-2);
pq.Add(1);
pq.Add(-10);
-
Assert.AreEqual(pq.Size(), 4);
- // Should resize the queue
pq.Add(7);
-
- Assert.AreEqual(pq.Size(), 5);
+ pq.Add(5);
+ pq.Add(10);
+ pq.Add(1);
+ Assert.AreEqual(pq.Size(), 8);
pq.Add(10);
pq.Add(1);
pq.Add(5);
+ Assert.AreEqual(pq.Size(), 11);
- Assert.AreEqual(pq.Size(), 8);
-
- // Should resize again
- pq.Add(100);
+ pq.Add(12);
+ pq.Add(13);
+ pq.Add(14);
+ pq.Add(15);
pq.Add(16);
+ Assert.AreEqual(pq.Size(), 16);
- Assert.AreEqual(pq.Size(), 10);
+ pq.Add(-17);
+ pq.Add(-18);
+ Assert.AreEqual(pq.Size(), 18);
}
[Test]
public static void TestIntegrityAfterResize()
{
// Tests that after a resize, the queue keeps working fine
- PriorityQueue<int?> pq = new IntegerQueue(4);
+ PriorityQueue<int?> pq = new IntegerQueue();
pq.Add(3);
pq.Add(-2);
pq.Add(1);
+ pq.Add(7);
+ pq.Add(5);
+ pq.Add(10);
+ pq.Add(1);
pq.Add(-10);
- pq.Add(-100); // Resize
+ pq.Add(-100);
Assert.AreEqual(pq.Top(), -100);
pq.Add(-1000);
Assert.AreEqual(pq.Top(), -1000);
pq.Pop();
- Assert.AreEqual(pq.Top(), -100);
+ pq.Pop();
+ pq.Pop();
+ Assert.AreEqual(pq.Top(), -2);
pq.Add(0);
- Assert.AreEqual(pq.Top(), -100);
+ Assert.AreEqual(pq.Top(), -2);
for(int i = 0; i < 100; i++)
{
- pq.Add(5); // Lots of resizes
+ pq.Add(5);
}
- Assert.AreEqual(pq.Top(), -100);
+ Assert.AreEqual(pq.Top(), -2);
}
[Test]
@@ -607,8 +619,7 @@ namespace Lucene.Net.Util
{
if (!VERBOSE)
{
- // You won't see the results
- return;
+ Assert.Fail("Turn VERBOSE on or otherwise you won't see the results.");
}
int maxSize = AtLeast(100000);
[3/5] lucenenet git commit: Changed the only reference to Support's
PQ. Changed the corresponding method calls.
Posted by sy...@apache.org.
Changed the only reference to Support's PQ. Changed the corresponding method calls.
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/9428451c
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/9428451c
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/9428451c
Branch: refs/heads/master
Commit: 9428451c8ee87b39efeb2c39b94eb153067a066e
Parents: bf98bca
Author: Guido Tagliavini Ponce <t-...@microsoft.com>
Authored: Wed Feb 18 12:02:13 2015 -0800
Committer: Guido Tagliavini Ponce <t-...@microsoft.com>
Committed: Wed Feb 18 12:02:13 2015 -0800
----------------------------------------------------------------------
src/Lucene.Net.Core/Search/TopTermsRewrite.cs | 29 ++++++++++++++--------
1 file changed, 19 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9428451c/src/Lucene.Net.Core/Search/TopTermsRewrite.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/TopTermsRewrite.cs b/src/Lucene.Net.Core/Search/TopTermsRewrite.cs
index e61b362..e685872 100644
--- a/src/Lucene.Net.Core/Search/TopTermsRewrite.cs
+++ b/src/Lucene.Net.Core/Search/TopTermsRewrite.cs
@@ -5,7 +5,7 @@ using System.Linq;
namespace Lucene.Net.Search
{
- using Lucene.Net.Support;
+ using Lucene.Net.Util;
using ArrayUtil = Lucene.Net.Util.ArrayUtil;
using BytesRef = Lucene.Net.Util.BytesRef;
@@ -71,7 +71,7 @@ namespace Lucene.Net.Search
public override Query Rewrite(IndexReader reader, MultiTermQuery query)
{
int maxSize = Math.Min(size, MaxSize);
- PriorityQueue<ScoreTerm> stQueue = new PriorityQueue<ScoreTerm>();
+ PriorityQueue<ScoreTerm> stQueue = new ScoreTermPQ();
CollectTerms(reader, query, new TermCollectorAnonymousInnerClassHelper(this, maxSize, stQueue));
var q = TopLevelQuery;
@@ -161,9 +161,9 @@ namespace Lucene.Net.Search
//System.out.println("TTR.collect term=" + bytes.utf8ToString() + " boost=" + boost + " ord=" + readerContext.ord);
// ignore uncompetitive hits
- if (StQueue.Count == MaxSize)
+ if (StQueue.Size() == MaxSize)
{
- ScoreTerm t = StQueue.Peek();
+ ScoreTerm t = StQueue.Top();
if (boost < t.Boost)
{
return true;
@@ -190,11 +190,11 @@ namespace Lucene.Net.Search
visitedTerms[st.Bytes] = st;
Debug.Assert(st.TermState.DocFreq == 0);
st.TermState.Register(state, ReaderContext.Ord, termsEnum.DocFreq(), termsEnum.TotalTermFreq());
- StQueue.Offer(st);
+ StQueue.Add(st);
// possibly drop entries from queue
- if (StQueue.Count > MaxSize)
+ if (StQueue.Size() > MaxSize)
{
- st = StQueue.Poll();
+ st = StQueue.Pop();
visitedTerms.Remove(st.Bytes);
st.TermState.Clear(); // reset the termstate!
}
@@ -202,11 +202,11 @@ namespace Lucene.Net.Search
{
st = new ScoreTerm(termComp, new TermContext(TopReaderContext));
}
- Debug.Assert(StQueue.Count <= MaxSize, "the PQ size must be limited to maxSize");
+ Debug.Assert(StQueue.Size() <= MaxSize, "the PQ size must be limited to maxSize");
// set maxBoostAtt with values to help FuzzyTermsEnum to optimize
- if (StQueue.Count == MaxSize)
+ if (StQueue.Size() == MaxSize)
{
- t2 = StQueue.Peek();
+ t2 = StQueue.Top();
maxBoostAtt.MaxNonCompetitiveBoost = t2.Boost;
maxBoostAtt.CompetitiveTerm = t2.Bytes;
}
@@ -283,5 +283,14 @@ namespace Lucene.Net.Search
}
}
}
+
+ private class ScoreTermPQ : PriorityQueue<ScoreTerm>
+ {
+ public override bool LessThan(ScoreTerm a, ScoreTerm b)
+ {
+ return (a.CompareTo(b) < 0) ? true : false;
+ }
+ }
+
}
}
\ No newline at end of file
[5/5] lucenenet git commit: Merge remote-tracking branch
'guidotag/ms_pq_references'
Posted by sy...@apache.org.
Merge remote-tracking branch 'guidotag/ms_pq_references'
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/bdf4ec7b
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/bdf4ec7b
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/bdf4ec7b
Branch: refs/heads/master
Commit: bdf4ec7b05d279ff426063a81e7f338fff20ca04
Parents: 781e1c2 ee021b6
Author: Itamar Syn-Hershko <it...@code972.com>
Authored: Sun Mar 1 21:40:33 2015 +0200
Committer: Itamar Syn-Hershko <it...@code972.com>
Committed: Sun Mar 1 21:40:33 2015 +0200
----------------------------------------------------------------------
src/Lucene.Net.Core/Util/PriorityQueue.cs | 60 +++++++++-----
.../core/Util/TestPriorityQueue.cs | 82 ++++++++++++++++++--
2 files changed, 117 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/bdf4ec7b/src/Lucene.Net.Core/Util/PriorityQueue.cs
----------------------------------------------------------------------
diff --cc src/Lucene.Net.Core/Util/PriorityQueue.cs
index a0b52b7,83e60a4..0460d76
--- a/src/Lucene.Net.Core/Util/PriorityQueue.cs
+++ b/src/Lucene.Net.Core/Util/PriorityQueue.cs
@@@ -36,10 -37,17 +37,17 @@@ namespace Lucene.Net.Uti
public abstract class PriorityQueue<T>
{
private int QueueSize = 0;
- private readonly int MaxSize;
- private readonly T[] Heap;
+ private int MaxSize;
+ private T[] Heap;
+ private bool resizable;
+
+ public PriorityQueue()
+ : this(8, false)
+ {
+ resizable = true;
+ }
- public PriorityQueue(int maxSize)
+ public PriorityQueue(int maxSize = 128)
: this(maxSize, true)
{
}