/// <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); }
/// <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; }
/// <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); }