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

collection: fix SortedArray container #35

Merged
merged 1 commit into from
Apr 9, 2018

Conversation

yerden
Copy link
Contributor

@yerden yerden commented Apr 3, 2018

Changes:

  • fix constructor to require explicit SortComparer object
    since GenericSortComparer may fail in the runtime due to
    absence of > and < operators.
  • fix clear() method to adhere to Collection behaviour;
  • call clear() from destructor.

The problem with SortComparer is that it should be specified explicitly. The GenericSortComparer class relies on > and < operators which may be not implemented for the T type. That leads to "illegal operator use" compilation error for non-comparable types. Thus, this fix breaks SortedArray API.

This is not the case for EqualityComparer class as == operator is defined for every conventional type as well as object pointers.

Changes:
* fix constructor to require explicit SortComparer object
  since GenericSortComparer may fail in the runtime due to
  absence of `>` and `<` operators.
* fix clear() method to adhere to Collection behaviour;
* call clear() from destructor.
@dingmaotu dingmaotu merged commit 2ff32c6 into dingmaotu:master Apr 9, 2018
@yerden yerden deleted the sortedarray_fix branch April 10, 2018 05:05
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.

2 participants