Example #1
0
        static void Main(string[] args)
        {
            var linkedList = new SimpleLinkedList <int>
            {
                5,
                10,
                20,
                40
            };

            Console.WriteLine(linkedList);
            linkedList.Insert(0, 50);
            Console.WriteLine(linkedList);
            linkedList.Insert(linkedList.Count, 400);
            Console.WriteLine(linkedList);

            linkedList.Insert(2, 100);
            Console.WriteLine(linkedList);
        }
Example #2
0
        public static void DisplaySimpleLinkedListClass()
        {
            SimpleLinkedList <int> list = new SimpleLinkedList <int>();

            list.SetSortRule(SetArrayStandard);

            list.Insert(11);
            list.Insert(11);
            list.Insert(22);
            list.Insert(22);
            list.Insert(33);

            Console.WriteLine("현재 데이터의 수 : " + list.CountData);
            Console.WriteLine(list);

            list.RemoveData(22);

            Console.WriteLine("현재 데이터의 수 : " + list.CountData);
            Console.WriteLine(list);
        }
Example #3
0
        public static void DisplayQuest4()
        {
            SimpleLinkedList <Point> list = new SimpleLinkedList <Point>();

            list.Insert(new Point(2, 1));
            list.Insert(new Point(2, 2));
            list.Insert(new Point(3, 1));
            list.Insert(new Point(3, 2));

            list.SetSortRule(delegate(Point left, Point right)
            {
                if (left.X < right.X)
                {
                    return(true);
                }
                if (left.X != right.X)
                {
                    return(false);
                }
                return(left.Y < right.Y);
            });

            Console.WriteLine(list);
        }
Example #4
0
 public void InsertThrowException()
 {
     SimpleLinkedList<int> list = new SimpleLinkedList<int>();
     list.Add(3);
     list.Add(5);
     list.Add(7);
     list.Insert(-1, 4);
     list.ShouldContain(4);
 }
Example #5
0
 public void InsertAtIndex()
 {
     SimpleLinkedList<int> list = new SimpleLinkedList<int>();
     list.Add(3);
     list.Add(5);
     list.Add(7);
     list.Insert(1, 4);
     list.ShouldContain(4);
 }