Пример #1
0
        public static void values(ST st, string action, int left = 0, int right = 0, int value = 0)
        {
            double value0 = st.Get(0, 10);
            double value1 = st.Get(0, 5);
            double value2 = st.Get(6, 10);
            double value3 = st.Get(4, 9);
            double value4 = st.Get(2, 6);

            StringBuilder sb = new StringBuilder("");
            if (action.CompareTo("CREATE") == 0 || action.CompareTo("SHOW") == 0)
                sb.Append(action);
            else
                sb.AppendFormat("{0} ({1}, {2}) to {3}", action, left, right, value);

            Console.WriteLine(sb.ToString());
            Console.WriteLine("(0, 10) -> {0}\n(0, 5) -> {1}\n(6, 10) -> {2}\n(4, 9) -> {3}\n(2, 6) -> {4}\n",
                                value0, value1, value2, value3, value4);
        }
Пример #2
0
        public void test_pointed_update2()
        {
            ST st = new ST(new double[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });

            st = st.PointedUpdate(7, DO.ADD, 8);

            double value0 = st.Get(0, 10);
            double value1 = st.Get(0, 5);
            double value2 = st.Get(6, 10);
            double value3 = st.Get(4, 9);
            double value4 = st.Get(2, 6);

            Assert.AreEqual(value0, 63);
            Assert.AreEqual(value1, 15);
            Assert.AreEqual(value2, 48);
            Assert.AreEqual(value3, 47);
            Assert.AreEqual(value4, 20);
        }
Пример #3
0
        public void test_pointed_update1()
        {
            ST st = new ST(new double[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });

            st = st.PointedUpdate(5, DO.UPDATE, 8);

            double value0 = st.Get(0, 10);
            double value1 = st.Get(0, 5);
            double value2 = st.Get(6, 10);
            double value3 = st.Get(4, 9);
            double value4 = st.Get(2, 6);

            Assert.AreEqual(value0, 58);
            Assert.AreEqual(value1, 18);
            Assert.AreEqual(value2, 40);
            Assert.AreEqual(value3, 42);
            Assert.AreEqual(value4, 23);
        }
Пример #4
0
        public void test_mass_update2()
        {
            ST st = new ST(new double[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });

            st = st.MassUpdate(0, 10, DO.ADD, 1);

            double value0 = st.Get(0, 10);
            double value1 = st.Get(0, 5);
            double value2 = st.Get(6, 10);
            double value3 = st.Get(4, 9);
            double value4 = st.Get(2, 6);

            Assert.AreEqual(value0, 67);
            Assert.AreEqual(value1, 21);
            Assert.AreEqual(value2, 46);
            Assert.AreEqual(value3, 45);
            Assert.AreEqual(value4, 25);
        }
Пример #5
0
        public void test_mass_update1()
        {
            ST st = new ST(new double[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });

            st = st.MassUpdate(0, 10, DO.UPDATE, 6);

            double value0 = st.Get(0, 10);
            double value1 = st.Get(0, 5);
            double value2 = st.Get(6, 10);
            double value3 = st.Get(4, 9);
            double value4 = st.Get(2, 6);

            Assert.AreEqual(value0, 72);
            Assert.AreEqual(value1, 36);
            Assert.AreEqual(value2, 36);
            Assert.AreEqual(value3, 36);
            Assert.AreEqual(value4, 30);
        }
Пример #6
0
        public void test_init()
        {
            ST st = new ST(new double[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });

            double value0 = st.Get(0, 10);
            double value1 = st.Get(0, 5);
            double value2 = st.Get(6, 10);
            double value3 = st.Get(4, 9);
            double value4 = st.Get(2, 6);

            Assert.AreEqual(value0, 55);
            Assert.AreEqual(value1, 15);
            Assert.AreEqual(value2, 40);
            Assert.AreEqual(value3, 39);
            Assert.AreEqual(value4, 20);
        }