Beispiel #1
0
 public IntArray(IntArray array)
 {
     this.ordered = array.ordered;
     size = array.size;
     items = new int[size];
     System.Array.Copy(array.items, 0, items, 0, size);
 }
Beispiel #2
0
 public void AddAll(IntArray array, int offset, int Length)
 {
     if (offset + Length > array.size)
     {
         throw new Exception(
                 "offset + Length must be <= size: " + offset + " + "
                         + Length + " <= " + array.size);
     }
     AddAll(array.items, offset, Length);
 }
Beispiel #3
0
 private bool BatchRemove(IntArray c, bool complement)
 {
     int[] data = this.items;
     int r = 0, w = 0;
     bool modified = false;
     try
     {
         for (; r < size; r++)
         {
             if (c.Contains(data[r]) == complement)
             {
                 data[w++] = data[r];
             }
         }
     }
     finally
     {
         if (r != size)
         {
             System.Array.Copy((Array)(data), r, (Array)(data), w, size - r);
             w += size - r;
         }
         if (w != size)
         {
             for (int i = w; i < size; i++)
             {
                 data[i] = -1;
             }
             size = w;
             modified = true;
         }
     }
     return modified;
 }
Beispiel #4
0
 public bool RemoveAll(IntArray c)
 {
     return BatchRemove(c, false);
 }
Beispiel #5
0
 public bool RetainAll(IntArray c)
 {
     return BatchRemove(c, true);
 }
Beispiel #6
0
 public bool Part(IntArray c)
 {
     int cc = 0;
     for (int i = 0; i < c.size; i++)
     {
         if (Contains(c.items[i]))
         {
             cc++;
         }
     }
     return cc != 0;
 }
Beispiel #7
0
 public bool ContainsAll(IntArray c)
 {
     for (int i = 0; i < c.size; i++)
     {
         if (!Contains(c.items[i]))
         {
             return false;
         }
     }
     return true;
 }
Beispiel #8
0
 public void AddAll(IntArray array)
 {
     AddAll(array, 0, array.size);
 }