Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. public class MainBot  {
  2.    HashSet<String> mySet = loadFromfile();  //a very big set!
  3.  
  4.    public List<String> doSomething()  {
  5.        List<String> result = new LinkedList<>();
  6.        ...
  7.        List<String> myList = ... //big list!
  8.  
  9.        for (String s: myList)  {
  10.              if (new UniqueItemCondition(s, mySet).isTrue())  {
  11.                  result.add(s);
  12.              }
  13.        }
  14.  
  15.        return result;
  16. }
  17. public class UniqueItemCondition  {
  18.           public boolean isTrue(String s, Set<String> initialSet)  {
  19.                 return !initialSet.contains(s);
  20.           }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement