Skip to content

Fix NullReferenceException in SLinkedListEnumerator.MoveNext(). - #7

Open
RodneyRichardson wants to merge 1 commit into
C-Sharp-Algorithms:developfrom
RodneyRichardson:enumerate-empty-list
Open

RodneyRichardson wants to merge 1 commit into
C-Sharp-Algorithms:developfrom
RodneyRichardson:enumerate-empty-list

Conversation

@RodneyRichardson

Copy link
Copy Markdown

Description

Fix NullReferenceException in SLinkedListEnumerator.MoveNext().
Closes #6.

Checklist

  • An issue was first created before opening this pull request
  • The new code follows the contribution guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings (although it's hard to tell with so many warnings in the code)
  • I have added tests to ensure that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

_current = _current.Next;

return (this._current != null);
if (_current != null)

@NdubuisiJr NdubuisiJr Jan 6, 2022 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this “if statement” fixes the bug.

why did you change the ‘_doublyLinkedList’ to ‘_list’?

@RodneyRichardson RodneyRichardson Jan 6, 2022 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Because it is not a doubly-linked list (it's singly-linked). I presumed it was a copy-paste error, and it would have complicated things in a separate PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah… that makes sense.
I think the fix is valid.

well done 👍🏾

@NdubuisiJr NdubuisiJr left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please answer the question

@NdubuisiJr

Copy link
Copy Markdown
Member

@nloum please come and review this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enumerating an empty SLinkedList throws NullReferenceException

2 participants