### Question:
ObjectSelector { public ObjectSelector<T> selectLevelledSmallestScores(int n, int maxSize) { ObjectSelector<T> result = new ObjectSelector<T>(); if (size() == 0 || n == 0) { return result; } DenseVector ranks = toDenseVector(); MatrixUtils.rank(ranks); int [] unrank = new int[size()]; for (int i=0; i<ranks.size(); i++) { int ix = (int) Math.round(ranks.get(i))-1; unrank[ix] = i; } ArrayList<Integer> rankStarts = getRankStarts(unrank); for (int i=0; i<rankStarts.size()-1; i++) { int rank_start_ix = rankStarts.get(i); int next_rank_start_ix = rankStarts.get(i+1); if (result.size() < maxSize) { for (int iy = rank_start_ix; iy<next_rank_start_ix; iy++) { result.add(elements.get(unrank[iy]), scores.get(unrank[iy])); } } if (result.size() >= n) { break; } } return result; }  void add(T element, Double score); void add(List<T> elements, double [] scores); void add(FeatureList features, DenseVector scores); @SuppressWarnings("unchecked") void add(ObjectSelector<Feature> list); int size(); ObjectSelector<T> selectLevelledSmallestScores(int n, int maxSize); DenseVector toDenseVector(); ObjectSelector<T> lt(double v); ObjectSelector<T> le(double v); ObjectSelector<T> gt(double v); ObjectSelector<T> ge(double v); ArrayList<T> getElements(); ArrayList<Double> getScores(); T getElement(int i); double getScore(int i);  }### Answer:
@Test public void testSelectLevelledSmallestScores() { ObjectSelector<Integer> selector = new ObjectSelector<Integer>(); selector.add(1, 40.0); selector.add(2, 20.0); selector.add(3, 20.0); selector.add(4, 10.0); ObjectSelector<Integer> result = selector.selectLevelledSmallestScores(0, 10); assertEquals(0, result.size()); result = selector.selectLevelledSmallestScores(1, 10); assertEquals(1, result.size()); assertEquals(4, (int) result.getElement(0)); assertEquals(10.0d, result.getScore(0), 0d); result = selector.selectLevelledSmallestScores(2, 10); assertEquals(3, result.size()); assertEquals(2, (int) result.getElement(1)); assertEquals(20.0d, result.getScore(1), 0d); result = selector.selectLevelledSmallestScores(3, 10); assertEquals(3, result.size()); assertEquals(3, (int) result.getElement(2)); assertEquals(20.0d, result.getScore(2), 0d); result = selector.selectLevelledSmallestScores(4, 10); assertEquals(4, result.size()); assertEquals(1, (int) result.getElement(3)); assertEquals(40.0d, result.getScore(3), 0d); result = selector.selectLevelledSmallestScores(5, 10); assertEquals(4, result.size()); result = selector.selectLevelledSmallestScores(2, 2); assertEquals(3, result.size()); assertEquals(2, (int) result.getElement(1)); assertEquals(20.0d, result.getScore(1), 0d); }