Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8114196

SortedList: sourceIndex not update on permutated notification

XMLWordPrintable


      test case:

          
          private static class Permutator<E> extends ObservableListWrapper<E> {
              private List<E> backingList;
              public Permutator(List<E> list) {
                  super(list);
                  this.backingList = list;
              }
              
              public void swap() {
                  E first = get(0);
                  backingList.set(0, get(size() - 1));
                  backingList.set(size() -1, first);
                  callObservers(new GenericChange.SimplePermutationChange(0, size(), this));
              }
              
          }
          /**
           * SortedList cant cope with permutations.
           */
          @Test
          public void testPermutate() {
              List<Integer> list = new ArrayList<Integer>();
              for (int i = 0; i < 3; i++) {
                  list.add(i);
              }
              Permutator<Integer> permutator = new Permutator<Integer>(list);
              SortedList<Integer> sorted = new SortedList<Integer>(permutator);
              permutator.swap();
              assertEquals(0, sorted.getSourceIndex(sorted.size() - 1));
          }
          

            msladecek Martin Sládeček
            fastegal Jeanette Winzenburg
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: