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 liniarRemoveElement for Dlist #5786
Conversation
Thanks for your pull request, @Darredevil! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Some tips to help speed things up:
Bear in mind that large or tricky changes may require multiple rounds of review and revision. Please see CONTRIBUTING.md for more information. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
808a205
to
ac3a226
Compare
@andralex awaiting approval |
std/container/dlist.d
Outdated
private: | ||
|
||
BaseNode* findNodeByValue(BaseNode* n, T value) | ||
{ | ||
assert(n, "Error: un-initialized List"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't you just return null if the list is not initialized?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also prefer to return null instead of asserting, though all the other findNode*
functions do the same.
std/container/dlist.d
Outdated
@@ -766,6 +804,34 @@ private: | |||
{ | |||
import std.algorithm.comparison : equal; | |||
|
|||
auto a = DList!int(-1, 1, 2, 1, 3, 4); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should include a test involving an empty list
ac3a226
to
f4fcdc4
Compare
@andralex @ZombineDev should be ready for merge |
std/container/dlist.d
Outdated
bool linearRemoveElement(T value) | ||
{ | ||
auto n1 = findNodeByValue(_root, value); | ||
// if node exists |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete, just repeats what the code says
f4fcdc4
to
7d5708b
Compare
https://issues.dlang.org/show_bug.cgi?id=9362
Followed the idea from #5784 and implemented the same for Dlist.