public void Arrange()
 {
     //_originalValues = new List<String>{"BankVue", "Should", "Hire", "Elliott"};
     // lets check some performance issues
     _originalValues = new List<string>();
     for (var i = 0; i < 1000000; i++ )
     {
         _originalValues.Add(Guid.NewGuid().ToString());
     }
     _list = new CheatingLinkedList<String>();
     _expectedValues = new List<String>(_originalValues);
     _expectedValues.Reverse();
 }
예제 #2
0
 static void Main(string[] args)
 {
     ILinkedList<string> n = new ILinkedList<string>();
     n.push("Zero");
     n.push("Primeiro");
     n.push("Segundo");
     n.push("Teceiro");
     n.push("Quarto");
     n.push("Quinto");
     n.push("Sexto");
     n.SwitchPosition(1, 4);
     n.print();
     Console.WriteLine("We have "+n.Length+" elements in our Linked List!!");
     Console.ReadKey();
 }
예제 #3
0
        private static void TestLinkedList(ILinkedList <string> list)
        {
            list.AddToBegin("hEnd");
            list.AddToBegin("iasf");
            list.AddToBegin("grfg");
            list.AddToEnd("kEpppp");
            list.AddToEnd("adghj");
            list.AddToEnd("ptyutyi");

            foreach (string item in list)
            {
                Console.Write($"{item}\t");
            }
            Console.WriteLine();
            Console.WriteLine();

            #region //

            //string first = list.RemoveFromBegin();
            //Console.WriteLine("first: {0}", first);
            // list.RemoveFromEnd();

            //list.Sort();

            //foreach (string item in list)
            //{
            //    Console.Write($"{item}\t");
            //}
            //Console.WriteLine();
            //Console.WriteLine();

            //Console.ForegroundColor = ConsoleColor.Green;
            //Console.WriteLine("get from end:");

            //while (!list.IsEmpty())
            //{
            //    string last = list.RemoveFromEnd();
            //    Console.WriteLine("last: {0}", last);
            //}

            //Console.ForegroundColor = ConsoleColor.Cyan;
            //Console.WriteLine("REMOVE FIRST ELEMENT");

            //list.RemoveFromBegin();
            //list.RemoveFromEnd();

            //foreach (string item in list)
            //{
            //    Console.Write($"{item}\t");
            //}

            //Console.WriteLine();
            //Console.WriteLine();

            //Console.ForegroundColor = ConsoleColor.Red;

            //Console.WriteLine("AFTER REVERSE: ");

            //foreach (string item in list.GetReverse())
            //{
            //    Console.Write($"{item}\t");
            //}
            //Console.WriteLine();

            #endregion

            Console.ForegroundColor = ConsoleColor.Red;

            Console.WriteLine();

            list.Sort();

            foreach (string item in list)
            {
                Console.Write($"{item}\t");
            }
            Console.WriteLine();
            Console.WriteLine();
        }
예제 #4
0
 public static T GetMax <T>(this ILinkedList <T> linkedList) where T : IComparable <T>
 => GetValue(linkedList, 1);
예제 #5
0
        private static void TryLinkedList(ILinkedList <short> linkedList)
        {
            Console.WriteLine($"Trying {linkedList.GetType().Name}");

            var random = new Random();

            Console.WriteLine($"Display the queue: {linkedList}\n");

            for (var i = 0; i < 100; i++)
            {
                var randomValue = (short)random.Next(1000);
                Console.WriteLine($"Trying to add {randomValue} to the list.");
                linkedList.Add(randomValue);
                Console.WriteLine($"{randomValue} added to the list.");
            }

            for (short i = 0; i < 100; i++)
            {
                var op = random.Next(4); //randomly enqueue or dequeue
                try
                {
                    var randomValue = (short)random.Next(1000);
                    var randomIndex = random.Next(100);

                    switch (op)
                    {
                    case 0:    //Add
                        Console.WriteLine($"Trying to add {randomValue} to the list.");
                        linkedList.Add(randomValue);
                        Console.WriteLine($"{randomValue} added to the list.");
                        break;

                    case 1:    //Get
                        Console.WriteLine($"Trying to get...");
                        var val = linkedList.Get(random.Next(100));
                        Console.WriteLine($"get item:{val}");
                        break;

                    case 2:    //Insert
                        Console.WriteLine($"Trying to insert...");
                        linkedList.Insert(randomIndex, randomValue);
                        Console.WriteLine($"{randomValue} inserted to index:{randomIndex}.");
                        break;

                    case 3:    //Remove
                        Console.WriteLine($"Trying to remove...");
                        linkedList.Remove(randomIndex);
                        Console.WriteLine($"item removed at index:{randomIndex}.");
                        break;

                    default:
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                Console.WriteLine($"Count: {linkedList.GetCount()}\n");
                Console.WriteLine($"Display the list: {linkedList}\n");
            }
        }
예제 #6
0
 void ILinkedList <SimProcess> .Append(ILinkedList <SimProcess> list)
 {
     throw new DessertException(ErrorMessages.InvalidMethod);
 }
 public GiantInt(string numberString)
 {
     Numbers = ParseInput(numberString);
 }
예제 #8
0
 public void Init()
 {
     _uList = new UniqueList();
 }
 public Node(ILinkedList <INode <T> > linkedList)
     : this(linkedList, default(T))
 {
 }
        private int AddToEndTestAssert(ILinkedList ll, byte[] data)
        {
            int token = ll.AddToEnd(data);

            byte[] actual = ll.GetData(token);
            TestHelper.AssertByteArraysAreSame(data, actual);
            return token;
        }
예제 #11
0
 public void Setup()
 {
     _list = new LinkedList();
 }
 private static void UpdateTestAssert(ILinkedList ll, int index, byte[] data)
 {
     ll.Update(index, data);
     byte[] actual = ll.GetData(index);
     TestHelper.AssertByteArraysAreSame(data, actual);
 }
 private void AddBeforeTestAssert(ILinkedList ll, int index, byte[] data)
 {
     int token = ll.AddBefore(index, data);
     byte[] actual = ll.GetData(token);
     TestHelper.AssertByteArraysAreSame(data, actual);
 }
 private static void PutGetUserHeaderTestAssert(ILinkedList ll, byte[] uheader)
 {
     ll.PutUserHeader(uheader);
     byte[] actual = ll.GetUserHeader();
     TestHelper.AssertByteArraysAreSame(uheader, actual);
 }
 private static void GetDataTestAssert(ILinkedList ll, byte[] data)
 {
     int token = ll.AddToStart(data);
     byte[] actual = ll.GetData(token);
     TestHelper.AssertByteArraysAreSame(data, actual);
 }
 private static int AddAfterTestAssert(ILinkedList ll, int token, byte[] data)
 {
     int insertedToken = ll.AddAfter(token, data);
     byte[] actual = ll.GetData(insertedToken);
     TestHelper.AssertByteArraysAreSame(data, actual);
     return insertedToken;
 }
 public LinkedListNodeEnumerator(ILinkedList <T> list) => _list = list;
예제 #18
0
 //добавление списка в конец
 public void AddList(ILinkedList list)
 {
     AddListByIndex(list, Length);
 }
예제 #19
0
 private void StartWindow(Action exit)
 {
     this.elements = new Empty <IGuiElement>();
     this.menuFactory.Create(5, "Start", new Position(700, 300), Colour.Red, () => InputWindow(exit)).Visit(() => Do.Nothing(), (element) => this.elements   = this.elements.Add(element));
     this.menuFactory.Create(5, "Input", new Position(700, 400), Colour.White, () => LabelWindow(exit)).Visit(() => Do.Nothing(), (element) => this.elements = this.elements.Add(element));
     this.menuFactory.Create(5, "Exit", new Position(700, 500), Colour.Blue, () => ExitWindow(exit)).Visit(() => Do.Nothing(), (element) => this.elements    = this.elements.Add(element));
 }
예제 #20
0
 //добавление списка в начало
 public void AddListAtBeginning(ILinkedList list)
 {
     AddListByIndex(list, 0);
 }
 public Node(ILinkedList <INode <T> > linkedList, T vertex)
 {
     adjacent = linkedList;
     Vertex   = vertex;
 }
예제 #22
0
 public void Dispose()
 {
     Next     = null;
     Previous = null;
     list     = null;
 }
 public DirectedGraphAdjacencyList(ILinkedList <INode <T> > nodeList)
     : this(nodeList, null, null)
 {
 }
예제 #24
0
 public void Init()
 {
     LinkedList = new LinkedList();
 }
예제 #25
0
 public Stack()
 {
     _list = new LinkedList <T>();
 }
예제 #26
0
 public Queue(ILinkedList <T> linkedList)
 {
     this.list = linkedList;
 }
 public GiantInt(string[] numbers)
 {
     Numbers = ParseInput(numbers);
 }
예제 #28
0
 public Queue(ILinkedList <T> linkedList, T firstElement) : this(linkedList)
 {
     this.list.Add(firstElement);
 }
예제 #29
0
 public LinkedQueue()
 {
     this.queue = new LinkedList <T>();
 }
예제 #30
0
 public LinkedListIterator(ILinkedList <T> linkedlist)
 {
     this.LinkedList = linkedlist;
 }
예제 #31
0
 public Node(T value, ILinkedList <T> tail)
 {
     this.Value = value;
     this.Tail  = tail;
 }
예제 #32
0
 public IOption <T> moveNext()
 {
     //Moves to the Tail from the current Linkedlist item wich contains a refrence to the next value
     this.LinkedList = this.LinkedList.Tail;
     return(LinkedList.Visit <IOption <T> >(node => new Some <T>(this.LinkedList.Value), () => new None <T>()));
 }
예제 #33
0
파일: Stack.cs 프로젝트: barld/INFDEV01-6A
 public void Push(T item) =>
 list = new LinkedList <T>
 {
     Head = item, Tail = list
 };
 public void when_using_a_reversable_linked_list()
 {
     _list = new CheatingLinkedList<string>();
 }
예제 #35
0
 public GuiManager(Action exit)
 {
     this.elements    = new Empty <IGuiElement>();
     this.menuFactory = new ConcreteGuiElementFactory();
     StartWindow(exit);
 }
예제 #36
0
        public static void Find_FilledList_NoMatchingValue_ShouldReturnNull_Test <TNode>(ILinkedList <TNode> list)
            where TNode : class, ILinkedListNode
        {
            Assert.NotNull(list);

            list.Add("Josephus Flavius");
            list.Add("Herodotus");
            list.Add("Tacitus");

            var node = list.Find("Alexander Argead");

            Assert.IsNull(node);
        }
예제 #37
0
 internal Node(ILinkedList <T> list, T item) => (this.list, this.item) = (list, item);
예제 #38
0
        public static void Find_FilledList_ContainsMultipleMatchingValues_ShouldReturnFirstMatchingNode_Test <TNode>(ILinkedList <TNode> list)
            where TNode : class, ILinkedListNode
        {
            Assert.NotNull(list);

            list.Add("Josephus Flavius");
            var targetNode = list.Add("Herodotus");

            list.Add("Herodotus");
            list.Add("Herodotus");
            list.Add("Herodotus");
            list.Add("Tacitus");

            var foundNode = list.Find("Herodotus");

            Assert.AreSame(targetNode, foundNode);
        }
 public void when_using_a_SimpleLinkedList()
 {
     _list = new SimpleLinkedList<String>();
     PopulateNodes();
 }
예제 #40
0
 public Queue()
 {
     _list = new LinkedList <T>();
 }