Search in sources :

Example 1 with ImmutableCharSet

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

the class StringIterateTest method asCharAdapterExtra.

@Test
public void asCharAdapterExtra() {
    Assert.assertEquals(9, StringIterate.asCharAdapter(THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG).count(c -> !Character.isLetter(c)));
    Assert.assertTrue(StringIterate.asCharAdapter(THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG).anySatisfy(Character::isWhitespace));
    Assert.assertEquals(8, StringIterate.asCharAdapter(THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG).count(Character::isWhitespace));
    Verify.assertSize(26, StringIterate.asCharAdapter(THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG).asLazy().select(Character::isLetter).collectChar(Character::toLowerCase).toSet());
    ImmutableCharSet alphaCharAdapter = StringIterate.asCharAdapter(ALPHABET_LOWERCASE).toSet().toImmutable();
    Assert.assertTrue(StringIterate.asCharAdapter(THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG).containsAll(alphaCharAdapter));
    Assert.assertEquals(CharSets.immutable.empty(), alphaCharAdapter.newWithoutAll(StringIterate.asCharAdapter(THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG.toLowerCase())));
    Assert.assertEquals(TQBFJOTLD_MINUS_HALF_ABET_1, StringIterate.asCharAdapter(THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG.toLowerCase()).newWithoutAll(StringIterate.asCharAdapter(HALF_ABET.getOne())).toString());
    Assert.assertEquals(TQBFJOTLD_MINUS_HALF_ABET_2, StringIterate.asCharAdapter(THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG.toLowerCase()).newWithoutAll(StringIterate.asCharAdapter(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) ImmutableCharSet(org.eclipse.collections.api.set.primitive.ImmutableCharSet) Test(org.junit.Test)

Aggregations

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