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

Add partial implementation of java.util.EnumSet #3397

Merged
merged 1 commit into from Jul 19, 2023

Conversation

WojciechMazur
Copy link
Contributor

Adds simple implementation of EnumSet for parts not requiring reflection support.
Resolves #3385

@WojciechMazur WojciechMazur merged commit ce94cf5 into scala-native:main Jul 19, 2023
77 checks passed
@WojciechMazur WojciechMazur deleted the javalib/enum-set branch July 19, 2023 06:58
@@ -2,27 +2,113 @@ package java.util

import java.lang.Enum

final class EnumSet[E <: Enum[E]] private (values: Array[E])
final class EnumSet[E <: Enum[E]] private (values: Set[E])

Choose a reason for hiding this comment

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

this could still be an array where the index corresponds to ordinal, and the max ordinal + 1 is the size of the array? (never shrink, only grow by powers of 2?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, it could have been, but it's not going to be frequently used, and that way we get the Set ops for free. At some point it could be rewriten to be more optimal, but for current usages its good enough, especially since we cannot support the relection based semantics to populate it with all values

WojciechMazur added a commit to WojciechMazur/scala-native that referenced this pull request Sep 1, 2023
WojciechMazur added a commit that referenced this pull request Sep 4, 2023
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.

Implement java.util.EnumSet
2 participants