Use List<Boolean> instead of boolean[] in Set#1
Open
sim642 wants to merge 1 commit intout-aa:masterfrom
Open
Conversation
Member
|
Thanks for the suggestion! I agree that using a List instead of an array as a generic type of a Set (and other Collections) is pretty much always more reasonable. But since changing this at the moment is costly because many people have already implemented it can you give an example as to why changing this is essential in the context of this exercise? If it's not essential then it will be changed before next year. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BitVectorGeneratorinterface uses the typeSet<boolean[]>. The problem with this type is demonstrated by the following example:(running example)
All arrays (including those of primitives) are objects which do not override
equalsmethod. This meansObject.equalsis used which doesn't compare the content of arrays. This fact makes the use ofboolean[]in aSetessentially useless because it's neither correct nor reliable as all ofSet's methods rely on correct implementation ofequals.Instead
List<Boolean>has properly implementedequalsmethod, fixing the issue above:(running example)
In addition
Lists are much easier to manipulate than arrays, making the task less about reinventing the wheel which isList.