title: C# List removeall taking two arguments in the predicate?
body: <p>(I've done as much as possible search based on keywords of "removeall where" or "removeall two argument predicate" without much luck so here goes)</p>
  
  <p>The problem is I have a list of objects (of Class Wave) and a relationship function as:
  <strong>private bool AinB(Wave A, Wave B)</strong>, returning true if A 'is in' B. Also AinB(x,y) is true guarantees AinB(y,x) is false.  </p>
  
  <p>What's the best way to remove all of the objects in the list where the objects 'is in' another object in the list? i.e., after the removal, the list should only contain objects where neither are in the 'is in' relationship with any other object in the list?</p>
  
  <p>ideally this can be done easily as a</p>
  
  <p>listX.RemoveAll( (x,y) => AinB(x,y)) but of course this is not legal in C#, also there's no easy way to specify which to remove, x or y. </p>
  
  <p>I thought about looping through the list with an index </p>
  
  <pre><code>int i = listX.Count - 1;
  while (i&gt;=0)
  {
      int r = listX.RemoveAll(X =&gt; AinB(X, listX[i]));
      i = i - r - 1;
  }
  </code></pre>
  
  <p>This seems to work, but I am wondering if there's better way with straight linq code to solve the problem. 
  Thanks. </p>