Exemplo n.º 1
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Matrix4F"/> structure with the specified values.
		/// </summary>
		/// <param name="elements">An array containing the matrix values in row-major order.</param>
		public Matrix4D(DoubleArrayList elements)
		{
			Debug.Assert(elements != null);
			Debug.Assert(elements.Count >= 16);

			_m11 = elements[0]; _m12 = elements[1]; _m13 = elements[2]; _m14 = elements[3];
			_m21 = elements[4]; _m22 = elements[5]; _m23 = elements[6]; _m24 = elements[7];
			_m31 = elements[8]; _m32 = elements[9]; _m33 = elements[10]; _m34 = elements[11];
			_m41 = elements[12]; _m42 = elements[13]; _m43 = elements[14]; _m44 = elements[15];
		}
        /// <summary>
        /// Initializes a new instance of the <see cref="Matrix2D"/> structure with the specified values.
        /// </summary>
        /// <param name="elements">An array containing the matrix values in row-major order.</param>
        public Matrix2D(DoubleArrayList elements)
        {
            Debug.Assert(elements != null);
            Debug.Assert(elements.Count >= 4);

            _m11 = elements[0]; _m12 = elements[1];
            _m21 = elements[2]; _m22 = elements[3];
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Matrix3F"/> structure with the specified values.
        /// </summary>
        /// <param name="elements">An array containing the matrix values in row-major order.</param>
        public Matrix3D(DoubleArrayList elements)
        {
            Debug.Assert(elements != null);
            Debug.Assert(elements.Count >= 9);

            _m11 = elements[0]; _m12 = elements[1]; _m13 = elements[2];
            _m21 = elements[3]; _m22 = elements[4]; _m23 = elements[5];
            _m31 = elements[6]; _m32 = elements[7]; _m33 = elements[8];
        }
 /// <summary>
 /// Fills the specified array of doubles with random numbers in the interval [0,1).
 /// </summary>
 /// <param name="array">An array of double-precision floating point numbers.</param>
 public void Fill(DoubleArrayList array)
 {
     for (int i = 0; i < array.Count; i++)
     {
         array[i] = NextDouble();
     }
 }
        /// <summary>
        /// Creates a deep copy of the <see cref="DoubleArrayList"/>.
        /// </summary>
        /// <returns>A deep copy of the <see cref="DoubleArrayList"/>.</returns>
        /// <remarks><para>
        /// <b>Copy</b> has the same effect as <see cref="Clone"/> 
        /// because <see cref="double"/> is a value type.
        /// </para><para>
        /// <b>Copy</b> never returns a <b>DoubleArrayList</b> with a read-only,
        /// synchronized, or unique wrapper, whereas <b>Clone</b> preserves any
        /// wrappers around this <b>DoubleArrayList</b>.
        /// </para></remarks>
        public virtual DoubleArrayList Copy()
        {
            DoubleArrayList collection = new DoubleArrayList(this._count);

            Array.Copy(this._array, 0, collection._array, 0, this._count);
            collection._count = this._count;
            collection._version = this._version;

            return collection;
        }
        /// <overloads>
        /// Adds a range of elements to the end of the <see cref="DoubleArrayList"/>.
        /// </overloads>
        /// <summary>
        /// Adds the elements of another collection to the end of the <see cref="DoubleArrayList"/>.
        /// </summary>
        /// <param name="collection">The <see cref="DoubleArrayList"/> whose elements
        /// should be added to the end of the current collection.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="collection"/> is a null reference.</exception>
        /// <exception cref="NotSupportedException">
        /// <para>The <see cref="DoubleArrayList"/> is read-only.</para>
        /// <para>-or-</para>
        /// <para>The <b>DoubleArrayList</b> has a fixed size.</para>
        /// <para>-or-</para>
        /// <para>The <b>DoubleArrayList</b> already contains one or more elements
        /// in the specified <paramref name="collection"/>, and the <b>DoubleArrayList</b>
        /// ensures that all elements are unique.</para></exception>
        /// <remarks>Please refer to <see cref="ArrayList.AddRange"/> for details.</remarks>
        public virtual void AddRange(DoubleArrayList collection)
        {
            if (collection == null)
                throw new ArgumentNullException("collection");

            if (collection.Count == 0) return;
            if (this._count + collection.Count > this._array.Length)
                EnsureCapacity(this._count + collection.Count);

            ++this._version;
            Array.Copy(collection.InnerArray, 0,
                this._array, this._count, collection.Count);
            this._count += collection.Count;
        }
        /// <summary>
        /// Returns a wrapper for the specified <see cref="DoubleArrayList"/>
        /// ensuring that all elements are unique.
        /// </summary>
        /// <param name="collection">The <see cref="DoubleArrayList"/> 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="DoubleArrayList"/> 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>DoubleArrayList</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 DoubleArrayList Unique(DoubleArrayList 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);
        }
 internal ReadOnlyList(DoubleArrayList collection)
     : base(Tag.Default)
 {
     this._collection = collection;
 }
        /// <summary>
        /// Returns a read-only wrapper for the specified <see cref="DoubleArrayList"/>.
        /// </summary>
        /// <param name="collection">The <see cref="DoubleArrayList"/> to wrap.</param>
        /// <returns>A read-only wrapper around <paramref name="collection"/>.</returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="collection"/> is a null reference.</exception>
        /// <remarks>Please refer to <see cref="ArrayList.ReadOnly"/> for details.</remarks>
        public static DoubleArrayList ReadOnly(DoubleArrayList collection)
        {
            if (collection == null)
                throw new ArgumentNullException("collection");

            return new ReadOnlyList(collection);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DoubleArrayList"/> class
        /// that contains elements copied from the specified collection and
        /// that has the same initial capacity as the number of elements copied.
        /// </summary>
        /// <param name="collection">The <see cref="DoubleArrayList"/>
        /// whose elements are copied to the new collection.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="collection"/> is a null reference.</exception>
        /// <remarks>Please refer to <see cref="ArrayList(ICollection)"/> for details.</remarks>
        public DoubleArrayList(DoubleArrayList collection)
        {
            if (collection == null)
                throw new ArgumentNullException("collection");

            this._array = new double[collection.Count];
            AddRange(collection);
        }
            public override void AddRange(DoubleArrayList collection)
            {
                foreach (double value in collection)
                    CheckUnique(value);

                this._collection.AddRange(collection);
            }
 internal UniqueList(DoubleArrayList collection)
     : base(Tag.Default)
 {
     this._collection = collection;
 }
 public override void AddRange(DoubleArrayList collection)
 {
     lock (this._root) this._collection.AddRange(collection);
 }
 internal SyncList(DoubleArrayList collection)
     : base(Tag.Default)
 {
     this._root = collection.SyncRoot;
     this._collection = collection;
 }
 public override void AddRange(DoubleArrayList collection)
 {
     throw new NotSupportedException(
         "Read-only collections cannot be modified.");
 }
        /// <summary>
        /// Returns a synchronized (thread-safe) wrapper
        /// for the specified <see cref="DoubleArrayList"/>.
        /// </summary>
        /// <param name="collection">The <see cref="DoubleArrayList"/> to synchronize.</param>
        /// <returns>
        /// A synchronized (thread-safe) wrapper around <paramref name="collection"/>.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="collection"/> is a null reference.</exception>
        /// <remarks>Please refer to <see cref="ArrayList.Synchronized"/> for details.</remarks>
        public static DoubleArrayList Synchronized(DoubleArrayList collection)
        {
            if (collection == null)
                throw new ArgumentNullException("collection");

            return new SyncList(collection);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Vector3D"/> class with the specified coordinates.
        /// </summary>
        /// <param name="coordinates">An array containing the coordinate parameters.</param>
        public Vector3D(DoubleArrayList coordinates)
        {
            Debug.Assert(coordinates != null);
            Debug.Assert(coordinates.Count >= 3);

            _x = coordinates[0];
            _y = coordinates[1];
            _z = coordinates[2];
        }
 internal Enumerator(DoubleArrayList collection)
 {
     this._collection = collection;
     this._version = collection._version;
     this._index = -1;
 }