Advertisement
Guest User

Untitled

a guest
Apr 5th, 2020
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1.       public void Remove(Func<U,bool> shouldRemove)
  2.         {
  3.             Node<U> previous = null;
  4.             int counter = 0;
  5.             for (current = head; current != null; current = current.Next)
  6.             {
  7.                 if (shouldRemove(current.Value))
  8.                 {
  9.                     if (previous != null)
  10.                     {
  11.                         previous.Next = current.Next;
  12.                     }
  13.                     else
  14.                     {
  15.                         head = head.Next;
  16.                     }
  17.                 }
  18.                 else
  19.                 {
  20.                     previous = current;
  21.                 }
  22.                 counter++;
  23.             }
  24.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement