Exemplo n.º 1
0
        public INode <T> Find(T value)
        {
            Node <T> node = Head.Next;

            while (!node.Equals(Tail))
            {
                if (node.Value.Equals(value))
                {
                    return(node);
                }
                node = node.Next;
            }
            return(null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns the index of the first occurrency of the element you want.
        /// </summary>
        /// <param name="elementToCheck">Enter the element which index you want to know.</param>
        /// <returns>Returns the index of the element you want.</returns>
        public int GetIndex(TType elementToCheck)
        {
            if (!Contains(elementToCheck))
            {
                throw new InvalidOperationException("No such element excists in the list!!!");
            }

            int  indexOfElement = 0;
            Node currNode       = head;

            while (!currNode.Equals(tail) && !currNode.Value.Equals(elementToCheck))
            {
                currNode = currNode.Next;

                indexOfElement++;
            }

            return(indexOfElement);
        }