@Override
 @Test
 public void subList() {
   super.subList();
   MutableList<String> list = this.newWith("A", "B", "C", "D");
   MutableList<String> sublist = list.subList(1, 3);
   Verify.assertPostSerializedEqualsAndHashCode(sublist);
   Verify.assertSize(2, sublist);
   Verify.assertContainsAll(sublist, "B", "C");
   sublist.add("X");
   Verify.assertSize(3, sublist);
   Verify.assertContainsAll(sublist, "B", "C", "X");
   Verify.assertSize(5, list);
   Verify.assertContainsAll(list, "A", "B", "C", "X", "D");
   sublist.remove("X");
   Verify.assertContainsAll(sublist, "B", "C");
   Verify.assertContainsAll(list, "A", "B", "C", "D");
   Assert.assertEquals("C", sublist.set(1, "R"));
   Verify.assertContainsAll(sublist, "B", "R");
   Verify.assertContainsAll(list, "A", "B", "R", "D");
   sublist.addAll(Arrays.asList("W", "G"));
   Verify.assertContainsAll(sublist, "B", "R", "W", "G");
   Verify.assertContainsAll(list, "A", "B", "R", "W", "G", "D");
   sublist.clear();
   Verify.assertEmpty(sublist);
   Verify.assertContainsAll(list, "A", "D");
 }
  @Override
  @Test
  public void retainAllIterable() {
    super.retainAllIterable();

    MutableList<Integer> objects = this.newWith(1, 2, 3);
    objects.retainAllIterable(Lists.fixedSize.of(1, 2));
    Verify.assertSize(2, objects);
    Verify.assertContainsAll(objects, 1, 2);
    MutableList<Integer> objects2 = this.newWith(1, 2, 3);
    objects2.retainAllIterable(Lists.fixedSize.of(1));
    Verify.assertSize(1, objects2);
    Verify.assertContainsAll(objects2, 1);
    MutableList<Integer> objects3 = this.newWith(1, 2, 3);
    objects3.retainAllIterable(Lists.fixedSize.of(3));
    Verify.assertSize(1, objects3);
    Verify.assertContainsAll(objects3, 3);
    MutableList<Integer> objects4 = this.newWith(1, 2, 3);
    objects4.retainAllIterable(Lists.fixedSize.of(2));
    Verify.assertSize(1, objects4);
    Verify.assertContainsAll(objects4, 2);
    MutableList<Integer> objects5 = this.newWith(1, 2, 3);
    objects5.retainAllIterable(Lists.fixedSize.of());
    Verify.assertEmpty(objects5);
    MutableList<Integer> objects6 = this.newWith(1, 2, 3);
    objects6.retainAllIterable(Lists.fixedSize.of(1, 2, 3));
    Verify.assertSize(3, objects6);
    Verify.assertContainsAll(objects6, 1, 2, 3);
  }
  @Test
  public void newListWithCollection() {
    Verify.assertEmpty(MultiReaderFastList.newList(Lists.fixedSize.of()));
    Verify.assertEmpty(MultiReaderFastList.newList(Sets.fixedSize.of()));
    Verify.assertEmpty(MultiReaderFastList.newList(FastList.newList()));
    Verify.assertEmpty(MultiReaderFastList.newList(FastList.newList(4)));

    MutableList<Integer> setToList =
        MultiReaderFastList.newList(UnifiedSet.newSetWith(1, 2, 3, 4, 5));
    Verify.assertNotEmpty(setToList);
    Verify.assertSize(5, setToList);
    Verify.assertContainsAll(setToList, 1, 2, 3, 4, 5);

    MutableList<Integer> arrayListToList =
        MultiReaderFastList.newList(Lists.fixedSize.of(1, 2, 3, 4, 5));
    Verify.assertNotEmpty(arrayListToList);
    Verify.assertSize(5, arrayListToList);
    Verify.assertStartsWith(arrayListToList, 1, 2, 3, 4, 5);

    MutableList<Integer> fastListToList =
        MultiReaderFastList.newList(FastList.<Integer>newList().with(1, 2, 3, 4, 5));
    Verify.assertNotEmpty(fastListToList);
    Verify.assertSize(5, fastListToList);
    Verify.assertStartsWith(fastListToList, 1, 2, 3, 4, 5);
  }
  @Override
  @Test
  public void removeAllIterable() {
    super.removeAllIterable();

    MutableList<Integer> objects = MultiReaderFastList.newListWith(1, 2, 3);
    objects.removeAllIterable(Lists.fixedSize.of(1, 2));
    Verify.assertSize(1, objects);
    Verify.assertContains(3, objects);
    MutableList<Integer> objects2 = MultiReaderFastList.newListWith(1, 2, 3);
    objects2.removeAllIterable(Lists.fixedSize.of(1));
    Verify.assertSize(2, objects2);
    Verify.assertContainsAll(objects2, 2, 3);
    MutableList<Integer> objects3 = MultiReaderFastList.newListWith(1, 2, 3);
    objects3.removeAllIterable(Lists.fixedSize.of(3));
    Verify.assertSize(2, objects3);
    Verify.assertContainsAll(objects3, 1, 2);
    MutableList<Integer> objects4 = MultiReaderFastList.newListWith(1, 2, 3);
    objects4.removeAllIterable(Lists.fixedSize.of());
    Verify.assertSize(3, objects4);
    Verify.assertContainsAll(objects4, 1, 2, 3);
    MutableList<Integer> objects5 = MultiReaderFastList.newListWith(1, 2, 3);
    objects5.removeAllIterable(Lists.fixedSize.of(1, 2, 3));
    Verify.assertEmpty(objects5);
    MutableList<Integer> objects6 = MultiReaderFastList.newListWith(1, 2, 3);
    objects6.removeAllIterable(Lists.fixedSize.of(2));
    Verify.assertSize(2, objects6);
    Verify.assertContainsAll(objects6, 1, 3);
  }
 @Test
 public void toArray() {
   MutableList<Integer> objects = SingletonListTest.newWith(1);
   Object[] array = objects.toArray();
   Verify.assertSize(1, array);
   Integer[] array2 = objects.toArray(new Integer[1]);
   Verify.assertSize(1, array2);
 }
 @Override
 @Test
 public void selectAndRejectWith() {
   MutableList<Integer> list = this.getIntegerList();
   Twin<MutableList<Integer>> result =
       list.selectAndRejectWith(Predicates2.in(), Lists.fixedSize.of(1));
   Verify.assertSize(1, result.getOne());
   Verify.assertSize(4, result.getTwo());
 }
 @Test
 public void addAllAtIndexEmpty() {
   MutableList<Integer> integers = this.newWith(5);
   integers.addAll(0, Lists.fixedSize.of());
   Verify.assertSize(1, integers);
   Verify.assertStartsWith(integers, 5);
   integers.addAll(0, FastList.newList(4));
   Verify.assertSize(1, integers);
   Verify.assertStartsWith(integers, 5);
   integers.addAll(0, Sets.fixedSize.of());
   Verify.assertSize(1, integers);
   Verify.assertStartsWith(integers, 5);
   FastList<String> zeroSizedList = FastList.newList(0);
   zeroSizedList.addAll(0, this.newWith("1", "2"));
 }
 @Test
 public void toSet() {
   Interval interval = Interval.evensFromTo(0, 10);
   MutableSet<Integer> set = interval.toSet();
   Verify.assertContainsAll(set, 0, 2, 4, 6, 8, 10);
   Verify.assertSize(6, set);
 }
 @Test
 public void toFastList() {
   Interval interval = Interval.evensFromTo(0, 10);
   FastList<Integer> toList = (FastList<Integer>) interval.toList();
   Verify.assertStartsWith(toList, 0, 2, 4, 6, 8, 10);
   Verify.assertSize(6, toList);
 }
 @Test
 public void subListOfSubList() {
   MutableList<String> list = this.newWith("A", "B", "C", "D");
   MutableList<String> sublist = list.subList(0, 3);
   MutableList<String> sublist2 = sublist.subList(0, 2);
   Verify.assertSize(2, sublist2);
   Verify.assertContainsAll(sublist, "A", "B");
   sublist2.add("X");
   Verify.assertSize(3, sublist2);
   Verify.assertStartsWith(sublist2, "A", "B", "X");
   Verify.assertContainsAll(sublist, "A", "B", "C", "X");
   Assert.assertEquals("X", sublist2.remove(2));
   Verify.assertSize(2, sublist2);
   Verify.assertContainsNone(sublist, "X");
   Verify.assertContainsNone(sublist2, "X");
 }
 @Test
 public void removeUsingPredicate() {
   MutableList<Integer> objects = MultiReaderFastList.newListWith(1, 2, 3, null);
   Assert.assertTrue(objects.removeIf(Predicates.isNull()));
   Verify.assertSize(3, objects);
   Verify.assertContainsAll(objects, 1, 2, 3);
 }
 @Override
 @Test
 public void select() {
   MutableList<Integer> list = this.getIntegerList();
   MutableList<Integer> results = list.select(Integer.class::isInstance);
   Verify.assertSize(5, results);
 }
 @Override
 @Test
 public void selectWith() {
   MutableList<Integer> list = this.getIntegerList();
   MutableList<Integer> results = list.selectWith(Predicates2.instanceOf(), Integer.class);
   Verify.assertSize(5, results);
 }
 @Test
 public void selectAndRejectWith() {
   MutableList<Integer> objects = SingletonListTest.newWith(1);
   Twin<MutableList<Integer>> result = objects.selectAndRejectWith(Object::equals, 1);
   Verify.assertSize(1, result.getOne());
   Verify.assertEmpty(result.getTwo());
 }
 @Override
 @Test
 public void removeIfWith() {
   MutableList<Integer> objects = MultiReaderFastList.newListWith(1, 2, 3, null);
   Assert.assertTrue(objects.removeIfWith((each, ignored) -> each == null, null));
   Verify.assertSize(3, objects);
   Verify.assertContainsAll(objects, 1, 2, 3);
 }
 @Test
 public void serializationOfSublist() {
   MutableList<Integer> collection = this.newWith(1, 2, 3, 4, 5);
   MutableList<Integer> deserializedCollection =
       SerializeTestHelper.serializeDeserialize(collection.subList(0, 2));
   Verify.assertSize(2, deserializedCollection);
   Verify.assertStartsWith(deserializedCollection, 1, 2);
   Assert.assertEquals(collection.subList(0, 2), deserializedCollection);
 }
 @Test
 public void intervalAsReverseArray() {
   Integer[] array = Interval.toReverseArray(1, 5);
   Verify.assertSize(5, array);
   Assert.assertTrue(ArrayIterate.contains(array, 1));
   Assert.assertTrue(ArrayIterate.contains(array, 5));
   Assert.assertEquals(ArrayIterate.getFirst(array), Integer.valueOf(5));
   Assert.assertEquals(ArrayIterate.getLast(array), Integer.valueOf(1));
 }
 @Test
 public void forEachOnFromToByInterval2() {
   List<Integer> result = new ArrayList<>();
   Interval interval = Interval.fromToBy(5, 1, -2);
   interval.forEach(CollectionAddProcedure.on(result));
   Verify.assertSize(3, result);
   Verify.assertContains(1, result);
   Verify.assertNotContains(2, result);
   Verify.assertContains(5, result);
 }
  @Test
  public void reverseForEachOnFromToInterval() {
    List<Integer> result = new ArrayList<>();
    Interval interval = Interval.oneTo(5);
    interval.reverseForEach(result::add);
    Verify.assertSize(5, result);
    Verify.assertContains(1, result);
    Verify.assertContains(5, result);
    Assert.assertEquals(Integer.valueOf(5), Iterate.getFirst(result));
    Assert.assertEquals(Integer.valueOf(1), Iterate.getLast(result));

    result.clear();
    interval.reverseThis().reverseForEach(result::add);
    Verify.assertSize(5, result);
    Verify.assertContains(1, result);
    Verify.assertContains(5, result);
    Assert.assertEquals(Integer.valueOf(1), Iterate.getFirst(result));
    Assert.assertEquals(Integer.valueOf(5), Iterate.getLast(result));
  }
 @Override
 @Test
 public void serialization() {
   MutableList<Integer> collection = this.newWith(1, 2, 3, 4, 5);
   MutableList<Integer> deserializedCollection =
       SerializeTestHelper.serializeDeserialize(collection);
   Verify.assertSize(5, deserializedCollection);
   Verify.assertStartsWith(deserializedCollection, 1, 2, 3, 4, 5);
   Assert.assertEquals(collection, deserializedCollection);
 }
 @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 testComparatorConstructors() {
   MutableSortedBagMultimap<Boolean, Integer> revMap =
       TreeBagMultimap.newMultimap(Collections.reverseOrder());
   for (int i = 1; i < 10; ++i) {
     revMap.put(IntegerPredicates.isOdd().accept(i), i);
   }
   Verify.assertSize(2, revMap.keysView().toList());
   Verify.assertSortedBagsEqual(
       TreeBag.newBagWith(Collections.reverseOrder(), 9, 7, 5, 3, 1), revMap.get(Boolean.TRUE));
   Verify.assertSortedBagsEqual(
       TreeBag.newBagWith(Collections.reverseOrder(), 8, 6, 4, 2), revMap.get(Boolean.FALSE));
   MutableSortedBagMultimap<Boolean, Integer> revMap2 = TreeBagMultimap.newMultimap(revMap);
   Verify.assertMapsEqual(revMap2.toMap(), revMap.toMap());
   Verify.assertSortedBagsEqual(
       TreeBag.newBagWith(Collections.reverseOrder(), 9, 7, 5, 3, 1), revMap2.get(Boolean.TRUE));
 }
  @Test
  public void setKeyPreservation() {
    Key key = new Key("key");

    Key duplicateKey1 = new Key("key");
    ImmutableSet<Key> set1 = Sets.immutable.of(key, duplicateKey1);
    Verify.assertSize(1, set1);
    Verify.assertContains(key, set1);
    Assert.assertSame(key, set1.getFirst());

    Key duplicateKey2 = new Key("key");
    ImmutableSet<Key> set2 = Sets.immutable.of(key, duplicateKey1, duplicateKey2);
    Verify.assertSize(1, set2);
    Verify.assertContains(key, set2);
    Assert.assertSame(key, set2.getFirst());

    Key duplicateKey3 = new Key("key");
    ImmutableSet<Key> set3 = Sets.immutable.of(key, new Key("not a dupe"), duplicateKey3);
    Verify.assertSize(2, set3);
    Verify.assertContainsAll("immutable set", set3, key, new Key("not a dupe"));
    Assert.assertSame(key, set3.detect(key::equals));

    Key duplicateKey4 = new Key("key");
    ImmutableSet<Key> set4 =
        Sets.immutable.of(key, new Key("not a dupe"), duplicateKey3, duplicateKey4);
    Verify.assertSize(2, set4);
    Verify.assertContainsAll("immutable set", set4, key, new Key("not a dupe"));
    Assert.assertSame(key, set4.detect(key::equals));

    ImmutableSet<Key> set5 =
        Sets.immutable.of(key, new Key("not a dupe"), new Key("me neither"), duplicateKey4);
    Verify.assertSize(3, set5);
    Verify.assertContainsAll(
        "immutable set", set5, key, new Key("not a dupe"), new Key("me neither"));
    Assert.assertSame(key, set5.detect(key::equals));

    ImmutableSet<Key> set6 = Sets.immutable.of(key, duplicateKey2, duplicateKey3, duplicateKey4);
    Verify.assertSize(1, set6);
    Verify.assertContains(key, set6);
    Assert.assertSame(key, set6.detect(key::equals));
  }
 @Test
 public void newSetWith() {
   Assert.assertSame(Sets.immutable.of(), Sets.immutable.of(Sets.immutable.of().toArray()));
   Verify.assertSize(1, Sets.immutable.of(1).castToSet());
   Verify.assertSize(1, Sets.immutable.of(1, 1).castToSet());
   Verify.assertSize(1, Sets.immutable.of(1, 1, 1).castToSet());
   Verify.assertSize(1, Sets.immutable.of(1, 1, 1, 1).castToSet());
   Verify.assertSize(1, Sets.immutable.of(1, 1, 1, 1, 1).castToSet());
   Verify.assertSize(2, Sets.immutable.of(1, 1, 1, 1, 2).castToSet());
   Verify.assertSize(2, Sets.immutable.of(2, 1, 1, 1, 1).castToSet());
   Verify.assertSize(2, Sets.immutable.of(1, 2, 1, 1, 1).castToSet());
   Verify.assertSize(2, Sets.immutable.of(1, 1, 2, 1, 1).castToSet());
   Verify.assertSize(2, Sets.immutable.of(1, 1, 1, 2, 1).castToSet());
   Verify.assertSize(2, Sets.immutable.of(1, 1, 1, 2).castToSet());
   Verify.assertSize(2, Sets.immutable.of(2, 1, 1, 1).castToSet());
   Verify.assertSize(2, Sets.immutable.of(1, 2, 1, 1).castToSet());
   Verify.assertSize(2, Sets.immutable.of(1, 1, 2, 1).castToSet());
   Verify.assertSize(2, Sets.immutable.of(1, 1, 2).castToSet());
   Verify.assertSize(2, Sets.immutable.of(2, 1, 1).castToSet());
   Verify.assertSize(2, Sets.immutable.of(1, 2, 1).castToSet());
   Verify.assertSize(2, Sets.immutable.of(1, 2).castToSet());
   Verify.assertSize(3, Sets.immutable.of(1, 2, 3).castToSet());
   Verify.assertSize(3, Sets.immutable.of(1, 2, 3, 1).castToSet());
   Verify.assertSize(3, Sets.immutable.of(2, 1, 3, 1).castToSet());
   Verify.assertSize(3, Sets.immutable.of(2, 3, 1, 1).castToSet());
   Verify.assertSize(3, Sets.immutable.of(2, 1, 1, 3).castToSet());
   Verify.assertSize(3, Sets.immutable.of(1, 1, 2, 3).castToSet());
   Verify.assertSize(4, Sets.immutable.of(1, 2, 3, 4).castToSet());
   Verify.assertSize(4, Sets.immutable.of(1, 2, 3, 4, 1).castToSet());
 }
 @Test
 public void intervalToList() {
   MutableList<Integer> list = Interval.fromTo(1, 5).toList();
   Verify.assertSize(5, list);
   Verify.assertContainsAll(list, 1, 2, 3, 4, 5);
 }
 @Test
 public void intervalAsReverseList() {
   MutableList<Integer> list = Interval.toReverseList(1, 5);
   Verify.assertSize(5, list);
   Verify.assertStartsWith(list, 5, 4, 3, 2, 1);
 }
 @Test
 public void intervalToSet() {
   MutableSet<Integer> set = Interval.toSet(1, 5);
   Verify.assertSize(5, set);
   Verify.assertContainsAll(set, 1, 2, 3, 4, 5);
 }
 @Test
 public void testMutableTransparency() {
   this.mutableMap.remove(NAP_TIME);
   Verify.assertSize(this.mutableMap.size(), this.unmodifiableMap);
 }
 @Test
 public void testSize() {
   Verify.assertSize(this.mutableMap.size(), this.unmodifiableMap);
 }