C# Class CyrusBuilt.MonoPi.BitSet

Inheritance: ICloneable
Datei anzeigen Open project: cyrusbuilt/MonoPi Class Usage Examples

Public Methods

Method Description
And ( BitSet bs ) : void

Performs a logical AND of this target bit set with the argument bit set. This bit set is modified so that each bit in it has the value true if and only if it both initially had the value true and the corresponding bit in the specified bit set also had the value true.

AndNot ( BitSet bs ) : void

Clears all of the bits in this bit set whose corresponding bit is set in the specified bit set.

BitSet ( ) : System

Initializes a new instance of the CyrusBuilt.MonoPi.BitSet class. This is the default constructor.

BitSet ( Int32 nBits ) : System

Initializes a new instance of the CyrusBuilt.MonoPi.BitSet class whose intial size is large enough to explicitly represent bits with indices in the range of 0 through nBits - 1. All bits are intially false.

BitSet ( long words ) : System

Initializes a new instance of the CyrusBuilt.MonoPi.BitSet class from the specified array (words) as the internal representation. The last word (if there is one) must be non-zero.

Cardinality ( ) : Int32

Returns the number of bits set to true in this bit set.

Clear ( ) : void

Sets all of the bits in this CyrusBuilt.MonoPi.BitSet instance to false.

Clear ( Int32 pos ) : void

Sets the bit at the specified position (index) to false.

Clear ( Int32 from, Int32 to ) : void

Sets the bits from the specified from index (inclusive) to the specified to index (exclusive) to false.

Clone ( ) : Object

Creates a new object that is a copy of the current instance.

ContainsAll ( BitSet other ) : System.Boolean

This method is used by EnumSet for efficiency. It checks to see if this instance contains all the same bits as the specified bit set.

Equals ( object obj ) : bool

Determines whether the specified System.Object is equal to the current CyrusBuilt.MonoPi.BitSet.

Flip ( Int32 index ) : void

Sets the bit at the specified index to the compliment of its current value.

Flip ( Int32 from, Int32 to ) : void

Sets each bit from the specified from (inclusive) to the specified to (exclusive) to the complement of its current value.

Get ( Int32 from, Int32 to ) : BitSet

Returns a new bit set composed of bits from this bit set from the specified from index (inclusive) to the to index (exclusive).

Get ( Int32 pos ) : System.Boolean

Gets the value of the bit at the specified index.

GetHashCode ( ) : int

Gets a hash code value for this bit set. The hash code depends only on which bits are set within this instance.

Intersects ( BitSet bs ) : System.Boolean

Returns true if the specified bit set has any bits set to true that are also set to true in this bit set.

NextClearBit ( Int32 from ) : Int32

Returns the index of the first bit that is set to false that occurs on or after the specified starting index.

NextSetBit ( Int32 from ) : Int32

Returns the index of the first bit that is set to true that occurs on or after the specified starting index.

Or ( BitSet bs ) : void

Performs a logical OR of this bit set with the specified bit set. This bit set is modified so that a bit in it has the value true if and only if either it already had the value true or the corresponding bit in the specified bit set has the value true.

PreviousClearBit ( Int32 fromIndex ) : Int32

Returns the index of the nearest bit that is set to false that occurs on or before the specified starting index.

PreviousSetBit ( Int32 fromIndex ) : Int32

Returns the index of the nearest bit that is set to true that occurs on or before the specified starting index.

Set ( Int32 index ) : void

Sets the bit at the specified index to true.

Set ( Int32 index, System.Boolean value ) : void

Sets the bit at the specified index to the specified value.

Set ( Int32 from, Int32 to ) : void

Sets the bits from the specified from index (inclusive) to the specified to index (exclusive) to true.

Set ( Int32 from, Int32 to, System.Boolean value ) : void

Sets the bits from the specified from index (inclusive) to the specified to index (exclusive) to the specified value.

ToByteArray ( ) : Byte[]

Returns a new byte array containing all the bits in this bit set instance.

ToLongArray ( ) : long[]

Returns a new array of longs containing all the bits in this bit set instance.

ToString ( ) : string

Returns a System.String that represents the current CyrusBuilt.MonoPi.BitSet. For every index for which this bit set contains a bit in the set state, the decimal representation of that index is included in the result. Such indices are listed in order from lowest to highest, separated by ", " (a comma and a space) and surrounded by braces, resulting in the usual mathematical notation for a set of integers.

ValueOf ( Byte bytes ) : BitSet

Returns a new bit set containing all the bits in the specified byte array.

ValueOf ( long words ) : BitSet

Returns a new bit set containing all the bits in the specified array of longs.

XOr ( BitSet bs ) : void

Performs a logical XOR of this bit set with the specified bit set. This bit set is modified so that a bit in it has the value true if and only if one of the following statements holds true:
- The bit initially has the value true, and the corresponding bit in the specified bit set has the value false.

- Thi bit initially has the value false, and the corresponding bit in the specified bit set has the value true.

Private Methods

Method Description
CheckInvariants ( ) : void

Every public method must preserve the invariants. This method checks to see if this is true using assertions.

CheckRange ( Int32 fromIndex, Int32 toIndex ) : void

Checks to see if the specified "from" index and "to" index is a valid range of bit indices.

EnsureCapacity ( Int32 lastElt ) : void

Ensures that this BitSet can hold enough words.

ExpandTo ( Int32 wordIndex ) : void

Ensures that the BitSet can accomodate a given word index, temporarily violating the invariants. The caller must restore the invariants before returning to the user, possibly using CyrusBuilt.MonoPi.BitSet.RecalculateWordsInUse().

NumberOfTrailingZeros ( long n ) : Int32

Gets the number of trailing zeros in the specified long.

RecalculateWordsInUse ( ) : void

Sets the internal word use count field to the logical size in words of the bit set. WARNING: This method assumes that the number of words actually in use is less than or equal to the current value of the words in use field!!!

TrimToSize ( ) : void

Attempts to reduce internal storage used for the bits in this bit set. Calling this method may, but is not required to, affect the value returned by a subsequent call to the CyrusBuilt.MonoPi.BitSet.Size property.

WordIndex ( Int32 bitIndex ) : Int32

Given the specified bit index, returns the word index containing it.

Method Details

And() public method

Performs a logical AND of this target bit set with the argument bit set. This bit set is modified so that each bit in it has the value true if and only if it both initially had the value true and the corresponding bit in the specified bit set also had the value true.
/// cannot be null. ///
public And ( BitSet bs ) : void
bs BitSet /// A bit set. ///
return void

AndNot() public method

Clears all of the bits in this bit set whose corresponding bit is set in the specified bit set.
/// cannot be null. ///
public AndNot ( BitSet bs ) : void
bs BitSet /// The bit set with which to mask this instance. ///
return void

BitSet() public method

Initializes a new instance of the CyrusBuilt.MonoPi.BitSet class. This is the default constructor.
public BitSet ( ) : System
return System

BitSet() public method

Initializes a new instance of the CyrusBuilt.MonoPi.BitSet class whose intial size is large enough to explicitly represent bits with indices in the range of 0 through nBits - 1. All bits are intially false.
/// cannot be negative. ///
public BitSet ( Int32 nBits ) : System
nBits System.Int32 /// The initial size of the bit set. ///
return System

BitSet() public method

Initializes a new instance of the CyrusBuilt.MonoPi.BitSet class from the specified array (words) as the internal representation. The last word (if there is one) must be non-zero.
public BitSet ( long words ) : System
words long /// The array (words) to compose this instance from. ///
return System

Cardinality() public method

Returns the number of bits set to true in this bit set.
public Cardinality ( ) : Int32
return System.Int32

Clear() public method

Sets all of the bits in this CyrusBuilt.MonoPi.BitSet instance to false.
public Clear ( ) : void
return void

Clear() public method

Sets the bit at the specified position (index) to false.
/// cannot be less than zero. ///
public Clear ( Int32 pos ) : void
pos System.Int32 /// The index of the bit to be cleared. ///
return void

Clear() public method

Sets the bits from the specified from index (inclusive) to the specified to index (exclusive) to false.
/// is less than zero - or - /// is less than zero - or - /// is greater than . ///
public Clear ( Int32 from, Int32 to ) : void
from System.Int32 /// The index of the first bit to be cleared. ///
to System.Int32 /// The index after the last bit to be cleared. ///
return void

Clone() public method

Creates a new object that is a copy of the current instance.
public Clone ( ) : Object
return Object

ContainsAll() public method

This method is used by EnumSet for efficiency. It checks to see if this instance contains all the same bits as the specified bit set.
public ContainsAll ( BitSet other ) : System.Boolean
other BitSet /// The bit set to check. ///
return System.Boolean

Equals() public method

Determines whether the specified System.Object is equal to the current CyrusBuilt.MonoPi.BitSet.
public Equals ( object obj ) : bool
obj object /// The to compare with the current . ///
return bool

Flip() public method

Sets the bit at the specified index to the compliment of its current value.
/// cannot be less than zero. ///
public Flip ( Int32 index ) : void
index System.Int32 /// The index of the bit to flip. ///
return void

Flip() public method

Sets each bit from the specified from (inclusive) to the specified to (exclusive) to the complement of its current value.
/// is less than zero - or - /// is less than zero - or - /// is greater than . ///
public Flip ( Int32 from, Int32 to ) : void
from System.Int32 /// The index of the first bit to flip. ///
to System.Int32 /// The index after the last bit to flip. ///
return void

Get() public method

Returns a new bit set composed of bits from this bit set from the specified from index (inclusive) to the to index (exclusive).
/// is less than zero - or - /// is less than zero - or - /// is greater than . ///
public Get ( Int32 from, Int32 to ) : BitSet
from System.Int32 /// The index of the first bit to include. ///
to System.Int32 /// The index after the last bit to include. ///
return BitSet

Get() public method

Gets the value of the bit at the specified index.
/// cannot be less than zero. ///
public Get ( Int32 pos ) : System.Boolean
pos System.Int32 /// The index at which to get the bit value. ///
return System.Boolean

GetHashCode() public method

Gets a hash code value for this bit set. The hash code depends only on which bits are set within this instance.
public GetHashCode ( ) : int
return int

Intersects() public method

Returns true if the specified bit set has any bits set to true that are also set to true in this bit set.
public Intersects ( BitSet bs ) : System.Boolean
bs BitSet /// The bit set to intersect with. ///
return System.Boolean

NextClearBit() public method

Returns the index of the first bit that is set to false that occurs on or after the specified starting index.
/// cannot be less than zero. ///
public NextClearBit ( Int32 from ) : Int32
from System.Int32 /// The index to start checking from (inclusive). ///
return System.Int32

NextSetBit() public method

Returns the index of the first bit that is set to true that occurs on or after the specified starting index.
/// cannot be less than zero. ///
public NextSetBit ( Int32 from ) : Int32
from System.Int32 /// The index to start checking from (inclusive). ///
return System.Int32

Or() public method

Performs a logical OR of this bit set with the specified bit set. This bit set is modified so that a bit in it has the value true if and only if either it already had the value true or the corresponding bit in the specified bit set has the value true.
/// cannot be null. ///
public Or ( BitSet bs ) : void
bs BitSet /// A bit set. ///
return void

PreviousClearBit() public method

Returns the index of the nearest bit that is set to false that occurs on or before the specified starting index.
/// cannot be less than zero. ///
public PreviousClearBit ( Int32 fromIndex ) : Int32
fromIndex System.Int32 /// The index to start checking from (inclusive). ///
return System.Int32

PreviousSetBit() public method

Returns the index of the nearest bit that is set to true that occurs on or before the specified starting index.
/// cannot be less than zero. ///
public PreviousSetBit ( Int32 fromIndex ) : Int32
fromIndex System.Int32 /// The index to start checking from (inclusive). ///
return System.Int32

Set() public method

Sets the bit at the specified index to true.
/// cannot be less than zero. ///
public Set ( Int32 index ) : void
index System.Int32 /// The index of the bit to set. ///
return void

Set() public method

Sets the bit at the specified index to the specified value.
/// cannot be less than zero. ///
public Set ( Int32 index, System.Boolean value ) : void
index System.Int32 /// The index of the bit to set. ///
value System.Boolean /// The value to set. ///
return void

Set() public method

Sets the bits from the specified from index (inclusive) to the specified to index (exclusive) to true.
/// is less than zero - or - /// is less than zero - or - /// is greater than . ///
public Set ( Int32 from, Int32 to ) : void
from System.Int32 /// The index of the first bit to set. ///
to System.Int32 /// The index after the last bit to set. ///
return void

Set() public method

Sets the bits from the specified from index (inclusive) to the specified to index (exclusive) to the specified value.
/// is less than zero - or - /// is less than zero - or - /// is greater than . ///
public Set ( Int32 from, Int32 to, System.Boolean value ) : void
from System.Int32 /// The index of the first bit to set. ///
to System.Int32 /// The index after the last bit to set. ///
value System.Boolean /// The value to set. ///
return void

ToByteArray() public method

Returns a new byte array containing all the bits in this bit set instance.
public ToByteArray ( ) : Byte[]
return Byte[]

ToLongArray() public method

Returns a new array of longs containing all the bits in this bit set instance.
public ToLongArray ( ) : long[]
return long[]

ToString() public method

Returns a System.String that represents the current CyrusBuilt.MonoPi.BitSet. For every index for which this bit set contains a bit in the set state, the decimal representation of that index is included in the result. Such indices are listed in order from lowest to highest, separated by ", " (a comma and a space) and surrounded by braces, resulting in the usual mathematical notation for a set of integers.
public ToString ( ) : string
return string

ValueOf() public static method

Returns a new bit set containing all the bits in the specified byte array.
public static ValueOf ( Byte bytes ) : BitSet
bytes Byte /// A byte array containing a little-endian representation of a /// sequence of bits to be used as the intial set of the new bit set. ///
return BitSet

ValueOf() public static method

Returns a new bit set containing all the bits in the specified array of longs.
public static ValueOf ( long words ) : BitSet
words long /// A long array containing a little-endian representation of a /// sequence of bits to be used as the intial bits of the new /// bit set. ///
return BitSet

XOr() public method

Performs a logical XOR of this bit set with the specified bit set. This bit set is modified so that a bit in it has the value true if and only if one of the following statements holds true:
- The bit initially has the value true, and the corresponding bit in the specified bit set has the value false.

- Thi bit initially has the value false, and the corresponding bit in the specified bit set has the value true.
/// cannot be null. ///
public XOr ( BitSet bs ) : void
bs BitSet /// A bit set. ///
return void