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; } }
private static Container containerOR(Container ca, Container cb) { BitmapContainer a = null; BitmapContainer b = null; if (ca is BitmapContainer) { a = (BitmapContainer)ca; } else { a = (BitmapContainer)ca.Change(); } if (cb is BitmapContainer) { b = (BitmapContainer)cb; } else { b = (BitmapContainer)cb.Change(); } var av = a.Values(); var bv = b.Values(); var la = av != null ? av.Length : 1024; var lb = bv != null ? bv.Length : 1024; var max = la; if (lb > max) { max = lb; } List <ulong> vals = new List <ulong>(); for (int i = 0; i < max; i++) { ulong ua = 0; ulong ub = 0; if (av != null && i < la) { ua = av[i]; } if (bv != null && i < lb) { ub = bv[i]; } vals.Add(ua | ub); } return(new BitmapContainer(vals.ToArray())); }
private static Container containerAND(Container ca, Container cb) { BitmapContainer a = null; BitmapContainer b = null; if (ca is BitmapContainer) { a = (BitmapContainer)ca; } else { a = (BitmapContainer)ca.Change(); } if (cb is BitmapContainer) { b = (BitmapContainer)cb; } else { b = (BitmapContainer)cb.Change(); } var av = a.Values(); var bv = b.Values(); var la = av != null ? av.Length : 1024; var lb = bv != null ? bv.Length : 1024; var min = la; if (lb < min) { min = lb; } List <ulong> vals = new List <ulong>(); for (int i = 0; i < min; i++) { ulong ua = ulong.MaxValue; ulong ub = ulong.MaxValue; if (av != null) { ua = av[i]; } if (bv != null) { ub = bv[i]; } vals.Add(ua & ub); } return(new BitmapContainer(vals.ToArray())); }
public override Container ToBitmap() { lock (_lock) { var c = new BitmapContainer(); foreach (var i in _values) { c.Set(i, true); } return(c); } }
public override Container ToBitmap() { lock (_lock) { var b = new BitmapContainer(); foreach (var i in GetBitIndexes()) { b.Set(i, true); } return(b); } }
public override Container Change() { //if(CountZeros()<CHGOVER) //{ // // FIXx : return inverted //} lock (_lock) { var c = new BitmapContainer(); foreach (var i in _values) { c.Set(i, true); } return(c); } }