/// <summary> /// Returns a wrapper for the specified <see cref="Vector2DArrayList"/> /// ensuring that all elements are unique. /// </summary> /// <param name="collection">The <see cref="Vector2DArrayList"/> to wrap.</param> /// <returns> /// A wrapper around <paramref name="collection"/> ensuring that all elements are unique. /// </returns> /// <exception cref="ArgumentException"> /// <paramref name="collection"/> contains duplicate elements.</exception> /// <exception cref="ArgumentNullException"> /// <paramref name="collection"/> is a null reference.</exception> /// <remarks><para> /// The <b>Unique</b> wrapper provides a set-like collection by ensuring /// that all elements in the <see cref="Vector2DArrayList"/> are unique. /// </para><para> /// <b>Unique</b> raises an <see cref="ArgumentException"/> if the specified /// <paramref name="collection"/> contains any duplicate elements. The returned /// wrapper raises a <see cref="NotSupportedException"/> whenever the user attempts /// to add an element that is already contained in the <b>Vector2DArrayList</b>. /// </para><para> /// <strong>Note:</strong> The <b>Unique</b> wrapper reflects any changes made /// to the underlying <paramref name="collection"/>, including the possible /// creation of duplicate elements. The uniqueness of all elements is therefore /// no longer assured if the underlying collection is manipulated directly. /// </para></remarks> public static Vector2DArrayList Unique(Vector2DArrayList collection) { if (collection == null) throw new ArgumentNullException("collection"); for (int i = collection.Count - 1; i > 0; i--) if (collection.IndexOf(collection[i]) < i) throw new ArgumentException("collection", "Argument cannot contain duplicate elements."); return new UniqueList(collection); }