scodec.bits

BitVector

sealed trait BitVector extends AnyRef

Persistent vector of bits, stored as bytes.

Bits are numbered left to right, starting at 0.

Linear Supertypes
AnyRef, Any
Ordering
  1. Grouped
  2. Alphabetic
  3. By inheritance
Inherited
  1. BitVector
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def get(n: Long): Boolean

    Returns true if the nth bit is high, false otherwise.

    Returns true if the nth bit is high, false otherwise.

    Exceptions thrown
    NoSuchElementException

    if n >= size

  2. abstract def size: Long

    Returns number of bits in this vector.

  3. abstract def updated(n: Long, high: Boolean): BitVector

    Returns a new bit vector with the nth bit high if high is true or low if high is false.

Concrete Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def &(other: BitVector): BitVector

    Returns a bitwise AND of this vector with the specified vector.

    Returns a bitwise AND of this vector with the specified vector.

    The resulting vector's size is the minimum of this vector's size and the specified vector's size.

  5. def ++(b2: BitVector): BitVector

    Returns a new bit vector representing this vector's contents followed by the specified vector's contents.

  6. final def <<(n: Long): BitVector

    Returns a bit vector of the same size with each bit shifted to the left n bits.

  7. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  8. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  9. final def >>(n: Long): BitVector

    Returns a bit vector of the same size with each bit shifted to the right n bits where the n left-most bits are sign extended.

  10. final def >>>(n: Long): BitVector

    Returns a bit vector of the same size with each bit shifted to the right n bits where the n left-most bits are low.

  11. final def ^(other: BitVector): BitVector

    Returns a bitwise XOR of this vector with the specified vector.

    Returns a bitwise XOR of this vector with the specified vector.

    The resulting vector's size is the minimum of this vector's size and the specified vector's size.

  12. def acquire(n: Long): Either[String, BitVector]

    Returns a vector whose contents are the results of taking the first n bits of this vector.

    Returns a vector whose contents are the results of taking the first n bits of this vector.

    If this vector does not contain at least n bits, an error message is returned.

    See also

    take

  13. def and(other: BitVector): BitVector

    Returns a bitwise AND of this vector with the specified vector.

    Returns a bitwise AND of this vector with the specified vector.

    The resulting vector's size is the minimum of this vector's size and the specified vector's size.

  14. final def apply(n: Long): Boolean

    Alias for get.

    Alias for get.

    See also

    get(Long)

  15. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  16. def checkBounds(n: Long): Unit

    Attributes
    protected
  17. final def clear(n: Long): BitVector

    Returns a new bit vector with the nth bit low (and all other bits unmodified).

  18. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. def compact: Bytes

    Return a BitVector with the same contents as this, but based off a single ByteVector.

    Return a BitVector with the same contents as this, but based off a single ByteVector.

    This may involve copying data to a fresh ByteVector, but has the advantage that lookups index directly into a single ByteVector rather than traversing a logarithmic number of nodes in this tree.

  20. def consume[A](n: Long)(decode: (BitVector) ⇒ Either[String, A]): Either[String, (BitVector, A)]

    Consumes the first n bits of this vector and decodes them with the specified function, resulting in a vector of the remaining bits and the decoded value.

    Consumes the first n bits of this vector and decodes them with the specified function, resulting in a vector of the remaining bits and the decoded value. If this vector does not have n bits or an error occurs while decoding, an error is returned instead.

  21. def drop(n0: Long): BitVector

    Returns a vector whose contents are the results of skipping the first n bits of this vector and taking the rest.

    Returns a vector whose contents are the results of skipping the first n bits of this vector and taking the rest.

    The resulting vector's size is 0 max (size - n)

  22. def dropRight(n: Long): BitVector

    Returns a vector whose contents are the results of skipping the last n bits of this vector.

    Returns a vector whose contents are the results of skipping the last n bits of this vector.

    The resulting vector's size is 0 max (size - n)

  23. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  24. def equals(other: Any): Boolean

    Definition Classes
    BitVector → AnyRef → Any
  25. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  26. def force: BitVector

    Forces any Suspend nodes in this BitVector and ensures the tree is balanced.

  27. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  28. lazy val hashCode: Int

    Computed by sampling bits Stream.iterate(0L)(n => (n*1.7).toLong + 1), up until the maximum index.

    Computed by sampling bits Stream.iterate(0L)(n => (n*1.7).toLong + 1), up until the maximum index. The result is cached.

    Definition Classes
    BitVector → AnyRef → Any
  29. def head: Boolean

    Returns the first bit in this vector.

    Returns the first bit in this vector.

    Exceptions thrown
    IllegalArgumentException

    if this vector is empty

  30. def intSize: Option[Int]

    Returns the number of bits in this vector, or None if the size does not fit into an Int.

  31. final def isEmpty: Boolean

    Returns true if this bit vector has no bits.

  32. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  33. def leftShift(n: Long): BitVector

    Returns a bit vector of the same size with each bit shifted to the left n bits.

  34. final def lift(n: Long): Option[Boolean]

    Returns Some(true) if the nth bit is high, Some(false) if low, and None if n >= size.

  35. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  36. final def nonEmpty: Boolean

    Returns true if this bit vector has a non-zero number of bits.

  37. def not: BitVector

    Returns a bitwise complement of this vector.

  38. final def notify(): Unit

    Definition Classes
    AnyRef
  39. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  40. def or(other: BitVector): BitVector

    Returns a bitwise OR of this vector with the specified vector.

    Returns a bitwise OR of this vector with the specified vector.

    The resulting vector's size is the minimum of this vector's size and the specified vector's size.

  41. def outOfBounds(n: Long): Nothing

    Attributes
    protected
  42. def padTo(n: Long): BitVector

    Returns an n-bit vector whose contents are this vector's contents followed by 0 or more low bits.

    Returns an n-bit vector whose contents are this vector's contents followed by 0 or more low bits.

    Exceptions thrown
    IllegalArgumentException

    if n < size

  43. def reverse: BitVector

    Reverse the bits of this vector.

  44. def reverseByteOrder: BitVector

    Returns a new vector of the same size with the byte order reversed.

  45. def rightShift(n: Long, signExtension: Boolean): BitVector

    Returns a bit vector of the same size with each bit shifted to the right n bits.

    Returns a bit vector of the same size with each bit shifted to the right n bits.

    signExtension

    whether the n left-most bits should take on the value of bit 0

  46. final def set(n: Long): BitVector

    Returns a new bit vector with the nth bit high (and all other bits unmodified).

  47. def sizeGreaterThan(n: Long): Boolean

    Returns true if the size of this BitVector is greater than n.

    Returns true if the size of this BitVector is greater than n. Unlike size, this forces this BitVector from left to right, halting as soon as it has a definite answer.

  48. def sizeLessThan(n: Long): Boolean

    Returns true if the size of this BitVector is less than n.

    Returns true if the size of this BitVector is less than n. Unlike size, this forces this BitVector from left to right, halting as soon as it has a definite answer.

  49. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  50. def take(n0: Long): BitVector

    Returns a vector whose contents are the results of taking the first n bits of this vector.

    Returns a vector whose contents are the results of taking the first n bits of this vector.

    The resulting vector's size is n min size.

    Note: if an n-bit vector is required, use the acquire method instead.

    See also

    acquire

  51. def takeRight(n: Long): BitVector

    Returns a vector whose contents are the results of taking the last n bits of this vector.

    Returns a vector whose contents are the results of taking the last n bits of this vector.

    The resulting vector's size is n min size.

    Note: if an n-bit vector is required, use the acquire method instead.

    See also

    acquire

  52. def toBin: String

    Converts the contents of this bit vector to a binary string of size digits.

  53. def toByteArray: Array[Byte]

    Converts the contents of this vector to a byte array.

    Converts the contents of this vector to a byte array.

    If this vector's size does not divide evenly by 8, the last byte of the returned vector will be zero-padded to the right.

  54. def toByteBuffer: ByteBuffer

    Converts the contents of this vector to a java.nio.ByteBuffer.

    Converts the contents of this vector to a java.nio.ByteBuffer.

    The returned buffer is freshly allocated with limit set to the minimum number of bytes needed to represent the contents of this vector, position set to zero, and remaining set to the limit.

    See also

    toByteVector

  55. def toByteVector: ByteVector

    Converts the contents of this vector to a byte vector.

    Converts the contents of this vector to a byte vector.

    If this vector's size does not divide evenly by 8, the last byte of the returned vector will be zero-padded to the right.

  56. def toHex: String

    Converts the contents of this bit vector to a hexadecimal string of ceil(size / 4) nibbles.

    Converts the contents of this bit vector to a hexadecimal string of ceil(size / 4) nibbles.

    The last nibble is right-padded with zeros if the size is not evenly divisible by 4.

  57. def toIndexedSeq: IndexedSeq[Boolean]

    Return the sequence of bits in this vector.

    Return the sequence of bits in this vector. The returned IndexedSeq is just a view; nothing is actually copied.

    Exceptions thrown
    IllegalArgumentException

    if this vector's size exceeds Int.MaxValue

    See also

    toIndexedSeq

    acquire

  58. def toString(): String

    Display the size and bytes of this BitVector.

    Display the size and bytes of this BitVector. For bit vectors beyond a certain size, only a hash of the contents are shown.

    Definition Classes
    BitVector → AnyRef → Any
  59. final def unary_~(): BitVector

    Returns a bitwise complement of this vector.

  60. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  61. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  62. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  63. def xor(other: BitVector): BitVector

    Returns a bitwise XOR of this vector with the specified vector.

    Returns a bitwise XOR of this vector with the specified vector.

    The resulting vector's size is the minimum of this vector's size and the specified vector's size.

  64. final def |(other: BitVector): BitVector

    Returns a bitwise OR of this vector with the specified vector.

    Returns a bitwise OR of this vector with the specified vector.

    The resulting vector's size is the minimum of this vector's size and the specified vector's size.

Inherited from AnyRef

Inherited from Any

Collection Like Methods

Operations on Individual Bits

Bitwise Operations

Conversions

Ungrouped