public final class BitN
extends java.util.BitSet
implements java.lang.Comparable<java.lang.Object>
Constructor and Description |
---|
BitN()
constructor - construct a BIT(0), which is unusable for any purpose
|
BitN(BitN inBits)
copy constructor of BIT(n).
|
BitN(java.util.BitSet set,
int n)
constructor - construct a BIT(n) from a BitSet
(copy constructor not part of a BitSet)
|
BitN(byte[] bytes,
int n)
constructor - construct a BIT(n) from a long[] array
converting the longs from little-endian to big-endian
|
BitN(int n)
constructor - construct a BIT(n), with all bits set to '0'B
|
BitN(long[] longs,
int n)
constructor - construct a BIT(n) from a long[] array
converting the longs from little-endian to big-endian
|
BitN(java.lang.String str,
int n)
constructor - construct a BIT(n) from a String assumed to be
in BITCONSTANT form
|
Modifier and Type | Method and Description |
---|---|
int |
cardinality()
cardinality - Returns the number of bits set to true in this BitSet.
|
void |
clear()
clear - Sets all of the bits in this BitSet to false.
|
void |
clear(int bitIndex)
clear - Sets one of the bits in this BitSet to false.
|
void |
clear(int fromBigEndianBit,
int toBigEndianBit)
clear - Sets a range of bits in this BitSet to false.
|
int |
compareTo(java.lang.Object arg)
compareTo - compare two BitN objects
|
void |
flip(int bitIndex)
flip - Sets the bit at the specified index to the complement of its current value.
|
void |
flip(int fromBigEndianBit,
int toBigEndianBit)
flip - Sets each bit from the specified fromIndex (inclusive) to the specified toIndex (exclusive)
to the complement of its current value.
|
boolean |
get(int bitIndex)
get - Returns the value of the bit with the specified index.
|
BitN |
get(int fromBigEndianBit,
int toBigEndianBit)
get - Returns a new BitSet composed of bits from this BitSet from fromIndex
(inclusive) to toIndex (exclusive).
|
int |
length()
length - Returns the "logical size" of this BitSet: the index of the highest
set bit in the BitSet plus one.
|
static void |
main(java.lang.String[] args)
main - unit test for Picture
|
int |
nextClearBit(int fromIndex)
nextClearBit - Returns the index of the first bit that is set to false that
occurs on or after the specified starting index.
|
int |
nextSetBit(int fromIndex)
nextSetBit - Returns the index of the first bit that is set to true that
occurs on or after the specified starting index.
|
int |
previousClearBit(int fromIndex)
previousClearBit - Returns the index of the nearest bit that is set to false
that occurs on or before the specified starting index.
|
int |
previousSetBit(int fromIndex)
previousSetBit - Returns the index of the nearest bit that is set to true
that occurs on or before the specified starting index.
|
void |
set(int bitIndex)
set - Sets one of the bits in this BitSet to true.
|
void |
set(int fromBigEndianBit,
int toBigEndianBit)
set - Sets a range of bits in this BitSet to true.
|
void |
set(int fromBigEndianBit,
int toBigEndianBit,
boolean value)
set - Sets a range of bits in this BitSet to a value.
|
int |
size()
size - Returns the number of bits of space actually in use
by this BitN to represent bit values.
|
java.lang.String |
toString()
toString - return a display representation of an PLI representation of the BIT(n)
|
static BitN |
valueOf(byte[] bytes)
valueOf - Returns a new bit set containing all the bits in the given byte array.
|
static BitN |
valueOf(java.nio.ByteBuffer bb)
valueOf - Returns a new bit set containing all the bits in the given
byte buffer between its position and limit.
|
static BitN |
valueOf(long[] longs)
valueOf - Returns a new bit set containing all the bits in the given byte array.
|
static BitN |
valueOf(java.nio.LongBuffer lb)
valueOf - Returns a new bit set containing all the bits in the given
byte buffer between its position and limit.
|
public BitN()
public BitN(int n)
n
- - the size of this BIT(n)public BitN(java.util.BitSet set, int n)
set
- - the BitSet from which to constructn
- - the number of bits to maintain in this BIT(n)public BitN(long[] longs, int n)
longs
- - long[] containing little-endian values for the BitNn
- - the number of bits to maintain in this BIT(n)public BitN(byte[] bytes, int n)
bytes
- - byte[] containing little-endian values for the BitNn
- - the number of bits to maintain in this BIT(n)public BitN(java.lang.String str, int n)
str
- - String containing '00_0 101'Bn
- - the number of bits to maintain in this BIT(n)public BitN(BitN inBits)
inBits
- - input BitNpublic int cardinality()
cardinality
in class java.util.BitSet
public void clear()
clear
in class java.util.BitSet
public void clear(int bitIndex)
clear
in class java.util.BitSet
public void clear(int fromBigEndianBit, int toBigEndianBit)
clear
in class java.util.BitSet
public int compareTo(java.lang.Object arg)
compareTo
in interface java.lang.Comparable<java.lang.Object>
arg
- - another BitN to compare withpublic void flip(int bitIndex)
flip
in class java.util.BitSet
public void flip(int fromBigEndianBit, int toBigEndianBit)
flip
in class java.util.BitSet
public boolean get(int bitIndex)
get
in class java.util.BitSet
public BitN get(int fromBigEndianBit, int toBigEndianBit)
get
in class java.util.BitSet
public int length()
length
in class java.util.BitSet
public int nextClearBit(int fromIndex)
nextClearBit
in class java.util.BitSet
fromIndex
- - start looking at this indexpublic int nextSetBit(int fromIndex)
nextSetBit
in class java.util.BitSet
fromIndex
- - start looking at this indexpublic int previousClearBit(int fromIndex)
previousClearBit
in class java.util.BitSet
fromIndex
- - start looking at this indexpublic int previousSetBit(int fromIndex)
previousSetBit
in class java.util.BitSet
fromIndex
- - start looking at this indexpublic void set(int bitIndex)
set
in class java.util.BitSet
public void set(int fromBigEndianBit, int toBigEndianBit)
set
in class java.util.BitSet
public void set(int fromBigEndianBit, int toBigEndianBit, boolean value)
set
in class java.util.BitSet
public int size()
size
in class java.util.BitSet
public java.lang.String toString()
toString
in class java.util.BitSet
public static BitN valueOf(byte[] bytes)
bytes
- - byte array to initializea
- BitN representing the bits in byte[]public static BitN valueOf(java.nio.ByteBuffer bb)
public static BitN valueOf(long[] longs)
longs
- - long array to initializea
- BitN representing the bits in byte[]public static BitN valueOf(java.nio.LongBuffer lb)
public static void main(java.lang.String[] args)
args
- - the real & imaginary part of operand "a" and "b", respectively