Exemplo n.º 1
0
        public object Clone()
        {
            LinkedListVector clone = new LinkedListVector(this.Length);

            for (int i = 0; i < this.Length; i++)
            {
                clone[i] = this[i];
            }
            return(clone);
        }
Exemplo n.º 2
0
        public static IVector Sum(IVector x, IVector y)
        {
            IVector ans;

            if (x is ArrayVector)
            {
                ans = new ArrayVector(Math.Max(x.Length, y.Length));
            }
            else
            {
                if (x is LinkedListVector)
                {
                    ans = new LinkedListVector(Math.Max(x.Length, y.Length));
                }
                else
                {
                    Console.WriteLine("Операция неприменима к объектам данных типов\nPress Enter...");
                    Console.ReadLine();
                    throw new Exception();
                }
            }
            try
            {
                for (int i = 0; i < ans.Length; i++)
                {
                    ans[i] = x[i] + y[i];
                }
                return(ans);
            }
            catch (Exception)
            {
                Console.WriteLine("вектора имеют разную длину\nPress Enter...");
                Console.ReadLine();
                throw;
            }
        }