How to intersect the data of two collections

    /**
     * Supports intersect two collections and return a single intersected collection
     * @param a First collection parameter
     * @param b Second collection parameter
     * @return Intersected collection of results
     */
      public static Collection intersect (Collection a, Collection b)
      {
          Collection result = new ArrayList ();

             try {
               for (T t: a){
                     if (b.remove (t)) {
                         result.add (t);
                     }
                 }
               } catch (Exception e) {
                    return result;
               }
   
               return result;
      }

Comments

Popular posts from this blog

Let's try to build scrum masters/project managers/software architects/even a company with training AI models

TCP Ports list

Problem Solving: Allotment calculator