public void Set(long position, bool val) { lock (_lock) { isDirty = true; if (_size < position && val == true) { _size = position; } var idx = (int)(position >> 16); Container c = null; if (_containers.TryGetValue(idx, out c) == false) { //if (Global.useSortedList) // c = new OffsetContainerSL(); //else c = new OffsetContainer(); // add container _containers.Add(idx, c); } c.Set(position & _MASK, val); //if (c.ChangeRequired()) // _containers[idx] = c.Change(); } }
public override Container Change() { if (ALLONE) { return(new BitmapContainer(true)); } if (CountOnes() == BSize) { return(new BitmapContainer(true)); } // create inverted if (CountZeros() < CHGOVER) { return(new InvertedContainer(Not().GetBitIndexes())); } Container c = null; //if (Global.useSortedList) // c = new OffsetContainerSL(); //else c = new OffsetContainer(); foreach (var i in GetBitIndexes()) { c.Set(i, true); } return(c); }
public void Deserialize(MGRBData input) { foreach (var c in input.c) { Container con = null; if (c.t == CTYPE.ALLONES) { con = new BitmapContainer(true); } else if (c.t == CTYPE.BITMAP) { List <ulong> list = new List <ulong>(); var dataLen = c.d.Length; for (int i = 0; i < dataLen; i += 8) { list.Add(ToULong(c.d, i)); } con = new BitmapContainer(list.ToArray()); } else if (c.t == CTYPE.OFFSET) { List <ushort> list = new List <ushort>(); var dataLen = c.d.Length; for (int i = 0; i < dataLen; i += 2) { list.Add(ToUShort(c.d, i)); } con = new OffsetContainer(list); } else if (c.t == CTYPE.INV) { List <ushort> list = new List <ushort>(); var dataLen = c.d.Length; for (int i = 0; i < dataLen; i += 2) { list.Add(ToUShort(c.d, i)); } con = new InvertedContainer(list); } //else //{ // List<ushort> list = new List<ushort>(); // var dataLen = c.d.Length; // for (int i = 0; i < dataLen; i += 2) // { // list.Add(ToUShort(c.d, i)); // } // con = new OffsetContainerSL(list); //} _containers.Add(c.i, con); } var k = _containers.Keys(); var l = k.Length - 1; if (l >= 0) { _size = (k[l] << 16) + _containers.GetValue(l).Size; } }