Beispiel #1
0
 /// <summary>
 ///  Sort a pair of Arrays (keys and values). The keys are sorted and
 ///  the values are reordered so that each key still has the same value.
 /// </summary>
 /// <typeparam name="U">Type of Key items</typeparam>
 /// <typeparam name="V">Type of Value items</typeparam>
 /// <param name="keys">Key Array (will be sorted in order)</param>
 /// <param name="items">Value array (will be reordered to match keys)</param>
 public static void SortKeysAndItems <U, V>(PartialArray <U> keys, PartialArray <V> items)
 {
     if (keys.Count != items.Count)
     {
         throw new InvalidOperationException("Can't sort key and item arrays of different lengths.");
     }
     Array.Sort(keys._array, items._array, 0, keys.Count);
 }
Beispiel #2
0
        /// <summary>
        ///  Copy a PartialArray into another one.
        /// </summary>
        /// <param name="other">PartialArray to copy values to</param>
        public void CopyTo(ref PartialArray <T> other)
        {
            if (other.Capacity < this.Count)
            {
                other._array = new T[this.Count];
            }

            System.Array.Copy(_array, other._array, this.Count);
            other.Count        = this.Count;
            other.IsStaticSize = this.IsStaticSize;
        }