/// <summary> /// Gets the last pair in the linked list /// </summary> /// <returns></returns> public LinkedPair <KeyType, DataType> GetLastLinkedPairInLink() { LinkedPair <KeyType, DataType> current = this; while (true) { LinkedPair <KeyType, DataType> next = current.GetNext(); if (next == null) { break; } else { current = next; } } return(current); }
/// <summary> /// Searches for a <see cref="LinkedPair{KeyType, DataType}"/> with a specified key that is linked with this one, only searching forwards in the list /// </summary> /// <param name="key">Search key</param> /// <returns>Mathed pair. Can be null</returns> public LinkedPair <KeyType, DataType> GetLinkedPairWithKeyInListForwardSearch(KeyType key) { if (this.key.Equals(key)) { return(this); } for (LinkedPair <KeyType, DataType> next = this.GetNext(); next != null; next = next.GetNext()) { if (next.key.Equals(key)) { return(next); } } return(null); }