public static CreateFrom ( |
||
bits | a BitArray | |
return | IBitset |
public static IBitset CreateFrom(BitArray bits)
{
RLEBitset rtnVal = new RLEBitset();
rtnVal.length = bits.Length;
Run currRun = new Run();
for (int i = 0; i < bits.Count; i++)
{
if (bits.Get(i) == true)
{
currRun.StartIndex = i;
currRun.EndIndex = i;
for (int j = i + 1; j < bits.Count; j++)
{
if (bits.Get(j))
{
currRun.EndIndex = j;
}
else
{
break;
}
}
i = currRun.EndIndex; //move the counter to the end of the run we just found
rtnVal.runArray.Add(currRun);
currRun = new Run();
}
}
return rtnVal;
}
RLEBitset::CreateFrom ( int indices ) : IBitset | |
RLEBitset::CreateFrom ( int indices, int capacity ) : IBitset |
/// <summary> /// Creates a RLEBitset from an array of indices. /// Each value in the input array represents the position (i.e. index) of a 1. /// </summary> /// <param name="indices">an array of integers representing the positions of 1's</param> /// <returns>an RLEBitset</returns> public static IBitset CreateFrom(int[] indices) { int capacity = 0; if (indices.Length > 0) { capacity = indices.Max() + 1; } return(RLEBitset.CreateFrom(indices, capacity)); }