SHARE
TWEET

Untitled

a guest Jan 24th, 2020 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     private LinkedList<E> fusion(LinkedList<E> leftList, LinkedList<E> rightList) {
  2.         LinkedList<E> fusionList = new LinkedList<>();
  3.         int index = 0;
  4.         while (leftList.size() != 0 && rightList.size() != 0) {
  5.             System.out.println("LISTES ;-; : \n"+leftList+" / "+rightList);
  6.             if(leftList.get(0).compareTo(rightList.get(0)) >= 0) {
  7.                 if (fusionList.size() == 0) {fusionList.addFirst(rightList.get(0));}
  8.                 else { fusionList.add(index, rightList.get(0)); }
  9.                 rightList.remove(0);
  10.                 index++;
  11.                 System.out.println("FUSION IS "+fusionList);
  12.             }
  13.             else if(leftList.get(0).compareTo(rightList.get(0)) < 0) {
  14.                 if (fusionList.size() == 0) {fusionList.addFirst(leftList.get(0));}
  15.                 else { fusionList.add(index, leftList.get(0)); }
  16.                 leftList.remove(0);
  17.                 index++;
  18.                 System.out.println("FUSION IS "+fusionList);
  19.             }
  20.         }
  21.         fusionList.addAll(leftList);
  22.         fusionList.addAll(rightList);
  23.         System.out.println("end fusion: FUSION IS "+fusionList);
  24.         return fusionList;
  25.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top