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
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,16 @@ public void PriorityQueue_Generic_EnqueueDequeue_LargerThanMin()
Assert.Equal("three", queue.Dequeue());
Assert.Equal("four", queue.Dequeue());
}

[Fact]
public void PriorityQueue_Generic_EnqueueDequeue_EqualToMin()
{
PriorityQueue<string, int> queue = SmallPriorityQueueFactory(out HashSet<(string, int)> enqueuedItems);

string actualElement = queue.EnqueueDequeue("one-not-to-enqueue", 1);

Assert.Equal("one-not-to-enqueue", actualElement);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the correctness of the assertion really depends on the implementation of SmallPriorityQueueFactory.

Assert.True(enqueuedItems.SetEquals(queue.UnorderedItems));
}
}
}