-
Notifications
You must be signed in to change notification settings - Fork 37
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
Refactor ImmutableLinkedHashSet #513
Conversation
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.
LGTM! Thank you!
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.
LGTM! Thank you!
But, I left one question.
immutable = true; | ||
public ImmutableLinkedHashSet(Collection<? extends E> data) { | ||
super(0); | ||
this.data = ImmutableSet.copyOf(data); |
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.
Just wondering. Is it guaranteed to keep the insertion order even if it's copied (not actually copied behind the scene, though) to ImmutableSet?
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.
Yes, ImmutableSet
guarantees to keep the insertion order. Actually, I didn't know that before working on this change, but it does according to the following document:
https://guava.dev/releases/30.1-jre/api/docs/com/google/common/collect/ImmutableCollection.html
Deterministic iteration. The iteration order is always well-defined, depending on how the collection was created. Typically this is insertion order unless an explicit ordering is otherwise specified (e.g. ImmutableSortedSet.naturalOrder()).
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.
Oh, cool. Thank you!
This PR changes
ImmutableLinkedHashSet
to useImmutableSet
internally and delegate to it. Please take a look!