예제 #1
0
 public void AddIndexKey(MySqlKeyDefinition index)
 {
     if (IndexKeys == null)
     {
         IndexKeys = new HashSet <MySqlKeyDefinition>();
     }
     IndexKeys.Add(index);
 }
예제 #2
0
 internal void Add(int index, SparseCell cell)
 {
     if (Count == 0)
     {
         IndexKeys.Add(index);
         FirstIndex = LastIndex = index;
         Count      = 1;
         Cells.Add(cell);
     }
     else if (index > LastIndex)
     {
         IndexKeys.Add(index);
         Cells.Add(cell);
         LastIndex = index;
         Count++;
     }
     else if (index < FirstIndex)
     {
         IndexKeys.Insert(0, index);
         Cells.Insert(0, cell);
         FirstIndex = index;
         Count++;
     }
     else //inserting time at some intermediate value
     {
         var upper = Count - 1;
         var lower = 0;
         var i     = lower + (upper - lower) / 2;
         while (true)
         {
             if (index > IndexKeys[i])
             {
                 if (lower == i)
                 {
                     i++;
                     break;
                 }
                 lower = i;
             }
             else if (index > IndexKeys[i - 1])
             {
                 break;
             }
             else
             {
                 upper = i;
             }
             i = lower + (upper - lower) / 2;
         }
         IndexKeys.Insert(i, index);
         Cells.Insert(i, cell);
         Count++;
     }
 }