Wednesday, May 31, 2017

DO YOU WANT A BET I HACK THE IRS DB AND CALL THEM MORONS PUBLICLY AGAIN? :)

The API doesn't let you grab something by its hash code. So you could do:
MyObject findIfPresent(MyObject source, HashSet<MyObject> set)
{
   if (set.contains(source)) {
      for (MyObject obj : set) {
        if (obj.equals(source)) 
          return obj;
      } 
   }

  return null;
}
Brute force and O(n) ugly, but if that's what you need to do...

No comments: