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

Implement iterator for binary_search_tree<T> #144

Closed
domfarolino opened this issue Jan 14, 2020 · 0 comments · Fixed by #145
Closed

Implement iterator for binary_search_tree<T> #144

domfarolino opened this issue Jan 14, 2020 · 0 comments · Fixed by #145

Comments

@domfarolino
Copy link
Owner

domfarolino commented Jan 14, 2020

API-wise, both min() and max() should return iterators, and we should introduce the following methods:

  • begin(): returns the result of min().
  • end(): returns an iterator pointing to nullptr
  • find(): returns an iterator pointing to the a found value. Similar to exists(), but with an iterator return value

A binary_search_tree<T>::iterator should support the following operations:

  • Pre-increment
    • Should rely on a newly-introduced static binary_search_tree::inorder_successor
  • Post-increment
    • ditto
  • Pre-decrement
    • Should rely on a newly-introduced static binary_search_tree::inorder_predecessor
  • Post-decrement
    • ditto

Given iterator increment and decrement support, does that imply we want to mark the iterator as a bidirectional iterator? See #146

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 a pull request may close this issue.

1 participant