コード例 #1
0
    public static void Main(string[] args)
    {
        ArrayList arrayList = new ArrayList();

        arrayList.AddLast(10);
        arrayList.AddLast(20);
        arrayList.AddLast(30);
        arrayList.AddAtFirst(4000);
        arrayList.Add(500, 2);

        Console.WriteLine(arrayList.toString());
    }
コード例 #2
0
        public void SmallTest()
        {
            ArrayList list = new ArrayList();

            list.AddLast("10");
            Assert.AreEqual("10", list.Get(0));
        }
コード例 #3
0
ファイル: UnitTest1.cs プロジェクト: carlosEGuerra/Boggle
        public void ConstructorTest3()
        {
            ArrayList list = new ArrayList();

            list.AddLast("hello");
            Assert.AreEqual("hello", list.Get(0));
        }
コード例 #4
0
        public void AddLastArrTest(int[] sourceArray, int[] arr, int[] expected)
        {
            ArrayList array = new ArrayList(sourceArray);

            array.AddLast(arr);
            int[] actual = array.ToArray();
            Assert.AreEqual(expected, actual);
        }
コード例 #5
0
ファイル: ArrayListTest.cs プロジェクト: gbower30/examples
        public void PrivateTest()
        {
            // Create an array element with three elements
            ArrayList list = new ArrayList();

            list.AddLast("1");
            list.AddLast("2");
            list.AddLast("3");

            // Invoke the private method Scale
            PrivateObject listAccessor = new PrivateObject(list);

            object[] parameters = { 3 };
            int      n          = (int)listAccessor.Invoke("Scale", parameters);

            Assert.AreEqual(12, n);
        }
コード例 #6
0
        public void PrivateTest()
        {
            ArrayList list = new ArrayList();

            list.AddLast("10");
            PrivateObject listAccessor = new PrivateObject(list);

            object[] parameters = { 0, "Joe" };
            listAccessor.Invoke("Set", parameters);
            Assert.AreEqual("Joe", list.Get(0));
        }
コード例 #7
0
ファイル: ArrayListTest.cs プロジェクト: gbower30/examples
        public void SmallTest()
        {
            ArrayList list = new ArrayList();

            list.AddLast("10");
            Assert.AreEqual("10", list.Get(0));
            Assert.AreEqual(1, list.GetSize());
            try
            {
                list.Get(1);
                Assert.Fail();
            }
            catch (IndexOutOfRangeException)
            {
                // An exception is expected
            }
        }
コード例 #8
0
        public void TestArrayList()
        {
            var arr = new ArrayList <int>(20);

            for (var i = 0; i < 10; i++)
            {
                arr.AddLast(i);
            }
            Console.WriteLine(arr);
            arr.Add(1, 100);
            Console.WriteLine(arr);
            arr.AddFirst(-1);
            Console.WriteLine(arr);
            arr.Remove(2);
            Console.WriteLine(arr);
            arr.RemoveElement(4);
            Console.WriteLine(arr);
            arr.RemoveFirst();
            Console.WriteLine(arr);
        }
コード例 #9
0
        /// <summary>Takes time linear in number of arcs.</summary>
        public static ClassicCounter ComputeLambda(TransducerGraph graph)
        {
            ArrayList      queue  = new ArrayList();
            ClassicCounter lambda = new ClassicCounter();
            ClassicCounter length = new ClassicCounter();
            IDictionary    first  = new Hashtable();
            ISet           nodes  = graph.GetNodes();

            foreach (object node in nodes)
            {
                lambda.SetCount(node, 0);
                length.SetCount(node, double.PositiveInfinity);
            }
            ISet endNodes = graph.GetEndNodes();

            foreach (object o in endNodes)
            {
                lambda.SetCount(o, 0);
                length.SetCount(o, 0);
                queue.AddLast(o);
            }
            // Breadth first search
            // get the first node from the queue
            object node_1 = null;

            try
            {
                node_1 = queue.RemoveFirst();
            }
            catch (NoSuchElementException)
            {
            }
            while (node_1 != null)
            {
                double oldLen = length.GetCount(node_1);
                ISet   arcs   = graph.GetArcsByTarget(node_1);
                if (arcs != null)
                {
                    foreach (object arc1 in arcs)
                    {
                        TransducerGraph.Arc arc = (TransducerGraph.Arc)arc1;
                        object      newNode     = arc.GetSourceNode();
                        IComparable a           = (IComparable)arc.GetInput();
                        double      k           = ((double)arc.GetOutput());
                        double      newLen      = length.GetCount(newNode);
                        if (newLen == double.PositiveInfinity)
                        {
                            // we are discovering this
                            queue.AddLast(newNode);
                        }
                        IComparable f = (IComparable)first[newNode];
                        if (newLen == double.PositiveInfinity || (newLen == oldLen + 1 && a.CompareTo(f) < 0))
                        {
                            // f can't be null, since we have a newLen
                            // we do this to this to newNode when we have new info, possibly many times
                            first[newNode] = a;
                            // ejecting old one if necessary
                            length.SetCount(newNode, oldLen + 1);
                            // this may already be the case
                            lambda.SetCount(newNode, k + lambda.GetCount(node_1));
                        }
                    }
                }
                // get a new node from the queue
                node_1 = null;
                try
                {
                    node_1 = queue.RemoveFirst();
                }
                catch (NoSuchElementException)
                {
                }
            }
            return(lambda);
        }
コード例 #10
0
 protected internal virtual void AddSplit(FastExactAutomatonMinimizer.Split split)
 {
     splits.AddLast(split);
 }