/// <summary> /// Adds the node to last with existing list. /// </summary> /// <param name="list">The list.</param> /// <param name="value">The value.</param> /// <param name="list1">The list1.</param> /// <returns>updated list</returns> public LinkedListQueue <T> AddLast1(List <T> list, T value, LinkedListQueue <T> list1) { try { if (this.head == null) { Node <T> newNode = new Node <T>(value, null); this.head = newNode; this.nodeCount++; return(list1); } else { Node <T> newNode = new Node <T>(); Node <T> current = this.head; while (current.GetNext() != null) { current = current.GetNext(); } current.SetNext(newNode); this.head = newNode; this.nodeCount++; } } catch (Exception ex) { Console.WriteLine(ex.Message); } return(list1); }
/// <summary> /// Adds the player in the list. /// </summary> /// <param name="list">The list.</param> /// <returns>returning the updated list</returns> public List <T> AddPlayer(LinkedListQueue <T> list) { try { Node <T> newNode = new Node <T>(); newNode = this.head; while (newNode != null) { this.list1.Add(newNode.GetData()); } } catch (Exception ex) { Console.WriteLine(ex.Message); } return(this.list1); }
/// <summary> /// Adds the first1. /// </summary> /// <param name="list">The list.</param> /// <param name="data">The data.</param> /// <param name="list1">The list1.</param> /// <returns>returning the updated list</returns> public LinkedListQueue <T> AddFirst1(List <T> list, T data, LinkedListQueue <T> list1) { try { if (this.head == null) { Node <T> newNode = new Node <T>(data, null); this.head = newNode; return(list1); } else { Node <T> newNode = new Node <T>(data, null); newNode.SetNext(this.head); this.head = newNode; } } catch (Exception ex) { Console.WriteLine(ex.Message); } return(list1); }
/// <summary> /// Pushes the specified list. /// </summary> /// <param name="list">The list.</param> /// <param name="data">The data.</param> public void Push(LinkedListQueue <T> list, T data) { this.AddFirst(list, data); }