public class BitInt32 extends java.lang.Object implements IEquatable<BitInt32>, java.lang.Comparable<BitInt32>
| Modifier and Type | Field and Description |
|---|---|
static int |
Log2Size
Returns the Log2(Size).
|
static int |
Size
Returns the number of bits.
|
| Constructor and Description |
|---|
BitInt32()
Initializes a new instance of the BitInt32 with
all bits set to false.
|
BitInt32(BitInt32 x)
Initializes a new instance of the BitInt32 structure
using the supplied BitInt32 value.
|
BitInt32(boolean value)
Initializes a new instance of the BitInt32 with
all bits set to the specified bit value.
|
BitInt32(int value)
Initializes a new instance of the BitInt32 with
the specified Int32 value.
|
BitInt32(java.lang.String item)
Initializes a new instance of the BitInt32 structure
using the supplied String value.
|
| Modifier and Type | Method and Description |
|---|---|
int |
Allocate(int startWith)
Locates the position of the first occurrence of a
0 bit and sets this bit to 1.
|
boolean |
Any()
Tests whether any bit is set to 1.
|
boolean |
Any(boolean value)
Tests whether any bit is set to the specified
value.
|
boolean |
Any(int first,
int last)
Tests whether any bit is set to 1 in the specified range.
|
boolean |
Any(int first,
int last,
boolean value)
Tests whether any bit is set to the specified value
in the specified range.
|
void |
AssignAnd(BitInt32 x)
Performs the bitwise AND operation and assigns the
result to the current instance.
|
void |
AssignOr(BitInt32 x)
Performs the bitwise OR operation and assigns the
result to the current instance.
|
void |
AssignXor(BitInt32 x)
Performs the bitwise eXclusive OR operation and assigns the
result to the current instance.
|
static BitInt32 |
BitwiseAnd(BitInt32 x,
BitInt32 y)
Performs the bitwise AND operation.
|
static BitInt32 |
BitwiseOr(BitInt32 x,
BitInt32 y)
Performs the bitwise OR operation.
|
static BitInt32 |
BitwiseXor(BitInt32 x,
BitInt32 y)
Performs the bitwise eXclusive OR operation.
|
int |
compareTo(BitInt32 other)
Compares this instance to a specified BitInt32 and
returns an indication of their relative values.
|
int |
Count(boolean value)
Returns the number of bits with a specified value.
|
int |
Count(int first,
int last,
boolean value)
Counts the number of bits with a specified value in
the specified range.
|
static boolean |
Equal(BitInt32 x,
BitInt32 y)
Performs a logical comparison of the two BitInt32
parameters to determine if they are equal.
|
boolean |
equals(BitInt32 other)
Tests whether this instance is equal to a specified
BitInt32.
|
boolean |
Equals(BitInt32 other)
Tests whether this instance is equal to a specified
BitInt32.
|
boolean |
equals(java.lang.Object obj)
Tests whether this instance is equal to a specified
object.
|
int |
FindFirst(boolean value)
Locates the position of the first occurrence of a
bit that has a specified value.
|
int |
FindFirst(int startWith,
boolean value)
Locates the position of the first occurrence of a
bit that has a specified value.
|
int |
FindFirst(int first,
int last,
boolean value)
Locates the position of the first occurrence of a
bit that has a specified value in the specified range.
|
int |
FindLast(boolean value)
Locates the position of the last occurrence of a
bit that has a specified value.
|
int |
FindLast(int startWith,
boolean value)
Locates the position of the last occurrence of a
bit that has a specified value.
|
int |
FindLast(int first,
int last,
boolean value)
Locates the position of the last occurrence of a
bit that has a specified value in the specified range.
|
void |
Flip()
Toggles the value of every bit.
|
void |
Flip(int pos)
Toggles the value of the bit at a specified position.
|
void |
Flip(int first,
int last)
Toggles the value of every bit the range [first, last).
|
static BitInt32 |
FromInt32(int convertFrom)
Explicit conversion from Int32 to BitInt32.
|
boolean |
Get(int pos)
Gets the value of the bit at a specified position.
|
static boolean |
GreaterThan(BitInt32 x,
BitInt32 y)
Tests whether the value of a specified BitInt32
structure is greater than another value of BitInt32 structure.
|
static boolean |
GreaterThanOrEqual(BitInt32 x,
BitInt32 y)
Tests whether the value of a specified BitInt32 structure
is greater than or equal to another value of BitInt32 structure.
|
int |
hashCode()
Returns the hash code for this instance.
|
static BitInt32 |
LeftShift(BitInt32 x,
int count)
Shifts the bits in a BitInt32 to the left a specified
number of positions and returns the result.
|
void |
LeftShift(int count)
Shifts the bits in the current instance to the left
a specified number of positions.
|
static boolean |
LessThan(BitInt32 x,
BitInt32 y)
Tests whether the value of a specified BitInt32
structure is less than another value of BitInt32 structure.
|
static boolean |
LessThanOrEqual(BitInt32 x,
BitInt32 y)
Tests whether the value of a specified BitInt32 structure
is less than or equal to another value of BitInt32 structure.
|
static BitInt32 |
MaxValue()
Represents the largest possible value of BitInt32
(all bits set to 1).
|
static BitInt32 |
MinValue()
Represents the smallest possible value of BitInt32
(all bits set to 0).
|
boolean |
None()
Tests if none of the bits have been set to 1.
|
boolean |
None(boolean value)
Tests if none of the bits have been set to the specified
value.
|
boolean |
None(int first,
int last)
Tests if none of the bits have been set to 1 in the specified
range.
|
boolean |
None(int first,
int last,
boolean value)
Tests if none of the bits have been set to the specified value
in the specified range.
|
static boolean |
NotEqual(BitInt32 x,
BitInt32 y)
Performs a logical comparison of the two BitInt32
parameters to determine if they are equal.
|
static BitInt32 |
OnesComplement(BitInt32 x)
Inverts all the bits in a target BitInt32 and returns
the result.
|
static BitInt32 |
Parse(java.lang.String item)
Converts the String representation of an array of bits to its
BitInt32 equivalent.
|
void |
Reset()
Sets every bit to 0.
|
void |
Reset(int pos)
Sets the bit at a specified position to 0.
|
void |
Reset(int first,
int last)
Sets every bit to 0 in the range [first, last).
|
static BitInt32 |
RightShift(BitInt32 x,
int count)
Shifts the bits in a BitInt32 to the right a specified
number of positions and returns the result.
|
void |
RightShift(int count)
Shifts the bits in the current instance to the right
a specified number of positions.
|
void |
Set()
Sets every bit to 1.
|
void |
Set(int pos)
Sets the bit at a specified position to 1.
|
void |
Set(int first,
int last)
Sets every bit to 1 in the range [first, last).
|
void |
SetValue(int value)
Sets the signed value of the BitInt32.
|
static int |
ToInt32(BitInt32 convertFrom)
Explicit conversion from BitInt32 to Int32.
|
java.lang.String |
toString()
Converts the bit values to their equivalent
String representation.
|
int |
Value()
Gets the signed value of the BitInt32.
|
public static final int Size
public static final int Log2Size
public BitInt32()
public BitInt32(boolean value)
value - The value of the bits in the
new BitInt32.public BitInt32(int value)
value - The value of the Int32 in
the new BitInt32.public BitInt32(java.lang.String item)
item - The String to be converted.java.lang.RuntimeException - If the String does not
contain a parsable int.public BitInt32(BitInt32 x)
x - The BitInt32 to be copied.public int Value()
public void SetValue(int value)
value - The signed value of the BitInt32.public static BitInt32 MinValue()
public static BitInt32 MaxValue()
public boolean Get(int pos)
pos - The position of the bit to be tested for its value.java.lang.RuntimeException - Thrown when
the specified position is out of [0, Size - 1] range.public void Set()
public void Set(int pos)
pos - The position of the bit to be set to 1.java.lang.RuntimeException - Thrown when
the specified position is out of [0, Size - 1] range.public void Set(int first,
int last)
first - Position of the first bit in the range.last - Position that is one past the final
bit in the range.java.lang.RuntimeException - Thrown when first
is out of [0, Size - 1].public void Reset()
public void Reset(int pos)
pos - The position of the bit to be set to 0.java.lang.RuntimeException - Thrown when
the specified position is out of [0, Size - 1] range.public void Reset(int first,
int last)
first - Position of the first bit in the range.last - Position that is one past the final
bit in the range.java.lang.RuntimeException - Thrown when first
is out of [0, Size - 1] range.public void Flip()
public void Flip(int pos)
pos - The position of the bit to be toggled.java.lang.RuntimeException - Thrown when
the specified position is out of [0, Size - 1] range.public void Flip(int first,
int last)
first - Position of the first bit in the range.last - Position that is one past the final
bit in the range.java.lang.RuntimeException - Thrown when first
is out of [0, Size - 1] range.public int Count(boolean value)
value - The bit value to be counted.public int Count(int first,
int last,
boolean value)
first - Position of the first bit in the range.last - Position that is one past the final
bit in the range.value - The bit value to be counted.java.lang.RuntimeException - Thrown when first
is out of [0, Size - 1] rangepublic boolean Any()
public boolean Any(boolean value)
value - The value to be tested.public boolean Any(int first,
int last)
first - Position of the first bit in the range.last - Position that is one past the final
bit in the range.java.lang.RuntimeException - Thrown when first
is out of [0, Size - 1] range.public boolean Any(int first,
int last,
boolean value)
first - Position of the first bit in the range.last - Position that is one past the final
bit in the range.value - The value to be tested.java.lang.RuntimeException - Thrown when first
is out of [0, Size - 1] range.public boolean None()
public boolean None(boolean value)
value - The value to be tested.public boolean None(int first,
int last)
first - Position of the first bit in the range.last - Position that is one past the final
bit in the range.java.lang.RuntimeException - Thrown when first
is out of [0, Size - 1] range.public boolean None(int first,
int last,
boolean value)
first - Position of the first bit in the range.last - Position that is one past the final
bit in the range.value - The value to be tested.java.lang.RuntimeException - Thrown when first
is out of [0, Size - 1] range.public int FindFirst(boolean value)
value - The value to be searched for.public int FindFirst(int startWith,
boolean value)
startWith - Index of the position where the
search is to begin.value - The value to be searched for.java.lang.RuntimeException - Thrown when the
specified position is out of [0, Size - 1] range.public int FindFirst(int first,
int last,
boolean value)
value - The value to be searched for.first - Position of the first bit in the range.last - Position that is one past the final
bit in the range.java.lang.RuntimeException - Thrown when first
or last is out of [0, Size - 1] range.public int FindLast(boolean value)
value - The value to be searched for.public int FindLast(int startWith,
boolean value)
startWith - Index of the position where the
search is to begin.value - The value to be searched for.java.lang.RuntimeException - Thrown when
the specified position is out of [0, Size - 1] range.public int FindLast(int first,
int last,
boolean value)
value - The value to be searched for.first - Position of the first bit in the range.last - Position that is one past the final
bit in the range.java.lang.RuntimeException - Thrown when first
or last is out of [0, Size - 1] range.public java.lang.String toString()
Remarks: The first character in the String represents the first MSB set to one and the last character in the String represents the LSB.
toString in class java.lang.Objectpublic static BitInt32 Parse(java.lang.String item)
Remarks: The first character in the String represents the first MSB set to one and the last character in the String represents the LSB.
item - A String containing an array of bits to convert.java.lang.RuntimeException - If the String does not
contain a parsable BitInt32.public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - An object to compare with this instance.public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(BitInt32 other)
other - A BitInt32 to compare with this instance.public boolean Equals(BitInt32 other)
Equals in interface IEquatable<BitInt32>other - A BitInt32 to compare with this instance.public int compareTo(BitInt32 other)
compareTo in interface java.lang.Comparable<BitInt32>other - An object to compare, or a null reference.public static boolean Equal(BitInt32 x, BitInt32 y)
x - The left operand in the equality to be tested.y - The right operand in the equality to be tested.public static boolean NotEqual(BitInt32 x, BitInt32 y)
x - The left operand in the equality to be tested.y - The right operand in the equality to be tested.public static boolean LessThan(BitInt32 x, BitInt32 y)
x - The left operand in the inequality to be tested.y - The right operand in the inequality to be tested.public static boolean GreaterThan(BitInt32 x, BitInt32 y)
x - The left operand in the inequality to be tested.y - The right operand in the inequality to be tested.public static boolean LessThanOrEqual(BitInt32 x, BitInt32 y)
x - The left operand in the inequality to be tested.y - The right operand in the inequality to be tested.public static boolean GreaterThanOrEqual(BitInt32 x, BitInt32 y)
x - The left operand in the inequality to be tested.y - The right operand in the inequality to be tested.public static BitInt32 BitwiseAnd(BitInt32 x, BitInt32 y)
x - The left operand in the bitwise AND operation.y - The right operand in the bitwise AND operation.public void AssignAnd(BitInt32 x)
x - The right operand in the bitwise AND operation.public static BitInt32 BitwiseOr(BitInt32 x, BitInt32 y)
x - The left operand in the bitwise OR operation.y - The right operand in the bitwise OR operation.public void AssignOr(BitInt32 x)
x - The right operand in the bitwise OR operation.public static BitInt32 BitwiseXor(BitInt32 x, BitInt32 y)
x - The left operand in the bitwise eXclusive OR operation.y - The right operand in the bitwise eXclusive OR operation.public void AssignXor(BitInt32 x)
x - The right operand in the bitwise eXclusive OR operation.public static BitInt32 OnesComplement(BitInt32 x)
x - The operand in the bitwise complement operation.public static BitInt32 LeftShift(BitInt32 x, int count)
x - A BitInt32 object whose bit values are to be shifted.count - The number of positions to the left the bits are to be shifted.public void LeftShift(int count)
count - The number of positions to the left the bits
are to be shifted.public static BitInt32 RightShift(BitInt32 x, int count)
x - A BitInt32 object whose bit values are to be shifted.count - The number of positions to the right the bits are to be shifted.public void RightShift(int count)
count - The number of positions to the right the bits
are to be shifted.public static BitInt32 FromInt32(int convertFrom)
convertFrom - The Int32 value to be converted.public static int ToInt32(BitInt32 convertFrom)
convertFrom - The BitInt32 value to be converted.public int Allocate(int startWith)
startWith - Index of the position where the
allocate is to begin.java.lang.RuntimeException - Thrown when
the specified position is out of [0, Size - 1] range.Copyright© 2012 Progeneric Systems, Inc. All Rights Reserved.