Exemplo n.º 1
0
        public override Container and(ArrayContainer value2)
        {
            ArrayContainer value1          = this;
            int            desiredCapacity = Math.Min(value1.getCardinality(), value2.getCardinality());
            ArrayContainer answer          = new ArrayContainer(desiredCapacity);

            answer.cardinality = Utility.unsignedIntersect2by2(value1.content,
                                                               value1.getCardinality(), value2.content,
                                                               value2.getCardinality(), answer.content);
            return(answer);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Performs an in-place intersection with another ArrayContainer.
 /// </summary>
 /// <param name="other">the other ArrayContainer to intersect</param>
 public override Container iand(ArrayContainer other)
 {
     cardinality = Utility.unsignedIntersect2by2(content,
                                                 getCardinality(), other.content,
                                                 other.getCardinality(), content);
     return(this);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Returns the elements of this ArrayContainer that are not in the
 /// other ArrayContainer.
 /// </summary>
 /// <param name="x">the other ArrayContainer</param>
 /// <returns>The modified container</returns>
 public override Container iandNot(ArrayContainer x)
 {
     this.cardinality = Utility.unsignedDifference(this.content,
                                                   this.getCardinality(), x.content,
                                                   x.getCardinality(), this.content);
     return(this);
 }
Exemplo n.º 4
0
        public override Container or(ArrayContainer value2)
        {
            ArrayContainer value1           = this;
            int            totalCardinality = value1.getCardinality() + value2.getCardinality();

            if (totalCardinality > DEFAULT_MAX_SIZE)
            {
                // it could be a bitmap!
                BitsetContainer bc = new BitsetContainer();
                for (int k = 0; k < value2.cardinality; ++k)
                {
                    ushort v = value2.content[k];
                    int    i = v >> 6;
                    bc.bitmap[i] |= (1L << v);
                }
                for (int k = 0; k < this.cardinality; ++k)
                {
                    ushort v = this.content[k];
                    int    i = v >> 6;
                    bc.bitmap[i] |= (1L << v);
                }
                bc.cardinality = 0;
                foreach (long k in bc.bitmap)
                {
                    bc.cardinality += Utility.longBitCount(k);
                }
                if (bc.cardinality <= DEFAULT_MAX_SIZE)
                {
                    return(bc.toArrayContainer());
                }
                return(bc);
            }
            else
            {
                // remains an array container
                int desiredCapacity = totalCardinality; // Math.min(BitmapContainer.MAX_CAPACITY,
                                                        // totalCardinality);
                ArrayContainer answer = new ArrayContainer(desiredCapacity);
                answer.cardinality = Utility.unsignedUnion2by2(value1.content,
                                                               value1.getCardinality(), value2.content,
                                                               value2.getCardinality(), answer.content);
                return(answer);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Returns the elements of this ArrayContainer that are not in the
        /// other ArrayContainer.
        /// </summary>
        /// <param name="x">the other ArrayContainer</param>
        /// <returns>A new container with the differences</returns>
        public override Container andNot(ArrayContainer x)
        {
            int desiredCapacity = this.getCardinality();
            var answer          = new ArrayContainer(desiredCapacity);

            // Compute the cardinality of the new container
            answer.cardinality = Utility.unsignedDifference(this.content,
                                                            desiredCapacity,
                                                            x.content,
                                                            x.getCardinality(),
                                                            answer.content);
            return(answer);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Returns the elements of this ArrayContainer that are not in the
        /// other ArrayContainer.
        /// </summary>
        /// <param name="x">the other ArrayContainer</param>
        /// <returns>A new container with the differences</returns>
        public override Container andNot (ArrayContainer x)
        {
            int desiredCapacity = this.getCardinality();
            var answer = new ArrayContainer(desiredCapacity);

            // Compute the cardinality of the new container
            answer.cardinality = Utility.unsignedDifference(this.content,
                                                            desiredCapacity,
                                                            x.content,
                                                            x.getCardinality(),
                                                            answer.content);
            return answer;

        }
Exemplo n.º 7
0
 public override Container or(ArrayContainer value2)
 {
     ArrayContainer value1 = this;
     int totalCardinality = value1.getCardinality() + value2.getCardinality();
     if (totalCardinality > DEFAULT_MAX_SIZE) {
         // it could be a bitmap!
         BitsetContainer bc = new BitsetContainer();
         for (int k = 0; k < value2.cardinality; ++k)
         {
             ushort v = value2.content[k];
             int i = v >> 6;
             bc.bitmap[i] |= (1L << v);
         }
         for (int k = 0; k < this.cardinality; ++k)
         {
             ushort v = this.content[k];
             int i = v >> 6;
             bc.bitmap[i] |= (1L << v);
         }
         bc.cardinality = 0;
         foreach (long k in bc.bitmap)
         {
             bc.cardinality += Utility.longBitCount(k);
         }
         if (bc.cardinality <= DEFAULT_MAX_SIZE)
             return bc.toArrayContainer();
         return bc;
     } else {
         // remains an array container
         int desiredCapacity = totalCardinality; // Math.min(BitmapContainer.MAX_CAPACITY,
                                                 // totalCardinality);
         ArrayContainer answer = new ArrayContainer(desiredCapacity);
         answer.cardinality = Utility.unsignedUnion2by2(value1.content,
                 value1.getCardinality(), value2.content,
                 value2.getCardinality(), answer.content);
         return answer;
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// Returns the elements of this ArrayContainer that are not in the
 /// other ArrayContainer.
 /// </summary>
 /// <param name="x">the other ArrayContainer</param>
 /// <returns>The modified container</returns>
 public override Container iandNot(ArrayContainer x)
 {
     this.cardinality = Utility.unsignedDifference(this.content,
         this.getCardinality(), x.content,
         x.getCardinality(), this.content);
     return this;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Performs an in-place intersection with another ArrayContainer.
 /// </summary>
 /// <param name="other">the other ArrayContainer to intersect</param>
 public override Container iand(ArrayContainer other)
 {
     cardinality = Utility.unsignedIntersect2by2(content,
         getCardinality(), other.content,
         other.getCardinality(), content);
     return this;
 }
Exemplo n.º 10
0
 public override Container and(ArrayContainer value2)
 {
     ArrayContainer value1 = this;
     int desiredCapacity = Math.Min(value1.getCardinality(), value2.getCardinality());
     ArrayContainer answer = new ArrayContainer(desiredCapacity);
     answer.cardinality = Utility.unsignedIntersect2by2(value1.content,
             value1.getCardinality(), value2.content,
             value2.getCardinality(), answer.content);
     return answer;
 }