Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • C#

Idiom #136 Remove all occurrences of a value from a list

Remove all occurrences of the value x from list items.
This will alter the original list or return a new list, depending on which is more idiomatic.

using System.Collections.Generic;
items.RemoveAll(r => r == x);

This is O(n)
(remove #{x} items)

Puts the x value in a set that serves as simple predicate

New implementation...