Packages

object BitVector extends BitVectorCompanionCrossPlatform with Serializable

Companion for BitVector.

Source
BitVector.scala
Linear Supertypes
Serializable, BitVectorCompanionCrossPlatform, BitVectorPlatform, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. BitVector
  2. Serializable
  3. BitVectorCompanionCrossPlatform
  4. BitVectorPlatform
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. implicit final class GroupedOp extends AnyVal

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def apply[A](bytes: A*)(implicit arg0: Integral[A]): BitVector

    Constructs a BitVector from a list of literal bytes.

    Constructs a BitVector from a list of literal bytes. Only the least significant byte is used of each integral value.

  5. def apply(bs: IterableOnce[Byte]): BitVector

    Constructs a BitVector from a collection of bytes.

  6. def apply(bs: Array[Byte]): BitVector

    Constructs a BitVector from an Array[Byte].

    Constructs a BitVector from an Array[Byte]. The given Array[Byte] is is copied to ensure the resulting BitVector is immutable. If this is not desired, use BitVector.view.

  7. def apply(buffer: ByteBuffer): BitVector

    Constructs a BitVector from a ByteBuffer.

    Constructs a BitVector from a ByteBuffer. The given ByteBuffer is is copied to ensure the resulting BitVector is immutable. If this is not desired, use BitVector.view.

  8. def apply(bs: ByteVector): BitVector

    Constructs a BitVector from a ByteVector.

    Constructs a BitVector from a ByteVector. This method has runtime O(1).

  9. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  10. def bit(high: Boolean): BitVector

    1-bit vector with only bit set to specified value.

  11. def bits(b: Iterable[Boolean]): BitVector

    n-bit vector with bit at index i set to value of boolean at index i in specified iterable.

  12. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  13. def concat(vs: Vector[BitVector]): BitVector

    Concatenate vs to produce a single BitVector.

  14. def concat(bvs: IterableOnce[BitVector]): BitVector

    Concatenates all the given BitVectors into a single instance.

  15. val empty: BitVector

    Empty bit vector.

  16. def encodeAscii(str: String): Either[CharacterCodingException, BitVector]

    Encodes the specified string to a BitVector using the US-ASCII charset.

  17. def encodeString(str: String)(implicit charset: Charset): Either[CharacterCodingException, BitVector]

    Encodes the specified string to a BitVector using the implicitly available Charset.

  18. def encodeUtf8(str: String): Either[CharacterCodingException, BitVector]

    Encodes the specified string to a BitVector using the UTF-8 charset.

  19. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  20. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  21. def fill(n: Long)(high: Boolean): BitVector

    Constructs an n-bit BitVector where each bit is set to the specified value.

  22. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  23. def fromBase32(str: String, alphabet: Base32Alphabet = Bases.Alphabets.Base32): Option[BitVector]

    Constructs a BitVector from a base 32 string or returns None if the string is not valid base 32.

    Constructs a BitVector from a base 32 string or returns None if the string is not valid base 32. Details pertaining to base 32 decoding can be found in the comment for ByteVector.fromBase32Descriptive. The string may contain whitespace characters which are ignored.

  24. def fromBase32Descriptive(str: String, alphabet: Base32Alphabet = Bases.Alphabets.Base32): Either[String, BitVector]

    Constructs a BitVector from a base 32 string or returns an error message if the string is not valid base 32.

    Constructs a BitVector from a base 32 string or returns an error message if the string is not valid base 32. Details pertaining to base 32 decoding can be found in the comment for ByteVector.fromBase32Descriptive. The string may contain whitespace characters which are ignored.

  25. def fromBase58(str: String, alphabet: Alphabet = Bases.Alphabets.Base58): Option[BitVector]

    Constructs a BitVector from a base 58 string or returns None if the string is not valid base 58.

    Constructs a BitVector from a base 58 string or returns None if the string is not valid base 58. Details pertaining to base 58 decoding can be found in the comment for ByteVector.fromBase58Descriptive. The string may contain whitespace characters which are ignored.

  26. def fromBase58Descriptive(str: String, alphabet: Alphabet = Bases.Alphabets.Base58): Either[String, BitVector]

    Constructs a BitVector from a base 58 string or returns an error message if the string is not valid base 58.

    Constructs a BitVector from a base 58 string or returns an error message if the string is not valid base 58. Details pertaining to base 58 decoding can be found in the comment for ByteVector.fromBase58Descriptive. The string may contain whitespace characters which are ignored.

  27. def fromBase64(str: String, alphabet: Base64Alphabet = Bases.Alphabets.Base64): Option[BitVector]

    Constructs a BitVector from a base 64 string or returns None if the string is not valid base 64.

    Constructs a BitVector from a base 64 string or returns None if the string is not valid base 64. Details pertaining to base 64 decoding can be found in the comment for ByteVector.fromBase64Descriptive. The string may contain whitespace characters which are ignored.

  28. def fromBase64Descriptive(str: String, alphabet: Base64Alphabet = Bases.Alphabets.Base64): Either[String, BitVector]

    Constructs a BitVector from a base 64 string or returns an error message if the string is not valid base 64.

    Constructs a BitVector from a base 64 string or returns an error message if the string is not valid base 64. Details pertaining to base 64 decoding can be found in the comment for ByteVector.fromBase64Descriptive. The string may contain whitespace characters which are ignored.

  29. def fromBin(str: String, alphabet: BinaryAlphabet = Bases.Alphabets.Binary): Option[BitVector]

    Constructs a BitVector from a binary string or returns None if the string is not valid binary.

    Constructs a BitVector from a binary string or returns None if the string is not valid binary.

    The string may start with a 0b and it may contain whitespace or underscore characters.

  30. def fromBinDescriptive(str: String, alphabet: BinaryAlphabet = Bases.Alphabets.Binary): Either[String, BitVector]

    Constructs a BitVector from a binary string or returns an error message if the string is not valid binary.

    Constructs a BitVector from a binary string or returns an error message if the string is not valid binary.

    The string may start with a 0b and it may contain whitespace or underscore characters.

  31. def fromByte(b: Byte, size: Int = 8): BitVector

    Constructs a bit vector with the 2's complement encoding of the specified byte.

    Constructs a bit vector with the 2's complement encoding of the specified byte.

    b

    value to encode

    size

    size of vector (<= 8)

  32. def fromChannel(in: ReadableByteChannel, chunkSizeInBytes: Int = 1024 * 1000 * 16, direct: Boolean = false): BitVector

    Produce a lazy BitVector from the given ReadableByteChannel, using chunkSizeInBytes to control the number of bytes read in each chunk (defaulting to 16MB).

    Produce a lazy BitVector from the given ReadableByteChannel, using chunkSizeInBytes to control the number of bytes read in each chunk (defaulting to 16MB). This function does lazy I/O, see scodec.bits.BitVector.fromInputStream for caveats. The direct parameter, if true, allows for (but does not enforce) using a 'direct' java.nio.ByteBuffer for each chunk, which means the buffer and corresponding BitVector chunk may be backed by a 'view' rather than an in-memory array. This may be more efficient for some workloads. See java.nio.ByteBuffer for more information.

    chunkSizeInBytes

    the number of bytes to read in each chunk

    direct

    true if we should attempt to use a 'direct' java.nio.ByteBuffer for reads

  33. def fromHex(str: String, alphabet: HexAlphabet = Bases.Alphabets.HexLowercase): Option[BitVector]

    Constructs a BitVector from a hexadecimal string or returns None if the string is not valid hexadecimal.

    Constructs a BitVector from a hexadecimal string or returns None if the string is not valid hexadecimal.

    The string may start with a 0x and it may contain whitespace or underscore characters.

  34. def fromHexDescriptive(str: String, alphabet: HexAlphabet = Bases.Alphabets.HexLowercase): Either[String, BitVector]

    Constructs a BitVector from a hexadecimal string or returns an error message if the string is not valid hexadecimal.

    Constructs a BitVector from a hexadecimal string or returns an error message if the string is not valid hexadecimal.

    The string may start with a 0x and it may contain whitespace or underscore characters.

  35. def fromInputStream(in: InputStream, chunkSizeInBytes: Int = 1024 * 1000 * 16): BitVector

    Produce a lazy BitVector from the given InputStream, using chunkSizeInBytes to control the number of bytes read in each chunk (defaulting to 16MB).

    Produce a lazy BitVector from the given InputStream, using chunkSizeInBytes to control the number of bytes read in each chunk (defaulting to 16MB). This simply calls scodec.bits.BitVector.unfold with a function to extract a series of flat byte arrays from the InputStream.

    This function does not handle closing the InputStream and has all the usual drawbacks of lazy I/O - I/O exceptions may be raised unexpectedly in pure code as chunks are forced, and it must memoize the results to prevent the underlying side effects from being observed. Streaming applications should take care to ensure that the head of the stream is not left on the stack, as this will cause the entire stream to be retained in memory.

    chunkSizeInBytes

    the number of bytes to read in each chunk

  36. def fromInt(i: Int, size: Int = 32, ordering: ByteOrdering = ByteOrdering.BigEndian): BitVector

    Constructs a bit vector with the 2's complement encoding of the specified value.

    Constructs a bit vector with the 2's complement encoding of the specified value.

    i

    value to encode

    size

    size of vector (<= 32)

    ordering

    byte ordering of vector

  37. def fromLong(l: Long, size: Int = 64, ordering: ByteOrdering = ByteOrdering.BigEndian): BitVector

    Constructs a bit vector with the 2's complement encoding of the specified value.

    Constructs a bit vector with the 2's complement encoding of the specified value.

    l

    value to encode

    size

    size of vector (<= 64)

    ordering

    byte ordering of vector

  38. def fromMmap(in: FileChannel, chunkSizeInBytes: Int = 1024 * 1000 * 16): BitVector

    Produce a lazy BitVector from the given FileChannel, using chunkSizeInBytes to control the number of bytes read in each chunk (defaulting to 16MB).

    Produce a lazy BitVector from the given FileChannel, using chunkSizeInBytes to control the number of bytes read in each chunk (defaulting to 16MB). Unlike scodec.bits.BitVector.fromChannel, this memory-maps chunks in, rather than copying them explicitly.

    Behavior is unspecified if this function is used concurrently with the underlying file being written.

    chunkSizeInBytes

    the number of bytes to read in each chunk

  39. def fromShort(s: Short, size: Int = 16, ordering: ByteOrdering = ByteOrdering.BigEndian): BitVector

    Constructs a bit vector with the 2's complement encoding of the specified value.

    Constructs a bit vector with the 2's complement encoding of the specified value.

    s

    value to encode

    size

    size of vector (<= 16)

    ordering

    byte ordering of vector

  40. final def fromUUID(u: UUID): BitVector

    Constructs a bit vector containing the binary representation of the specified UUID.

    Constructs a bit vector containing the binary representation of the specified UUID. The bits are in MSB-to-LSB order.

    u

    value to encode

  41. def fromValidBase32(str: String, alphabet: Base32Alphabet = Bases.Alphabets.Base32): BitVector

    Constructs a BitVector from a base 32 string or throws an IllegalArgumentException if the string is not valid base 32.

    Constructs a BitVector from a base 32 string or throws an IllegalArgumentException if the string is not valid base 32. Details pertaining to base 32 decoding can be found in the comment for ByteVector.fromBase32Descriptive. The string may contain whitespace characters which are ignored.

    Exceptions thrown

    IllegalArgumentException if the string is not valid base 32

  42. def fromValidBase58(str: String, alphabet: Alphabet = Bases.Alphabets.Base58): BitVector

    Constructs a BitVector from a base 58 string or throws an IllegalArgumentException if the string is not valid base 58.

    Constructs a BitVector from a base 58 string or throws an IllegalArgumentException if the string is not valid base 58. Details pertaining to base 58 decoding can be found in the comment for ByteVector.fromBase58Descriptive. The string may contain whitespace characters which are ignored.

    Exceptions thrown

    IllegalArgumentException if the string is not valid base 58

  43. def fromValidBase64(str: String, alphabet: Base64Alphabet = Bases.Alphabets.Base64): BitVector

    Constructs a BitVector from a base 64 string or throws an IllegalArgumentException if the string is not valid base 64.

    Constructs a BitVector from a base 64 string or throws an IllegalArgumentException if the string is not valid base 64. Details pertaining to base 64 decoding can be found in the comment for ByteVector.fromBase64Descriptive. The string may contain whitespace characters which are ignored.

    Exceptions thrown

    IllegalArgumentException if the string is not valid base 64

  44. def fromValidBin(str: String, alphabet: BinaryAlphabet = Bases.Alphabets.Binary): BitVector

    Constructs a BitVector from a binary string or throws an IllegalArgumentException if the string is not valid binary.

    Constructs a BitVector from a binary string or throws an IllegalArgumentException if the string is not valid binary.

    The string may start with a 0b and it may contain whitespace or underscore characters.

    Exceptions thrown

    IllegalArgumentException if the string is not valid hexadecimal

  45. def fromValidHex(str: String, alphabet: HexAlphabet = Bases.Alphabets.HexLowercase): BitVector

    Constructs a BitVector from a hexadecimal string or throws an IllegalArgumentException if the string is not valid hexadecimal.

    Constructs a BitVector from a hexadecimal string or throws an IllegalArgumentException if the string is not valid hexadecimal.

    The string may start with a 0x and it may contain whitespace or underscore characters.

    Exceptions thrown

    IllegalArgumentException if the string is not valid hexadecimal

  46. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  47. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  48. def high(n: Long): BitVector

    n-bit vector with all bits set high.

  49. val highByte: BitVector

    8-bit vector with all bits set high.

  50. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  51. def low(n: Long): BitVector

    n-bit vector with all bits set low.

  52. val lowByte: BitVector

    8-bit vector with all bits set low.

  53. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  54. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  55. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  56. val one: BitVector

    1-bit vector with only bit set high.

  57. def reverseBitsInByte(b: Byte): Byte

    Returns the bitwise reversal of the provided byte.

  58. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  59. def toString(): String
    Definition Classes
    AnyRef → Any
  60. def unfold[S](s: S)(f: (S) => Option[(BitVector, S)]): BitVector

    Create a lazy BitVector by repeatedly extracting chunks from S.

    Create a lazy BitVector by repeatedly extracting chunks from S. The returned BitVector will have the structure of a fully lazy right-associated cons list. Thus, get, take, and drop will be efficient when operating on the head of the list, but accessing later indices (for takeRight, say, or get(size-1) will require forcing the stream up to that point.

    Use force if you wish to convert the result to an in-memory strict BitVector backed by a balanced tree.

  61. def view(bs: Array[Byte], sizeInBits: Long): BitVector

    Constructs a BitVector from an Array[Byte].

    Constructs a BitVector from an Array[Byte]. Unlike apply, this does not make a copy of the input array, so callers should take care not to modify the contents of the array passed to this function.

  62. def view(bs: Array[Byte]): BitVector

    Constructs a BitVector from an Array[Byte].

    Constructs a BitVector from an Array[Byte]. Unlike apply, this does not make a copy of the input array, so callers should take care not to modify the contents of the array passed to this function.

  63. def view(buffer: ByteBuffer, sizeInBits: Long): BitVector

    Constructs a BitVector from the first sizeInBits of the ByteBuffer.

    Constructs a BitVector from the first sizeInBits of the ByteBuffer. Unlike apply, this does not make a copy of the input buffer, so callers should take care not to modify the contents of the buffer passed to this function.

  64. def view(buffer: ByteBuffer): BitVector

    Constructs a BitVector from a ByteBuffer using the buffer limit * 8 as the size.

    Constructs a BitVector from a ByteBuffer using the buffer limit * 8 as the size. Unlike apply, this does not make a copy of the input buffer, so callers should take care not to modify the contents of the buffer passed to this function.

  65. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  66. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  67. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  68. val zero: BitVector

    1-bit vector with only bit set low.

Inherited from Serializable

Inherited from BitVectorCompanionCrossPlatform

Inherited from BitVectorPlatform

Inherited from AnyRef

Inherited from Any

Constants

conversions

Constructors

Numeric Conversions

Base Conversions

Ungrouped