-
Notifications
You must be signed in to change notification settings - Fork 5k
Fixed LinkedList: #662
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
Fixed LinkedList: #662
Conversation
* Modified node(atIndex:) method not to return nil, and code refactoring. * Deleted nodesBeforeAndAfter(index:) method, and modified insert methods.
How about 'guard var node = head { ... }'. This saves having to write 'var node = head' below the guard statement. |
Thanks for your suggestion. |
I apologize for having sent a lot of commits after pull request. |
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.
Nice changes overall. I left a comment at one of the many signatures with the following style:
node(atIndex:)
Changing it to node(at index: Int)
would read nicer at the call site: node(at: 10)
, and fits in better with the ones in the collection apis.
if i == 0 { return node } | ||
i -= 1 | ||
node = node!.next | ||
public func node(atIndex index: Int) -> Node { |
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.
node(at index: Int)
would read a bit more like the other collection apis.
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.
Thank you for your review.
I renamed atIndex
to at
by the following methods:
- node(atIndex:)
- insert(_:, atIndex:)
- remove(atIndex:)
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.
Good changes!
Thank you @ysn551! |
Checklist
Description