Exemplo n.º 1
0
        /// <summary>
        /// 5. Работа с последовательностями элементов
        /// </summary>
        private static async Task DataSequencesTests()
        {
            using (SparseMatrixRepSeq sparseMatrixRepSeq = new SparseMatrixRepSeq("5"))
            {
                await sparseMatrixRepSeq.ClearAsync();

                Console.WriteLine(sparseMatrixRepSeq.GetNumSequences());
                // Объявляем последовательности элементов
                double[] seq0 = new double[] { -5.55, 0, 15, 211, 0.09 };
                double[] seq1 = new double[] { 1.1, 2.2, -0.6 };
                double[] seq2 = new double[] { 9, 8, 7, 6, 5, 4, 3, 2, 1 };
                double[] seq3 = new double[] { 1000, 0, 15, 211, 0.09 };
                double[] seq4 = new double[] { -4.55, 4, 45, 411, 4.09, 43.98, 4, -4, -44.432 };
                #region Добавление последовательностей
                Console.WriteLine("Добавление последовательности double[] seq0 = new double[] { -5.55, 0, 15, 211, 0.09 };");
                int seqIndex0 = await sparseMatrixRepSeq.AddSequence(seq0);

                await sparseMatrixRepSeq.PrintMatrixSequenceIndexFile();

                await sparseMatrixRepSeq.PrintMatrixSequenceDataFile();

                Console.WriteLine("Добавление последовательности double[] seq1 = new double[] { 1.1, 2.2, -0.6 };");
                int seqIndex1 = await sparseMatrixRepSeq.AddSequence(seq1);

                await sparseMatrixRepSeq.PrintMatrixSequenceIndexFile();

                await sparseMatrixRepSeq.PrintMatrixSequenceDataFile();

                Console.WriteLine("Добавление последовательности double[] seq2 = new double[] { 9, 8, 7, 6, 5, 4, 3, 2, 1 };");
                int seqIndex2 = await sparseMatrixRepSeq.AddSequence(seq2);

                await sparseMatrixRepSeq.PrintMatrixSequenceIndexFile();

                await sparseMatrixRepSeq.PrintMatrixSequenceDataFile();

                Console.WriteLine("Добавление последовательности double[] seq3 = new double[] { 1000, 0, 15, 211, 0.09 };");
                int seqIndex3 = await sparseMatrixRepSeq.AddSequence(seq3);

                await sparseMatrixRepSeq.PrintMatrixSequenceIndexFile();

                await sparseMatrixRepSeq.PrintMatrixSequenceDataFile();

                Console.WriteLine("Добавление последовательности double[] seq4 = new double[] { -4.55, 4, 45, 411, 4.09, 43.98, 4, -4, -44.432 };");
                int seqIndex4 = await sparseMatrixRepSeq.AddSequence(seq4);

                await sparseMatrixRepSeq.PrintMatrixSequenceIndexFile();

                await sparseMatrixRepSeq.PrintMatrixSequenceDataFile();

                #endregion

                #region Добавление координат размещения первых элементов последовательностей
                Console.WriteLine("Добавление координаты размещения последовательности AddSequenceCoord(seqIndex0, 0, 5)");
                int sequenceCoordIndex0 = await sparseMatrixRepSeq.AddSequenceCoord(seqIndex0, 0, 5);

                await sparseMatrixRepSeq.PrintMatrixSequenceCoordinatesFile();

                Console.WriteLine("Добавление координаты размещения последовательности AddSequenceCoord(seqIndex1, 1, 5)");
                int sequenceCoordIndex1 = await sparseMatrixRepSeq.AddSequenceCoord(seqIndex1, 1, 5);

                await sparseMatrixRepSeq.PrintMatrixSequenceCoordinatesFile();

                Console.WriteLine("Добавление координаты размещения последовательности AddSequenceCoord(seqIndex2, 2, 5)");
                int sequenceCoordIndex2 = await sparseMatrixRepSeq.AddSequenceCoord(seqIndex2, 2, 5);

                await sparseMatrixRepSeq.PrintMatrixSequenceCoordinatesFile();

                Console.WriteLine("Добавление координаты размещения последовательности AddSequenceCoord(seqIndex3, 3, 5)");
                int sequenceCoordIndex3 = await sparseMatrixRepSeq.AddSequenceCoord(seqIndex3, 3, 5);

                await sparseMatrixRepSeq.PrintMatrixSequenceCoordinatesFile();

                Console.WriteLine("Добавление координаты размещения последовательности AddSequenceCoord(seqIndex4, 4, 5)");
                int sequenceCoordIndex4_1 = await sparseMatrixRepSeq.AddSequenceCoord(seqIndex4, 4, 5);

                await sparseMatrixRepSeq.PrintMatrixSequenceCoordinatesFile();

                Console.WriteLine("Добавление координаты размещения последовательности AddSequenceCoord(seqIndex4, 5, 6)");
                int sequenceCoordIndex4_2 = await sparseMatrixRepSeq.AddSequenceCoord(seqIndex4, 5, 6);

                await sparseMatrixRepSeq.PrintMatrixSequenceCoordinatesFile();

                #endregion

                await sparseMatrixRepSeq.SetNumColsAsync(15);

                #region Запрос строк из последовательностей
                Console.WriteLine("Запрос строки 0");
                await sparseMatrixRepSeq.PrintRowFromSequence(0);

                Console.WriteLine("Запрос строки 1");
                await sparseMatrixRepSeq.PrintRowFromSequence(1);

                Console.WriteLine("Запрос строки 2");
                await sparseMatrixRepSeq.PrintRowFromSequence(2);

                Console.WriteLine("Запрос строки 3");
                await sparseMatrixRepSeq.PrintRowFromSequence(3);

                Console.WriteLine("Запрос строки 4");
                await sparseMatrixRepSeq.PrintRowFromSequence(4);

                Console.WriteLine("Запрос строки 5");
                await sparseMatrixRepSeq.PrintRowFromSequence(5);

                #endregion
            }
            Console.WriteLine("---Successful end of method---");
        }