public class BitArray
extends java.lang.Object
| Constructor and Description |
|---|
BitArray(boolean[] bits)
Create a BitArray whose bits are those of the given array
of Booleans.
|
BitArray(int length)
Creates a BitArray of the specified size, initialized to zeros.
|
BitArray(int length,
byte[] a)
Creates a BitArray of the specified size, initialized from the
specified byte array.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
clone() |
boolean |
equals(java.lang.Object obj) |
boolean |
get(int index)
Returns the indexed bit in this BitArray.
|
int |
hashCode()
Returns a hash code value for this bit array.
|
int |
length()
Returns the length of this BitArray.
|
void |
set(int index,
boolean value)
Sets the indexed bit in this BitArray.
|
boolean[] |
toBooleanArray()
Return a boolean array with the same bit values a this BitArray.
|
byte[] |
toByteArray()
Returns a Byte array containing the contents of this BitArray.
|
java.lang.String |
toString()
Returns a string representation of this BitArray.
|
BitArray |
truncate() |
public BitArray(int length)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentExceptionpublic BitArray(int length,
byte[] a)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentExceptionpublic BitArray(boolean[] bits)
public boolean get(int index)
throws java.lang.ArrayIndexOutOfBoundsException
java.lang.ArrayIndexOutOfBoundsExceptionpublic void set(int index,
boolean value)
throws java.lang.ArrayIndexOutOfBoundsException
java.lang.ArrayIndexOutOfBoundsExceptionpublic int length()
public byte[] toByteArray()
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic boolean[] toBooleanArray()
public int hashCode()
hashCode in class java.lang.Objectpublic java.lang.Object clone()
clone in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic BitArray truncate()
Copyright © 2025. All rights reserved.