Advertisement
Guest User

Untitled

a guest
Aug 29th, 2015
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. private void removedoubles(List<int> exclude, List<int> listcopy)
  2. {
  3. for (int j = 0; j < exclude.Count(); j++)
  4. {
  5. for (int i = 0; i < listcopy.Count(); i++)
  6. {
  7. if (listcopy[i] == exclude[j])
  8. {
  9. if (i % 2 == 0) // even
  10. {
  11. //listcopy.RemoveRange(i, i + 1);
  12. listcopy.RemoveAt(i);
  13. listcopy.RemoveAt(i);
  14. i = i - 1;
  15. }
  16. else //odd
  17. {
  18. //listcopy.RemoveRange(i - 1, i);
  19. listcopy.RemoveAt(i - 1);
  20. listcopy.RemoveAt(i - 1);
  21. i = i - 2;
  22. }
  23. }
  24. }
  25. }
  26. }
  27.  
  28. private List<Tuple<int, int>> getWithoutDoubles(
  29. HashSet<int> exclude, List<Tuple<int, int>> original)
  30. {
  31. return original.Where(xy => (!exclude.Contains(xy.Item1) &&
  32. !exclude.Contains(xy.Item2)))
  33. .ToList();
  34. }
  35.  
  36. var a = new List<int> {1, 2, 3, 4, 5};
  37.  
  38. var b = new List<int> {1, 2, 3};
  39.  
  40. var c = (from i in a let found = b.Any(j => j == i) where !found select i).ToList();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement