Skip to content

Add bitwise shift (<< and >>) operations to BitSet collection #47

Open
@linasm

Description

@linasm

Proposal

  • add bitwise shift (<< and >>) operations to BitSet collection (both mutable and immutable)
  • add in place bitwise shift (<<= and >>=) operations to mutable BitSet

Motivation

Implementation

The operations can be efficiently implemented by shifting the 64 bit words of the backing array of the BitSet.
The implementation (in the form of extension methods) is readily available in scala-collection-contrib project:

Alternatives

<< can be emulated with .map(_ + shiftBy),
>> can be emulated with .collect { case b if b >= shiftBy => b - shiftBy },
but performance difference is up to two orders of magnitude.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestlibrary:collectionsstatus:pendingThis enhancement request lacks consensus on whether or not to include it

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions