public SingleListQueue(SingleLinkedList list) { _list = list; Counter = 1; }
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(); }
public SingleListStack(SingleLinkedList list) { _list = list; Counter = 1; }