private void Behavior(LinkedListOperation operation, IActor actor, T data) { var find = ((LinkedListBehaviors <T>)LinkedTo).fList.Find(data); if (find != null) { var next = find.Next; actor.SendMessage(LinkedListOperation.Answer, next.Value); } }
private LinkedListOperation ArrangeScenarioForDeleteOperation() { LinkedListOperation linkedListOperation = new LinkedListOperation(); foreach (Node node in SampleNodes()) { linkedListOperation.AddNode(node, linkedListOperation.InsertNodeAtEnd); } return(linkedListOperation); }
static void Main(string[] args) { Console.WriteLine("Añade al inicio:"); Node list = new Node(); LinkedListOperation linkedListOperation = new LinkedListOperation(); list = linkedListOperation.createStart("Hola", list, null); list = linkedListOperation.createStart("Querido", list, null); list = linkedListOperation.createStart("Mundo", list, null); linkedListOperation.printList(list); Console.WriteLine(); Console.ReadLine(); }
public void InsertNodeEndOfListTest() { //Arrange LinkedListOperation linkedListOperation = new LinkedListOperation(); //Act foreach (Node node in SampleNodes()) { linkedListOperation.AddNode(node, linkedListOperation.InsertNodeAtEnd); } //Assert int counter = 0; while (linkedListOperation.Head.Next != null) { Assert.Equal(SampleNodes()[counter].Data, linkedListOperation.Head.Data); counter++; linkedListOperation.Head = linkedListOperation.Head.Next; } }
static void Main(string[] args) { //LinkedList linkedList = new LinkedList(); //linkedList.createRandomLinkedList(10); //linkedList.printLinkedList(); BasicMathLinkedList basicMathOperationsLinkedList = new BasicMathLinkedList(); Console.WriteLine("Please enter the number for performing the corresponding operation. \n 1. Add \n 2. Subtract \n 3. Multiply"); var inputOption = Console.ReadLine(); int parsedInputValue = 0; Int32.TryParse(inputOption, out parsedInputValue); LinkedListOperation operationName = (LinkedListOperation)parsedInputValue; if (parsedInputValue > 0 && parsedInputValue < 4) { Console.WriteLine("*************Going to test the {0} operations for single lists of size 2 /2 ***********", operationName.ToString()); Console.WriteLine(""); basicMathOperationsLinkedList.VerifyMathAddOperationOnSingleLinkedLists(2, 2, operationName); Console.WriteLine("*************Completed the test to {0} operations for single lists of size 2 /2 ***********", operationName.ToString()); Console.WriteLine(""); Console.WriteLine("*************Going to test the {0} operations for single lists of size 3 /2 ***********", operationName.ToString()); Console.WriteLine(""); basicMathOperationsLinkedList.VerifyMathAddOperationOnSingleLinkedLists(3, 2, operationName); Console.WriteLine("*************Completed test to {0} operations for single lists of size 3 /2 ***********", operationName.ToString()); Console.WriteLine(""); Console.WriteLine("*************Going to test the {0} operations for single lists of size 2 /3 ***********", operationName.ToString()); Console.WriteLine(""); basicMathOperationsLinkedList.VerifyMathAddOperationOnSingleLinkedLists(2, 3, operationName); Console.WriteLine("*************Completed test to {0} operations for single lists of size 2 /3 ***********", operationName.ToString()); Console.WriteLine(""); } else { Console.WriteLine("I am going to relax and have fun.. As all work and no fun makes jack a dull boy :)"); } Console.ReadLine(); }
public void InsertNodeBeginingOfListTest() { //Arrange LinkedListOperation linkedListOperation = new LinkedListOperation(); //Act foreach (Node node in SampleNodes()) { linkedListOperation.AddNode(node, linkedListOperation.InsertNodeAtFirst); } //Assert int counter = 0; var list = SampleNodes(); list.Reverse(); while (linkedListOperation.Head.Next != null) { Assert.Equal(list[counter].Data, linkedListOperation.Head.Data); counter++; linkedListOperation.Head = linkedListOperation.Head.Next; } }
public void VerifyMathAddOperationOnSingleLinkedLists(int firstLinkedListSize, int secondLinkedListSize, LinkedListOperation operationType) { LinkedList firstLinkedList = this.createRandomLinkedList(firstLinkedListSize); this.PrintLinkedListData(firstLinkedList); LinkedList secondLinkedList = this.createRandomLinkedList(secondLinkedListSize); this.PrintLinkedListData(secondLinkedList); switch (operationType) { case LinkedListOperation.Add: this.AddDataOfTwoSlingleLinkedLists(firstLinkedList, secondLinkedList); break; case LinkedListOperation.Subtract: this.SubtractDataOfTwoSlingleLinkedLists(firstLinkedList, secondLinkedList); break; case LinkedListOperation.Multiply: this.MultiplyDataOfTwoSingleLinkedLists(firstLinkedList, secondLinkedList); break; default: Console.WriteLine("I am going to relax and have fun.. As all work and no fun makes jack a dull boy :)"); break; } }
private void Behavior(LinkedListOperation operation, IActor Sender) { var first = ((LinkedListBehaviors <T>)LinkedTo).fList.First.Value; Sender.SendMessage(LinkedListOperation.Answer, first); }
private void Behavior(LinkedListOperation operation, T data) { ((LinkedListBehaviors <T>)LinkedTo).fList.AddLast(data); }