Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PriorityQueue to System.Collections.Generic (#43957) #46009

Merged
merged 50 commits into from
Feb 15, 2021
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
8b5b059
Add PriorityQueue to System.Collections.Generic (#43957)
Dec 12, 2020
9658a1b
(draft step, to squash) Modify API reference
pgolebiowski Dec 29, 2020
dda9697
(draft step, to squash) Add tests for PriorityQueue
pgolebiowski Dec 29, 2020
bf8b2e7
(draft step, to squash) Add initial implementation
pgolebiowski Dec 29, 2020
55f4e30
(draft step, to squash) Rename parameters
pgolebiowski Dec 29, 2020
ad531fe
(draft step, to squash) Replace `this.nodes` with `_nodes`
pgolebiowski Jan 8, 2021
28ca1e3
(draft step, to squash) Use an array and handle sizing ourselves
pgolebiowski Jan 8, 2021
b043b5a
(draft step, to squash) Create UnorderedItemsCollection lazily
pgolebiowski Jan 8, 2021
f60e250
(draft step, to squash) Deduplicate constructors
pgolebiowski Jan 8, 2021
6e01801
(draft step, to squash) Replace excessive `var` with explicit types
pgolebiowski Jan 8, 2021
e119ecc
(draft step, to squash) Remove `this.` in front of methods
pgolebiowski Jan 8, 2021
d76b0cf
(draft step, to squash) Improve out-of-range-argument exceptions
pgolebiowski Jan 8, 2021
4e7e138
(draft step, to squash) Use error messages from .resx
pgolebiowski Jan 8, 2021
4c2fd52
(draft step, to squash) Use positive case first in try methods
pgolebiowski Jan 8, 2021
321b4b0
(draft step, to squash) Implement UnorderedItemsCollection.CopyTo
pgolebiowski Jan 8, 2021
72c24da
(draft step, to squash) Optimize expressions involving Arity
pgolebiowski Jan 8, 2021
e647b2b
(draft step, to squash) Adjust implementation to be consistent with r…
pgolebiowski Jan 8, 2021
4d87259
(draft step, to squash) Implement method `EnqueueDequeue`
pgolebiowski Jan 9, 2021
cd5c0b2
(draft step, to squash) Make EnsureCapacity return int
pgolebiowski Jan 17, 2021
ea2b155
(draft step, to squash) Simplify lazy initialization of _unorderedItems
pgolebiowski Jan 17, 2021
a4c0d4f
(draft step, to squash) Use `out _` discard for unused properties
pgolebiowski Jan 17, 2021
2618b29
(draft step, to squash) Relax null checks on elements and priorities
pgolebiowski Jan 17, 2021
25f0125
(draft step, to squash) Simplify method SetCapacity
pgolebiowski Jan 17, 2021
7d187c9
(draft step, to squash) Remove MethodImplOptions.AggressiveInlining a…
pgolebiowski Jan 17, 2021
c8c2da4
(draft step, to squash) Use Array.Empty if the initial capacity is zero
pgolebiowski Jan 17, 2021
0ba9699
(draft step, to squash) Simplify UnorderedItemsCollection.Enumerator …
pgolebiowski Jan 17, 2021
4185937
(draft step, to squash) Simplify GetEnumerator methods
pgolebiowski Jan 17, 2021
af21790
(draft step, to squash) Optimize EnqueueRange methods
pgolebiowski Jan 23, 2021
58a9032
(draft step, to squash) Capitalize members of (TElement, TPriority)[]
pgolebiowski Jan 23, 2021
f8b4564
(draft step, to squash) Improve resize constants
pgolebiowski Jan 23, 2021
5851006
(draft step, to squash) Remove redundant `.this`
pgolebiowski Jan 23, 2021
ae630c2
(draft step, to squash) Optimize EnqueueDequeue
pgolebiowski Jan 23, 2021
fef7502
(draft step, to squash) Reduce indentation
pgolebiowski Jan 23, 2021
18301b2
(draft step, to squash) Simplify math expressions
pgolebiowski Jan 23, 2021
2bde65b
(draft step, to squash) Remove the PutAt helper method
pgolebiowski Jan 23, 2021
230a0a5
(draft step, to squash) Make the UnorderedItemsCollection constructor…
pgolebiowski Jan 23, 2021
abfb09b
(draft step, to squash) Clear last node slot on removal
pgolebiowski Jan 23, 2021
f700cba
(draft step, to squash) Improve next growth capacity computation
pgolebiowski Jan 23, 2021
e790b42
(draft step, to squash) Optimize Enqueue method
pgolebiowski Jan 23, 2021
07ec07c
(draft step, to squash) Make UnorderedItemsCollection.CopyTo implemen…
pgolebiowski Jan 23, 2021
ecf4c58
(draft step, to squash) Improve priority queue tests
pgolebiowski Jan 23, 2021
a877864
(draft step, to squash) Drop redundant casting
pgolebiowski Jan 24, 2021
26d4ce7
(draft step, to squash) Cosmetic improvements
pgolebiowski Jan 28, 2021
a3c114a
(draft step, to squash) Change signature of UnorderedItemsCollection
pgolebiowski Feb 13, 2021
3dbc4f5
(draft step, to squash) Add test PriorityQueue_Generic_EnqueueDequeue…
pgolebiowski Feb 13, 2021
8672c41
(draft step, to squash) Add tests of enqueue null functionality
pgolebiowski Feb 13, 2021
85aeed1
(draft step, to squash) Add test PriorityQueue_Generic_EnsureCapacity…
pgolebiowski Feb 13, 2021
938ef63
(draft step, to squash) Check underlying buffer length in tests with …
pgolebiowski Feb 13, 2021
475183a
(draft step, to squash) Check enumeration invalidation
pgolebiowski Feb 13, 2021
4f79c96
(draft step, to squash) Simplify code and improve documentation
pgolebiowski Feb 14, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions src/libraries/System.Collections/ref/System.Collections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,51 @@ public void Dispose() { }
void System.Collections.IEnumerator.Reset() { }
}
}

pgolebiowski marked this conversation as resolved.
Show resolved Hide resolved
public partial class PriorityQueue<TElement, TPriority>
{
public PriorityQueue() { }
public PriorityQueue(System.Collections.Generic.IComparer<TPriority>? comparer) { }
public PriorityQueue(System.Collections.Generic.IEnumerable<(TElement element, TPriority priority)> items) { }
public PriorityQueue(System.Collections.Generic.IEnumerable<(TElement element, TPriority priority)> items, System.Collections.Generic.IComparer<TPriority>? comparer) { }
public PriorityQueue(int initialCapacity) { }
public PriorityQueue(int initialCapacity, System.Collections.Generic.IComparer<TPriority>? comparer) { }
public System.Collections.Generic.IComparer<TPriority> Comparer { get { throw null; } }
public int Count { get { throw null; } }
public System.Collections.Generic.PriorityQueue<TElement, TPriority>.UnorderedItemsCollection UnorderedItems { get { throw null; } }
public void Clear() { }
public TElement Dequeue() { throw null; }
public void Enqueue(TElement element, TPriority priority) { }
public TElement EnqueueDequeue(TElement element, TPriority priority) { throw null; }
public void EnqueueRange(System.Collections.Generic.IEnumerable<(TElement element, TPriority priority)> items) { }
public void EnqueueRange(System.Collections.Generic.IEnumerable<TElement> elements, TPriority priority) { }
public int EnsureCapacity(int capacity) { throw null; }
public TElement Peek() { throw null; }
public void TrimExcess() { }
public bool TryDequeue([System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TElement element, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TPriority priority) { throw null; }
public bool TryPeek([System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TElement element, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TPriority priority) { throw null; }
public sealed partial class UnorderedItemsCollection : System.Collections.Generic.IEnumerable<(TElement element, TPriority priority)>, System.Collections.Generic.IReadOnlyCollection<(TElement element, TPriority priority)>, System.Collections.ICollection, System.Collections.IEnumerable
{
internal UnorderedItemsCollection(PriorityQueue<TElement, TPriority> queue) { }
public int Count { get { throw null; } }
bool System.Collections.ICollection.IsSynchronized { get { throw null; } }
object System.Collections.ICollection.SyncRoot { get { throw null; } }
void ICollection.CopyTo(System.Array array, int index) { }
public System.Collections.Generic.PriorityQueue<TElement, TPriority>.UnorderedItemsCollection.Enumerator GetEnumerator() { throw null; }
System.Collections.Generic.IEnumerator<(TElement element, TPriority priority)> System.Collections.Generic.IEnumerable<(TElement element, TPriority priority)>.GetEnumerator() { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
public partial struct Enumerator : System.Collections.Generic.IEnumerator<(TElement element, TPriority priority)>, System.Collections.IEnumerator, System.IDisposable
{
(TElement element, TPriority priority) IEnumerator<(TElement element, TPriority priority)>.Current { get { throw null; } }
public void Dispose() { }
public bool MoveNext() { throw null; }
public (TElement element, TPriority priority) Current { get { throw null; } }
object System.Collections.IEnumerator.Current { get { throw null; } }
void System.Collections.IEnumerator.Reset() { }
}
}
}

public partial class Queue<T> : System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IReadOnlyCollection<T>, System.Collections.ICollection, System.Collections.IEnumerable
{
public Queue() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<Compile Include="$(CoreLibSharedDir)System\Collections\Generic\IDictionaryDebugView.cs"
Link="Common\System\Collections\Generic\IDictionaryDebugView.cs" />
<Compile Include="System\Collections\Generic\LinkedList.cs" />
<Compile Include="System\Collections\Generic\PriorityQueue.cs" />
<Compile Include="System\Collections\Generic\Queue.cs" />
<Compile Include="System\Collections\Generic\QueueDebugView.cs" />
<Compile Include="System\Collections\Generic\SortedDictionary.cs" />
Expand Down
Loading