コード例 #1
0
 @Test
 public void reject() {
   ImmutableBag<String> strings = this.newBag();
   Verify.assertIterableEmpty(strings.reject(Predicates.greaterThan("0")));
   Assert.assertEquals(strings, strings.reject(Predicates.lessThan("0")));
   Verify.assertIterableSize(strings.size() - 1, strings.reject(Predicates.lessThan("2")));
 }
コード例 #2
0
 @Test
 public void toArray() {
   Assert.assertArrayEquals(
       FastList.newListWith(1, 2).toArray(),
       this.lazyIterable.select(Predicates.lessThan(3)).toArray());
   Assert.assertArrayEquals(
       FastList.newListWith(1, 2).toArray(),
       this.lazyIterable.select(Predicates.lessThan(3)).toArray(new Object[2]));
 }
コード例 #3
0
 @Test
 public void rejectToTarget() {
   ImmutableBag<String> strings = this.newBag();
   Assert.assertEquals(
       strings, strings.reject(Predicates.lessThan("0"), FastList.<String>newList()).toBag());
   Verify.assertEmpty(strings.reject(Predicates.greaterThan("0"), FastList.<String>newList()));
 }
コード例 #4
0
 @Test
 public void select() {
   ImmutableBag<String> strings = this.newBag();
   Verify.assertContainsAll(
       FastList.newList(strings.select(Predicates.greaterThan("0"))), strings.toArray());
   Verify.assertIterableEmpty(strings.select(Predicates.lessThan("0")));
   Verify.assertIterableSize(strings.size() - 1, strings.select(Predicates.greaterThan("1")));
 }
コード例 #5
0
 /** @deprecated since 3.0. */
 @Deprecated
 @Test
 public void lazySelectForEach() {
   UnifiedSetWithHashingStrategy<Integer> integers =
       UnifiedSetWithHashingStrategy.newSetWith(INTEGER_HASHING_STRATEGY, 1, 2, 3, 4, 5);
   LazyIterable<Integer> select = integers.lazySelect(Predicates.lessThan(5));
   Sum sum = new IntegerSum(0);
   select.forEach(new SumProcedure<Integer>(sum));
   Assert.assertEquals(10, sum.getValue().intValue());
 }
コード例 #6
0
 @Override
 @Test
 public void forEach() {
   super.forEach();
   MutableList<Integer> list = FastList.newList();
   CompositeFastList<Integer> iterables = new CompositeFastList<Integer>();
   iterables.addComposited(Interval.oneTo(5).toList());
   iterables.addComposited(Interval.fromTo(6, 10).toList());
   iterables.forEach(CollectionAddProcedure.on(list));
   Verify.assertSize(10, list);
   Verify.assertAllSatisfy(list, Predicates.greaterThan(0).and(Predicates.lessThan(11)));
 }
コード例 #7
0
 @Override
 @Test
 public void forEachWith() {
   super.forEachWith();
   MutableList<Integer> list = FastList.newList();
   CompositeFastList<Integer> iterables = new CompositeFastList<Integer>();
   iterables.addComposited(Interval.fromTo(6, 10).toList());
   iterables.addComposited(Interval.oneTo(5).toList());
   iterables.forEachWith((each, parameter) -> list.add(parameter.intValue(), each), 0);
   Verify.assertSize(10, list);
   Verify.assertAllSatisfy(list, Predicates.greaterThan(0).and(Predicates.lessThan(11)));
   Verify.assertStartsWith(list, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6);
 }
コード例 #8
0
 @Override
 @Test
 public void forEachWithIndex() {
   super.forEachWithIndex();
   MutableList<Integer> list = FastList.newList();
   CompositeFastList<Integer> iterables = new CompositeFastList<Integer>();
   iterables.addComposited(Interval.fromTo(6, 10).toList());
   iterables.addComposited(Interval.oneTo(5).toList());
   iterables.forEachWithIndex((each, index) -> list.add(index, each));
   Verify.assertSize(10, list);
   Verify.assertAllSatisfy(list, Predicates.greaterThan(0).and(Predicates.lessThan(11)));
   Verify.assertStartsWith(list, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5);
 }
コード例 #9
0
 @Test
 @Override
 public void select() {
   ImmutableBag<String> strings = this.newBag();
   Verify.assertIterableEmpty(strings.select(Predicates.lessThan("0")));
 }
コード例 #10
0
 @Override
 public void partition() {
   PartitionImmutableBag<String> partition = this.newBag().partition(Predicates.lessThan("0"));
   Verify.assertIterableEmpty(partition.getSelected());
   Verify.assertIterableEmpty(partition.getRejected());
 }
コード例 #11
0
 @Test
 public void reject() {
   ImmutableCollection<Integer> integers = this.classUnderTest();
   Verify.assertIterableEmpty(integers.reject(Predicates.lessThan(integers.size() + 1)));
   Assert.assertEquals(integers, integers.reject(Predicates.greaterThan(integers.size())));
 }
コード例 #12
0
 @Test
 public void select() {
   Assert.assertEquals(
       FastList.newListWith(1, 2), this.lazyIterable.select(Predicates.lessThan(3)).toList());
 }
コード例 #13
0
 @Test
 public void rejectWithTarget() {
   Assert.assertEquals(
       FastList.newListWith(3, 4, 5, 6, 7),
       this.lazyIterable.reject(Predicates.lessThan(3), FastList.<Integer>newList()));
 }
コード例 #14
0
 @Test
 public void reject() {
   Assert.assertEquals(
       FastList.newListWith(3, 4, 5, 6, 7),
       this.lazyIterable.reject(Predicates.lessThan(3)).toList());
 }
コード例 #15
0
 @Test
 public void selectWithTarget() {
   Assert.assertEquals(
       FastList.newListWith(1, 2),
       this.lazyIterable.select(Predicates.lessThan(3), FastList.<Integer>newList()));
 }