예제 #1
0
 public SingleListQueue(SingleLinkedList list)
 {
     _list   = list;
     Counter = 1;
 }
예제 #2
0
파일: Program.cs 프로젝트: keliny/AlgoHW01
        private static void SingleLinkedList()
        {
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("---------------------------  SingleLinkedList  ---------------------------");
            var header = new Item()
            {
                Value = "object 1"
            };
            var singleList = new SingleLinkedList(header);

            var prependItem = new Item {
                Value = "prepended item."
            };
            var appendItem = new Item {
                Value = "appended item"
            };
            var insertBefore = new Item {
                Value = "New insert before item."
            };

            singleList.Cycle();
            Console.WriteLine();
            Console.WriteLine("Insert");
            singleList.Insert(1, new Item {
                Value = "Object 2"
            });
            singleList.Cycle();
            Console.WriteLine();
            singleList.Insert(1, new Item {
                Value = "Object 3"
            });
            singleList.Cycle();
            Console.WriteLine();
            Console.WriteLine("Get index");
            singleList.GetItem(0);
            singleList.FindItem(header);
            Console.WriteLine();
            Console.WriteLine("set ");
            singleList.SetItem(1, new Item {
                Value = "Updated item"
            });
            singleList.Cycle();
            Console.WriteLine();
            Console.WriteLine("Append");
            singleList.Append(appendItem);
            singleList.Cycle();
            Console.WriteLine();
            Console.WriteLine("Prepend");
            singleList.Prepend(prependItem);
            singleList.Cycle();
            Console.WriteLine();
            Console.WriteLine("Delete at 2");
            singleList.DeleteAt(2);
            singleList.Cycle();
            Console.WriteLine();
            Console.WriteLine("Insert before prependItem");
            singleList.InsertBefore(prependItem, insertBefore);
            singleList.Cycle();
            Console.WriteLine();
            Console.WriteLine("Insert after prependItem");
            singleList.InsertAfter(prependItem, new Item {
                Value = "New insert after item."
            });
            singleList.Cycle();
            Console.WriteLine();
            singleList.InsertAfter(appendItem, new Item {
                Value = "Second insert after item."
            });
            singleList.Cycle();
            Console.WriteLine();
            Console.WriteLine("Remove by Item");
            singleList.Remove(insertBefore);
            singleList.Cycle();
        }
예제 #3
0
 public SingleListStack(SingleLinkedList list)
 {
     _list   = list;
     Counter = 1;
 }