float maxScore = 0;
Collector<Element> c = new SortedCollector<Element>(capacity);
assertTrue(c.isEmpty());
for(int i = 0; i < 100; i++) {
Element element = new SimpleElement(i);
float score = rand.nextFloat();
element.setScore(score);
maxScore = Math.max(maxScore, score);
c.add(new ElementHit<Element>(element, score));
}
assertEquals(capacity, c.capacity());
assertEquals(capacity, c.size());
assertFalse(c.isEmpty());
List<Element> results = c.elements();
assertEquals(capacity, results.size());
assertEquals(maxScore, results.get(0).getScore());
float score = maxScore;
for(int i = 0, cnt = results.size(); i < cnt; i++) {
Element element = results.get(i);
assertTrue(score >= element.getScore());
score = element.getScore();
}
c.clear();
assertEquals(capacity, c.capacity());
assertEquals(0, c.size());