Search in sources :

Example 1 with ImmutableIntSet

use of org.eclipse.collections.api.set.primitive.ImmutableIntSet in project eclipse-collections by eclipse.

the class StringIterateTest method asCodePointAdapterExtra.

@Test
public void asCodePointAdapterExtra() {
    Assert.assertEquals(9, StringIterate.asCodePointAdapter(THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG).count(i -> !Character.isLetter(i)));
    Assert.assertTrue(StringIterate.asCodePointAdapter(THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG).anySatisfy(Character::isWhitespace));
    Assert.assertEquals(8, StringIterate.asCodePointAdapter(THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG).count(Character::isWhitespace));
    Verify.assertSize(26, StringIterate.asCodePointAdapter(THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG).asLazy().select(Character::isLetter).collectInt(Character::toLowerCase).toSet());
    ImmutableIntSet alphaints = StringIterate.asCodePointAdapter(ALPHABET_LOWERCASE).toSet().toImmutable();
    Assert.assertTrue(StringIterate.asCodePointAdapter(THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG).containsAll(alphaints));
    Assert.assertEquals(IntSets.immutable.empty(), alphaints.newWithoutAll(StringIterate.asCodePointAdapter(THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG.toLowerCase())));
    Assert.assertEquals(TQBFJOTLD_MINUS_HALF_ABET_1, StringIterate.asCodePointAdapter(THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG.toLowerCase()).newWithoutAll(StringIterate.asCodePointAdapter(HALF_ABET.getOne())).toString());
    Assert.assertEquals(TQBFJOTLD_MINUS_HALF_ABET_2, StringIterate.asCodePointAdapter(THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG.toLowerCase()).newWithoutAll(StringIterate.asCodePointAdapter(HALF_ABET.getTwo())).toString());
}
Also used : CharPredicates(org.eclipse.collections.impl.block.factory.primitive.CharPredicates) Function(org.eclipse.collections.api.block.function.Function) CodePointList(org.eclipse.collections.impl.string.immutable.CodePointList) CharProcedure(org.eclipse.collections.api.block.procedure.primitive.CharProcedure) Verify(org.eclipse.collections.impl.test.Verify) IntSets(org.eclipse.collections.impl.factory.primitive.IntSets) MutableBag(org.eclipse.collections.api.bag.MutableBag) MutableList(org.eclipse.collections.api.list.MutableList) FastList(org.eclipse.collections.impl.list.mutable.FastList) CharToCharFunctions(org.eclipse.collections.impl.block.factory.primitive.CharToCharFunctions) CodePointAdapter(org.eclipse.collections.impl.string.immutable.CodePointAdapter) MutableSet(org.eclipse.collections.api.set.MutableSet) CodePointPredicate(org.eclipse.collections.impl.block.predicate.CodePointPredicate) MutableMap(org.eclipse.collections.api.map.MutableMap) Functions(org.eclipse.collections.impl.block.factory.Functions) Tuples(org.eclipse.collections.impl.tuple.Tuples) CharAdapter(org.eclipse.collections.impl.string.immutable.CharAdapter) CharList(org.eclipse.collections.api.list.primitive.CharList) IntList(org.eclipse.collections.api.list.primitive.IntList) CodePointProcedure(org.eclipse.collections.impl.block.procedure.primitive.CodePointProcedure) Twin(org.eclipse.collections.api.tuple.Twin) CharArrayList(org.eclipse.collections.impl.list.mutable.primitive.CharArrayList) ImmutableCharList(org.eclipse.collections.api.list.primitive.ImmutableCharList) Procedures(org.eclipse.collections.impl.block.factory.Procedures) Test(org.junit.Test) CharSets(org.eclipse.collections.impl.factory.primitive.CharSets) Lists(org.eclipse.collections.impl.factory.Lists) AddFunction(org.eclipse.collections.impl.block.function.AddFunction) ImmutableIntSet(org.eclipse.collections.api.set.primitive.ImmutableIntSet) Assert(org.junit.Assert) ImmutableCharSet(org.eclipse.collections.api.set.primitive.ImmutableCharSet) CodePointFunction(org.eclipse.collections.impl.block.function.primitive.CodePointFunction) UnifiedSet(org.eclipse.collections.impl.set.mutable.UnifiedSet) ImmutableIntSet(org.eclipse.collections.api.set.primitive.ImmutableIntSet) Test(org.junit.Test)

Example 2 with ImmutableIntSet

use of org.eclipse.collections.api.set.primitive.ImmutableIntSet in project eclipse-collections by eclipse.

the class PrimitiveStreamsTest method toImmutableIntSet.

@Test
public void toImmutableIntSet() {
    ImmutableIntSet set = PrimitiveStreams.iIntSet(IntStream.rangeClosed(1, 10));
    Assert.assertEquals(IntInterval.oneTo(10).toSet(), set);
    Assert.assertEquals(IntSets.mutable.ofAll(IntStream.rangeClosed(1, 10)), set);
}
Also used : ImmutableIntSet(org.eclipse.collections.api.set.primitive.ImmutableIntSet) Test(org.junit.Test)

Example 3 with ImmutableIntSet

use of org.eclipse.collections.api.set.primitive.ImmutableIntSet in project eclipse-collections by eclipse.

the class StringIterateTest method toCodePointListExtra.

@Test
public void toCodePointListExtra() {
    Assert.assertEquals(9, StringIterate.toCodePointList(THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG).count(i -> !Character.isLetter(i)));
    Assert.assertTrue(StringIterate.toCodePointList(THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG).anySatisfy(Character::isWhitespace));
    Assert.assertEquals(8, StringIterate.toCodePointList(THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG).count(Character::isWhitespace));
    Verify.assertSize(26, StringIterate.toCodePointList(THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG).asLazy().select(Character::isLetter).collectInt(Character::toLowerCase).toSet());
    ImmutableIntSet alphaints = StringIterate.toCodePointList(ALPHABET_LOWERCASE).toSet().toImmutable();
    Assert.assertTrue(StringIterate.toCodePointList(THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG).containsAll(alphaints));
    Assert.assertEquals(IntSets.immutable.empty(), alphaints.newWithoutAll(StringIterate.toCodePointList(THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG.toLowerCase())));
    Assert.assertTrue(StringIterate.toCodePointList(THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG).containsAll(StringIterate.toCodePointList(HALF_ABET.getOne())));
    Assert.assertEquals(TQBFJOTLD_MINUS_HALF_ABET_1, StringIterate.toCodePointList(THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG.toLowerCase()).newWithoutAll(StringIterate.toCodePointList(HALF_ABET.getOne())).toString());
    Assert.assertEquals(TQBFJOTLD_MINUS_HALF_ABET_2, StringIterate.toCodePointList(THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG.toLowerCase()).newWithoutAll(StringIterate.toCodePointList(HALF_ABET.getTwo())).toString());
}
Also used : CharPredicates(org.eclipse.collections.impl.block.factory.primitive.CharPredicates) Function(org.eclipse.collections.api.block.function.Function) CodePointList(org.eclipse.collections.impl.string.immutable.CodePointList) CharProcedure(org.eclipse.collections.api.block.procedure.primitive.CharProcedure) Verify(org.eclipse.collections.impl.test.Verify) IntSets(org.eclipse.collections.impl.factory.primitive.IntSets) MutableBag(org.eclipse.collections.api.bag.MutableBag) MutableList(org.eclipse.collections.api.list.MutableList) FastList(org.eclipse.collections.impl.list.mutable.FastList) CharToCharFunctions(org.eclipse.collections.impl.block.factory.primitive.CharToCharFunctions) CodePointAdapter(org.eclipse.collections.impl.string.immutable.CodePointAdapter) MutableSet(org.eclipse.collections.api.set.MutableSet) CodePointPredicate(org.eclipse.collections.impl.block.predicate.CodePointPredicate) MutableMap(org.eclipse.collections.api.map.MutableMap) Functions(org.eclipse.collections.impl.block.factory.Functions) Tuples(org.eclipse.collections.impl.tuple.Tuples) CharAdapter(org.eclipse.collections.impl.string.immutable.CharAdapter) CharList(org.eclipse.collections.api.list.primitive.CharList) IntList(org.eclipse.collections.api.list.primitive.IntList) CodePointProcedure(org.eclipse.collections.impl.block.procedure.primitive.CodePointProcedure) Twin(org.eclipse.collections.api.tuple.Twin) CharArrayList(org.eclipse.collections.impl.list.mutable.primitive.CharArrayList) ImmutableCharList(org.eclipse.collections.api.list.primitive.ImmutableCharList) Procedures(org.eclipse.collections.impl.block.factory.Procedures) Test(org.junit.Test) CharSets(org.eclipse.collections.impl.factory.primitive.CharSets) Lists(org.eclipse.collections.impl.factory.Lists) AddFunction(org.eclipse.collections.impl.block.function.AddFunction) ImmutableIntSet(org.eclipse.collections.api.set.primitive.ImmutableIntSet) Assert(org.junit.Assert) ImmutableCharSet(org.eclipse.collections.api.set.primitive.ImmutableCharSet) CodePointFunction(org.eclipse.collections.impl.block.function.primitive.CodePointFunction) UnifiedSet(org.eclipse.collections.impl.set.mutable.UnifiedSet) ImmutableIntSet(org.eclipse.collections.api.set.primitive.ImmutableIntSet) Test(org.junit.Test)

Aggregations

ImmutableIntSet (org.eclipse.collections.api.set.primitive.ImmutableIntSet)3 Test (org.junit.Test)3 MutableBag (org.eclipse.collections.api.bag.MutableBag)2 Function (org.eclipse.collections.api.block.function.Function)2 CharProcedure (org.eclipse.collections.api.block.procedure.primitive.CharProcedure)2 MutableList (org.eclipse.collections.api.list.MutableList)2 CharList (org.eclipse.collections.api.list.primitive.CharList)2 ImmutableCharList (org.eclipse.collections.api.list.primitive.ImmutableCharList)2 IntList (org.eclipse.collections.api.list.primitive.IntList)2 MutableMap (org.eclipse.collections.api.map.MutableMap)2 MutableSet (org.eclipse.collections.api.set.MutableSet)2 ImmutableCharSet (org.eclipse.collections.api.set.primitive.ImmutableCharSet)2 Twin (org.eclipse.collections.api.tuple.Twin)2 Functions (org.eclipse.collections.impl.block.factory.Functions)2 Procedures (org.eclipse.collections.impl.block.factory.Procedures)2 CharPredicates (org.eclipse.collections.impl.block.factory.primitive.CharPredicates)2 CharToCharFunctions (org.eclipse.collections.impl.block.factory.primitive.CharToCharFunctions)2 AddFunction (org.eclipse.collections.impl.block.function.AddFunction)2 CodePointFunction (org.eclipse.collections.impl.block.function.primitive.CodePointFunction)2 CodePointPredicate (org.eclipse.collections.impl.block.predicate.CodePointPredicate)2