public AggregateBucket <T> GetOrCreateBucket(int level)
        {
            AggregateBucket <T> aggregateBucket = null;

            for (int i = 0; i < this.m_buckets.Count; i++)
            {
                if (aggregateBucket != null)
                {
                    break;
                }
                AggregateBucket <T> aggregateBucket2 = this.m_buckets[i];
                if (aggregateBucket2.Level == level)
                {
                    aggregateBucket = aggregateBucket2;
                }
                else if (aggregateBucket2.Level > level)
                {
                    aggregateBucket = this.CreateBucket(level);
                    this.m_buckets.Insert(i, aggregateBucket);
                }
            }
            if (aggregateBucket == null)
            {
                aggregateBucket = this.CreateBucket(level);
                this.m_buckets.Add(aggregateBucket);
            }
            return(aggregateBucket);
        }
 public void MergeFrom(BucketedAggregatesCollection <T> otherCol)
 {
     if (otherCol != null)
     {
         foreach (AggregateBucket <T> bucket in otherCol.Buckets)
         {
             AggregateBucket <T> orCreateBucket = this.GetOrCreateBucket(bucket.Level);
             orCreateBucket.Aggregates.AddRange(bucket.Aggregates);
         }
     }
 }