Пример #1
0
        public void ListInt_IndexOf()
        {
            var list = new ListInt(new[] { 1, 2 });

            Assert.Equal(0, list.IndexOf(1));
            Assert.Equal(1, list.IndexOf(2));
        }
Пример #2
0
        private void DisconnectClient(int ClientId)
        {
            foreach (List <int> ListInt in DictUserListener.Values)
            {
                ListInt.Remove(ClientId);
            }

            string EventName = string.Empty;

            foreach (KeyValuePair <string, int> kvp in DictActionListener)
            {
                if (kvp.Value == ClientId)
                {
                    EventName = kvp.Key;
                    break;
                }
            }
            if (EventName.Length > 0)
            {
                DictActionListener.Remove(EventName);
            }

            foreach (List <int> ListInt in DictUserClient.Values)
            {
                if (ListInt.Remove(ClientId))
                {
                    break;
                }
            }
        }
Пример #3
0
    public List <Property> GetProperties()
    {
        ListInt         temp = JsonUtility.FromJson <ListInt>(Property);
        List <Property> achievementProperty = MainGameController.instance.databaseController.connection.Table <Property>().Where(x => temp.list.Contains(x.id)).ToList();

        return(achievementProperty);
    }
Пример #4
0
        public void ListInt_Contains()
        {
            var list = new ListInt(new[] { 1, 2 });

            Assert.True(list.Contains(1));
            Assert.True(list.Contains(2));
            Assert.False(list.Contains(3));
        }
Пример #5
0
        static void TestInterfaceExercise3()
        {
            ListInt ls         = new NodeInt(10, new NodeInt(4, new NodeInt(5, new NodeInt(3, new EmptyInt()))));
            ListInt lsFiltered = ls.Filter((x) => x % 2 == 0);

            lsFiltered.Iter((x) => Console.WriteLine(x));
//			Console.WriteLine (ls.Length);
        }
Пример #6
0
        public void ListInt_Remove()
        {
            var list = new ListInt(new[] { 1, 2 });

            list.Remove(1);
            list.Remove(2);
            Assert.Equal(0, list.Count);
        }
Пример #7
0
        public void ListInt_RemoveAt()
        {
            var list = new ListInt(new[] { 1, 2 });

            list.RemoveAt(1);
            Assert.Equal(1, list.Count);
            Assert.Equal(1, list[0]);
        }
Пример #8
0
 public List <int> GetWaypointOrder()
 {
     if (_waypointOrder == null)
     {
         _waypointOrder = JsonUtility.FromJson <ListInt>(WaypointOrder);
     }
     return(_waypointOrder.list);
 }
Пример #9
0
        public void ListInt_Insert()
        {
            var list = new ListInt(new[] { 1 });

            list.Insert(2, 0);
            Assert.Equal(2, list.Count);
            Assert.Equal(2, list[0]);
            Assert.Equal(1, list[1]);
        }
Пример #10
0
    public List <int> GetSailsId()
    {
        if (_sailsId == null)
        {
            _sailsId = JsonUtility.FromJson <ListInt>(Sails);
        }

        return(_sailsId.list);
    }
Пример #11
0
    public List <int> GetUpgradesId()
    {
        if (_upgradesId == null)
        {
            _upgradesId = JsonUtility.FromJson <ListInt>(Upgrades);
        }

        return(_upgradesId.list);
    }
Пример #12
0
        public void LinkedListReverse()
        {
            var values = new ListInt {
                45, 56, 12, 1, 23, -23, 1, 21, -294, -24, 13, 14, 22
            };
            var list = new LinkedList <int>(values);

            list.Reverse();
            Assert.IsTrue(list.SequenceEqual(values.AsEnumerable().Reverse()));
        }
Пример #13
0
        public void LinkedListCopyTo()
        {
            var values = new ListInt {
                1, 2, 3, 4, 5, 6, 7, 8, 9
            };
            var array = new int[values.Count];

            new LinkedList <int>(values).CopyTo(array, 0);
            Assert.IsTrue(array.SequenceEqual(values));
        }
Пример #14
0
        public void ListInt_Add()
        {
            var list = new ListInt();

            list.Add(1);
            list.Add(2);
            Assert.Equal(2, list.Count);
            Assert.Equal(1, list[0]);
            Assert.Equal(2, list[1]);
        }
Пример #15
0
        public void ListInt_Resize()
        {
            var list = new ListInt();

            for (var i = 0; i < 1024; i++)
            {
                list.Add(i);
            }
            Assert.Equal(1024, list.Count);
        }
Пример #16
0
        static void Main(string[] args)
        {
            UtilsCLass utils = new UtilsCLass();

            String      File = System.AppDomain.CurrentDomain.BaseDirectory + "/../../../Data.txt";
            ListStudent list = utils.createListFromFile(File);

            Console.WriteLine("Initial list: ");
            list.printList();

            try {
                Console.WriteLine("After remvoveFirst:");
                list.removeFirst();
                list.printList();
            } catch (ListElementNotFoundException e) { Console.WriteLine(e); }
            catch (ListEmptyException e) { Console.WriteLine(e); }


            Console.WriteLine("After adding Marc as last element(addAtEnd)");
            ListElement <Student> listElement = new ListElement <Student>(new Student("Marc", 23, 123456, 1.3));

            list.addAtEnd(listElement);
            list.printList();

            try {
                Console.WriteLine("After adding Melkis as first element(addAtStart)");
                ListElement <Student> listElement2 = new ListElement <Student>(new Student("Melkis", 27, 23423, 1.7));
                list.addAtStart(listElement2);
                list.printList();

                Console.WriteLine("After replacing Franck (Mat: 1470) by Fred (Mat: 1987)");
                list.replace(1470, new ListElement <Student>(new Student("Fred", 27, 1987, 1.0)));
                list.printList();
                ListStudent list2 = new ListStudent();
                // list2 is empty, exception ListEmptyException should be thrown
                list2.replace(1470, new ListElement <Student>(new Student("Fred", 27, 1987, 1.0)));
            } catch (ListElementNotFoundException e) { Console.WriteLine(e); }
            catch (ListEmptyException e) { Console.WriteLine(e); }

            // integer list now
            ListInt listInt = new ListInt();

            listInt.addAtEnd(new ListElement <int>(16));
            listInt.addAtEnd(new ListElement <int>(20));
            listInt.addAtEnd(new ListElement <int>(30));
            listInt.addAtStart(new ListElement <int>(22));
            listInt.printList();

            try {
                // element 19 does not exist in the list. should throw an exception
                listInt.replace(19, new ListElement <int>(100));
                listInt.printList();
            } catch (ListElementNotFoundException e) { Console.WriteLine(e); }
            catch (ListEmptyException e) { Console.WriteLine(e); }
        }
Пример #17
0
        public void ListInt_Index()
        {
            var list = new ListInt(new[] { 1, 2 });

            Assert.Equal(1, list[0]);
            Assert.Equal(2, list[1]);
            list[0] = 3;
            list[1] = 4;
            Assert.Equal(3, list[0]);
            Assert.Equal(4, list[1]);
        }
Пример #18
0
        public void LinkedListEquals()
        {
            var values = new ListInt {
                18, 25, 33, 42
            };
            var list = new LinkedList <int>(values);

            Assert.IsTrue(new LinkedList <int>(values).Equals(list));
            Assert.AreEqual(new LinkedList <int>(values).GetHashCode(), list.GetHashCode());
            Assert.IsFalse(new LinkedList <int> {
                58, 47, 12
            }.Equals(list));
        }
Пример #19
0
        public void LinkedListPopBack()
        {
            var values = new ListInt {
                1, 2, 3, 4
            };
            var list = new LinkedList <int>(values.AsEnumerable().Reverse());

            for (int i = 0; i < 4; i++)
            {
                Assert.AreEqual(values[i], list.PopBack());
                Assert.AreEqual(list.Count, 4 - i - 1);
            }
            Assert.IsTrue(list.Empty);
            Assert.IsFalse(list.FrontNode.HasValue);
            Assert.IsFalse(list.BackNode.HasValue);
        }
Пример #20
0
        public void LinkedListAt()
        {
            var values = new ListInt {
                1, 2, 3, 4, 5, 6
            };
            var list = new LinkedList <int>(values);

            for (int i = 0; i < values.Count; i++)
            {
                Assert.AreEqual(list[i], values[i]);
                Assert.AreEqual(list.NodeAt(i).Value, values[i]);
            }
            Assert.AreEqual(list.NodeAt(0).ThisNode, list.FrontNode.Value.ThisNode);
            Assert.AreEqual(list.NodeAt(5).ThisNode, list.BackNode.Value.ThisNode);
            list[0] = 100;
            list[1] = 200;
            Assert.AreEqual(list[0], 100);
            Assert.AreEqual(list[1], 200);
        }
Пример #21
0
    public List <int> GetAvaliableBoatsIds()
    {
        ListInt li = JsonUtility.FromJson <ListInt>(AvaliableBoats);

        return(li.list);
    }
Пример #22
0
 public NodeInt(int x, ListInt xs)
 {
     head = x; tail = xs;
 }
Пример #23
0
		public NodeInt(int x, ListInt xs) { head = x; tail = xs; }
Пример #24
0
 public void Merge(ListInt other)
 {
     this._list.AddRange(other._list);
 }