示例#1
0
        /// <summary>
        /// Create a new instance with the same contents and indexes of this list
        /// </summary>
        public UnorderedList <T> Clone()
        {
            var newList = new UnorderedList <T>(elements.Length, step_increment);

            CopyTo(newList);
            return(newList);
        }
示例#2
0
 /// <summary>
 /// Create a new instance with the same contents and indexes of this list
 /// </summary>
 public void CopyTo(UnorderedList <T> to, int offset = 0)
 {
     to.EnsureCapacity(Count + offset);
     for (int i = 0; i < Count; i++)
     {
         to.elements[i + offset] = elements[i];
     }
     to.Count = Count;
 }
示例#3
0
 /// <summary>
 /// Compare 2 lists element by element with the method Equals
 /// Boxing with structs, generating garbage
 /// </summary>
 public bool ArrayEquals(UnorderedList <T> other)
 {
     if (other.Count != Count)
     {
         return(false);
     }
     for (int i = 0; i < Count; i++)
     {
         if (!elements[i].Equals(other.elements[i]))
         {
             return(false);
         }
     }
     return(true);
 }