private void runArrayListAddAll(String type, Object[] objects) {
   ArrayList<Object> listToAddAll = new ArrayList<>(Arrays.asList(objects));
   for (int i = 0; i < 100; i++) {
     this.runArrayListAddAll(listToAddAll, 100);
   }
   for (int i = 0; i < 100; i++) {
     this.runArrayListAddAll(listToAddAll, 100);
   }
   long now1 = System.currentTimeMillis();
   for (int i = 0; i < 100; i++) {
     this.runArrayListAddAll(listToAddAll, 1000);
   }
   long time1 = System.currentTimeMillis() - now1;
   LOGGER.info("ArrayList, list size 100,000, {} addAll/msec: {}", type, 100000 / time1);
   long now2 = System.currentTimeMillis();
   this.runArrayListAddAll(new ArrayList<>(Interval.oneTo(100)), 100000000);
   long time2 = System.currentTimeMillis() - now2;
   LOGGER.info("ArrayList, list size 100, addAll/msec: {}", 100000000 / time2);
   long now3 = System.currentTimeMillis();
   this.runArrayListAddAll(new ArrayList<>(Interval.oneTo(1)), 1000000000);
   long time3 = System.currentTimeMillis() - now3;
   LOGGER.info("ArrayList, list size 1, addAll/msec: {}", 1000000000 / time3);
   long now4 = System.currentTimeMillis();
   this.runArrayListAddAll(new ArrayList<>(), 1000000000);
   long time4 = System.currentTimeMillis() - now4;
   LOGGER.info("ArrayList, list size (empty), addAll/msec: {}", 1000000000 / time4);
 }
예제 #2
0
 @Test
 public void newSet() {
   for (int i = 1; i <= 5; i++) {
     Interval interval = Interval.oneTo(i);
     Verify.assertEqualsAndHashCode(UnifiedSet.newSet(interval), Sets.immutable.ofAll(interval));
   }
 }
  @Override
  @Test
  public void forEachWithIndex() {
    super.forEachWithIndex();

    MutableList<Integer> list = MultiReaderFastList.newList(Interval.oneTo(5));
    list.forEachWithIndex((object, index) -> Assert.assertEquals(index, object - 1));
  }
 @Test
 public void testEmptyConstructor() {
   MutableSortedBagMultimap<Integer, Integer> map = TreeBagMultimap.newMultimap();
   for (int i = 1; i < 6; ++i) {
     for (int j = 1; j < i + 1; ++j) {
       map.put(i, j);
     }
   }
   Verify.assertSize(5, map.keysView().toList());
   for (int i = 1; i < 6; ++i) {
     Verify.assertSortedBagsEqual(TreeBag.newBag(Interval.oneTo(i)), map.get(i));
   }
 }
 @Test
 public void notInInterval() {
   assertAccepts(Predicates.notIn(Interval.oneTo(3)), 4);
   assertToString(Predicates.notIn(Interval.oneTo(3)));
 }
 @Test
 public void inInterval() {
   assertAccepts(Predicates.in(Interval.oneTo(3)), 2);
   assertToString(Predicates.in(Interval.oneTo(3)));
 }
 @Test
 public void subListSort() {
   MutableList<Integer> list =
       Interval.from(0).to(20).addAllTo(MultiReaderFastList.newList()).subList(2, 18).sortThis();
   Assert.assertEquals(FastList.newList(list), Interval.from(2).to(17));
 }
 private MutableList<Integer> getIntegerList() {
   return MultiReaderFastList.newList(Interval.toReverseList(1, 5));
 }