C# Class BitsetsNET.RLEBitset

Inheritance: IBitset
Show file Open project: BitSetsNet/BitSetsNet Class Usage Examples

Public Methods

Method Description
And ( IBitset otherSet ) : IBitset
AndWith ( IBitset otherSet ) : void

Intersects an IBitset with another IBitset, modifying the first IBitset rather than creating a new IBitset

Cardinality ( ) : int

Returns the number of 1's in the uncompressed set (i.e. 1's only).

Clone ( ) : IBitset

Returns a deep copy of this RLEBitset.

CreateFrom ( BitArray bits ) : IBitset

Creates a RLEBitset from a BitArray.

CreateFrom ( int indices ) : IBitset

Creates a RLEBitset from an array of indices. Each value in the input array represents the position (i.e. index) of a 1.

CreateFrom ( int indices, int capacity ) : IBitset

Creates a RLEBitset from an array of indices and a capacity value. Each value in the input array represents the position (i.e. index) of a 1. The capity represents the length of the uncompressed data.

Deserialize ( System.Stream stream ) : RLEBitset

Read a binary serialization of a RLE bitset, as written by the Serialize method.

Difference ( IBitset otherSet ) : IBitset

Performs the set difference, defined as the set in A and not in B.

DifferenceWith ( IBitset otherSet ) : void

Performs the set difference, defined as the set in A and not in B.

Equals ( object otherSet ) : bool

Determines if the other IBitset is equal to this one.

Flip ( int index ) : void

Flips the bit at the specified index.

Flip ( int start, int end ) : void

Flips each bit in the specified range

Get ( int index ) : bool

Gets the boolean value at the given index.

GetEnumerator ( ) : IEnumerator

Get an enumerator of the set indices of this bitset. Meaning, it returns the indicies where the value is set to "true" or "1".

GetHashCode ( ) : int
GetObjectData ( SerializationInfo info, StreamingContext context ) : void
Length ( ) : int

Returns the length of the uncompressed set (i.e. 1's and 0's).

Not ( ) : IBitset

Inverts all the values in the current IBitset, so that elements set to true are changed to false, and elements set to false are changed to true.

Or ( IBitset otherSet ) : IBitset
OrWith ( IBitset otherSet ) : void
Serialize ( System.Stream stream ) : void

Write a binary serialization of this RLE bitset.

Set ( int index, bool value ) : void

Sets the bit at a specific position in the IBitset to the specified value.

Set ( int start, int end, bool value ) : void

For indices in the range [start, end] add the index to the set if the value is true, otherwise remove it.

SetRange ( int startIndex, int count, bool value ) : void

Sets all bits in the given range to the specified value.

ToBitArray ( ) : BitArray

Returns the contents of this set as a bit array where the value is set to true for each index that is a member of this set

Private Methods

Method Description
AddRunToRLE ( RLEBitset &currRLE, Run runToAdd ) : void

Helper function for Or operations. Adds the given run to the run-array by. Either: a) merges it with the previous run if overlap with previous in array b) adds it as next run if no overlap with previous in array

GetRange ( int start, int end ) : List
Merge ( Run &current, Run &next, bool shouldInsert, int index ) : bool
MergeOtherRun ( RLEBitset other, Run &current, int &nextThisIndex, int &nextOtherIndex ) : void
TryCreateIntersection ( Run runA, Run runB, Run &output ) : bool
TryCreateUnion ( Run runA, Run runB, Run &output ) : bool
mergeExistingRun ( Run &current, int &nextIndex ) : void

Method Details

And() public method

public And ( IBitset otherSet ) : IBitset
otherSet IBitset
return IBitset

AndWith() public method

Intersects an IBitset with another IBitset, modifying the first IBitset rather than creating a new IBitset
public AndWith ( IBitset otherSet ) : void
otherSet IBitset the other IBitset
return void

Cardinality() public method

Returns the number of 1's in the uncompressed set (i.e. 1's only).
public Cardinality ( ) : int
return int

Clone() public method

Returns a deep copy of this RLEBitset.
public Clone ( ) : IBitset
return IBitset

CreateFrom() public static method

Creates a RLEBitset from a BitArray.
public static CreateFrom ( BitArray bits ) : IBitset
bits System.Collections.BitArray a BitArray
return IBitset

CreateFrom() public static method

Creates a RLEBitset from an array of indices. Each value in the input array represents the position (i.e. index) of a 1.
public static CreateFrom ( int indices ) : IBitset
indices int an array of integers representing the positions of 1's
return IBitset

CreateFrom() public static method

Creates a RLEBitset from an array of indices and a capacity value. Each value in the input array represents the position (i.e. index) of a 1. The capity represents the length of the uncompressed data.
public static CreateFrom ( int indices, int capacity ) : IBitset
indices int an array of integers representing the positions of 1's
capacity int the length of the uncompressed array
return IBitset

Deserialize() public static method

Read a binary serialization of a RLE bitset, as written by the Serialize method.
public static Deserialize ( System.Stream stream ) : RLEBitset
stream System.Stream The stream to read from.
return RLEBitset

Difference() public method

Performs the set difference, defined as the set in A and not in B.
public Difference ( IBitset otherSet ) : IBitset
otherSet IBitset the other IBitset
return IBitset

DifferenceWith() public method

Performs the set difference, defined as the set in A and not in B.
public DifferenceWith ( IBitset otherSet ) : void
otherSet IBitset the other IBitset
return void

Equals() public method

Determines if the other IBitset is equal to this one.
public Equals ( object otherSet ) : bool
otherSet object the other IBitset
return bool

Flip() public method

Flips the bit at the specified index.
public Flip ( int index ) : void
index int Index to be flipped
return void

Flip() public method

Flips each bit in the specified range
public Flip ( int start, int end ) : void
start int Start of range
end int End of range
return void

Get() public method

Gets the boolean value at the given index.
public Get ( int index ) : bool
index int an index
return bool

GetEnumerator() public method

Get an enumerator of the set indices of this bitset. Meaning, it returns the indicies where the value is set to "true" or "1".
public GetEnumerator ( ) : IEnumerator
return IEnumerator

GetHashCode() public method

public GetHashCode ( ) : int
return int

GetObjectData() public method

public GetObjectData ( SerializationInfo info, StreamingContext context ) : void
info System.Runtime.Serialization.SerializationInfo
context System.Runtime.Serialization.StreamingContext
return void

Length() public method

Returns the length of the uncompressed set (i.e. 1's and 0's).
public Length ( ) : int
return int

Not() public method

Inverts all the values in the current IBitset, so that elements set to true are changed to false, and elements set to false are changed to true.
public Not ( ) : IBitset
return IBitset

Or() public method

public Or ( IBitset otherSet ) : IBitset
otherSet IBitset
return IBitset

OrWith() public method

public OrWith ( IBitset otherSet ) : void
otherSet IBitset
return void

Serialize() public method

Write a binary serialization of this RLE bitset.
public Serialize ( System.Stream stream ) : void
stream System.Stream The stream to write to.
return void

Set() public method

Sets the bit at a specific position in the IBitset to the specified value.
public Set ( int index, bool value ) : void
index int The zero-based index of the bit to set.
value bool The Boolean value to assign to the bit.
return void

Set() public method

For indices in the range [start, end] add the index to the set if the value is true, otherwise remove it.
public Set ( int start, int end, bool value ) : void
start int the index to start from (inclusive)
end int the index to stop at (exclusive)
value bool
return void

SetRange() public method

Sets all bits in the given range to the specified value.
public SetRange ( int startIndex, int count, bool value ) : void
startIndex int The zero-based start position of the range.
count int The number of bits in the range.
value bool The Boolean value to assign to the bits.
return void

ToBitArray() public method

Returns the contents of this set as a bit array where the value is set to true for each index that is a member of this set
public ToBitArray ( ) : BitArray
return System.Collections.BitArray