@Test public void sortedView2() { ArrayDouble values = new ArrayDouble(5,3,1,4,2,0); ArrayInt indexes = new ArrayInt(0,3,1,4,2,5); SortedListView sortedView = ListNumbers.sortedView(values, indexes); assertThat(values, equalTo(new ArrayDouble(5,3,1,4,2,0))); assertThat(sortedView, equalTo((ListNumber) new ArrayDouble(5,4,3,2,1,0))); assertThat(sortedView.getIndexes(), equalTo((ListInt) new ArrayInt(0,3,1,4,2,5))); }
public static SortedListView sortedView(ListNumber values) { SortedListView view = new SortedListView(values); if (values.size() <= 1) { return view; } double value = values.getDouble(0); for (int i = 1; i < values.size(); i++) { double newValue = values.getDouble(i); if (value > newValue) { SortedListView.quicksort(view); return view; } value = newValue; } return view; }
ListNumbers { public static SortedListView sortedView(ListNumber values) { SortedListView view = new SortedListView(values); if (values.size() <= 1) { return view; } double value = values.getDouble(0); for (int i = 1; i < values.size(); i++) { double newValue = values.getDouble(i); if (value > newValue) { SortedListView.quicksort(view); return view; } value = newValue; } return view; } }
ListNumbers { public static SortedListView sortedView(ListNumber values) { SortedListView view = new SortedListView(values); if (values.size() <= 1) { return view; } double value = values.getDouble(0); for (int i = 1; i < values.size(); i++) { double newValue = values.getDouble(i); if (value > newValue) { SortedListView.quicksort(view); return view; } value = newValue; } return view; }  }
ListNumbers { public static SortedListView sortedView(ListNumber values) { SortedListView view = new SortedListView(values); if (values.size() <= 1) { return view; } double value = values.getDouble(0); for (int i = 1; i < values.size(); i++) { double newValue = values.getDouble(i); if (value > newValue) { SortedListView.quicksort(view); return view; } value = newValue; } return view; }  static SortedListView sortedView(ListNumber values); static SortedListView sortedView(ListNumber values, ListInt indexes); static int binarySearchValueOrLower(ListNumber values, double value); static int binarySearchValueOrHigher(ListNumber values, double value); static ListNumber linearListFromRange(final double minValue, final double maxValue, final int size); static ListNumber linearList(final double initialValue, final double increment, final int size); static boolean isLinear(ListNumber listNumber); static ListNumber toListNumber(Object primitiveArray); static ListNumber listView(ListNumber list, ListInt indexes); }
ListNumbers { public static SortedListView sortedView(ListNumber values) { SortedListView view = new SortedListView(values); if (values.size() <= 1) { return view; } double value = values.getDouble(0); for (int i = 1; i < values.size(); i++) { double newValue = values.getDouble(i); if (value > newValue) { SortedListView.quicksort(view); return view; } value = newValue; } return view; }  static SortedListView sortedView(ListNumber values); static SortedListView sortedView(ListNumber values, ListInt indexes); static int binarySearchValueOrLower(ListNumber values, double value); static int binarySearchValueOrHigher(ListNumber values, double value); static ListNumber linearListFromRange(final double minValue, final double maxValue, final int size); static ListNumber linearList(final double initialValue, final double increment, final int size); static boolean isLinear(ListNumber listNumber); static ListNumber toListNumber(Object primitiveArray); static ListNumber listView(ListNumber list, ListInt indexes);  }