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

Enumeration.ValueSet should provide a bit mask representation and use a BitSet-based implementation #5208

Closed
scabug opened this issue Nov 21, 2011 · 2 comments
Assignees

Comments

@scabug
Copy link

scabug commented Nov 21, 2011

Unlike Java's EnumSet, an Enumeration.ValueSet in Scala is not based on a bit set. Conversions between ValueSets and bit masks can currently be implemented like this:

  def toLong(vs: Enumeration#ValueSet): Long = vs.foldLeft(0L){ (z,n) => (2L << n.id) + z }
  def fromLong[T <: Enumeration](e: T, l: Long): T#ValueSet = e.ValueSet.empty ++ (new BitSet1(l)).map(i => e(i-1))

Such conversion method should be built in (not even BitSet itself currently provides a way of getting a bit mask out), and be based on a more efficient implementation like Java's EnumSet.

@scabug
Copy link
Author

scabug commented Nov 21, 2011

Imported From: https://issues.scala-lang.org/browse/SI-5208?orig=1
Reporter: @szeiger
Affected Versions: 2.9.1
See #5211

@scabug
Copy link
Author

scabug commented Dec 8, 2011

@szeiger said:
Implemented in 0f87b7b5780267d05d467a2f0075ee746f2cef2f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants