Class CharAdapter
java.lang.Object
org.eclipse.collections.impl.primitive.AbstractCharIterable
org.eclipse.collections.impl.string.immutable.CharAdapter
- All Implemented Interfaces:
Serializable,CharSequence,CharIterable,ImmutableCharCollection,CharList,ImmutableCharList,OrderedCharIterable,ReversibleCharIterable,PrimitiveIterable
public class CharAdapter extends AbstractCharIterable implements CharSequence, ImmutableCharList, Serializable
Provides a view into the char[] stored in a String as an ImmutableCharList. This is a cleaner more OO way of
providing many of the iterable protocols available in StringIterate for char values.
- Since:
- 7.0
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description CharAdapter(String value) -
Method Summary
Modifier and Type Method Description static CharAdapteradapt(String value)booleanallSatisfy(CharPredicate predicate)Returns true if all of the elements in the CharIterable return true for the specified predicate, otherwise returns false.booleananySatisfy(CharPredicate predicate)Returns true if any of the elements in the CharIterable return true for the specified predicate, otherwise returns false.voidappendString(Appendable appendable, String start, String separator, String end)Prints a string representation of this collection onto the givenAppendable.LazyCharIterableasReversed()intbinarySearch(char value)charcharAt(int index)CharIteratorcharIterator()Returns a primitive iterator that can be used to iterate over the CharIterable in an imperative style.RichIterable<CharIterable>chunk(int size)Partitions elements in fixed size chunks.<V> ImmutableList<V>collect(CharToObjectFunction<? extends V> function)Returns a new collection with the results of applying the specified function on each element of the source collection.CharAdaptercollectChar(CharToCharFunction function)booleancontains(char expected)Returns true if the value is contained in the CharIterable, and false if it is not.intcount(CharPredicate predicate)Returns a count of the number of elements in the CharIterable that return true for the specified predicate.chardetectIfNone(CharPredicate predicate, char ifNone)CharAdapterdistinct()longdotProduct(CharList list)voideach(CharProcedure procedure)A synonym for forEach.booleanequals(Object otherList)Follows the same general contract asList.equals(Object).voidforEach(CharProcedure procedure)Applies the CharProcedure to each element in the CharIterable.voidforEachWithIndex(CharIntProcedure procedure)static CharAdapterfrom(char... chars)static CharAdapterfrom(CharIterable iterable)charget(int index)CharactergetCharacter(int index)chargetFirst()chargetLast()inthashCode()Follows the same general contract asList.hashCode().intindexOf(char value)<T> TinjectInto(T injectedValue, ObjectCharToObjectFunction<? super T,? extends T> function)<T> TinjectIntoWithIndex(T injectedValue, ObjectCharIntToObjectFunction<? super T,? extends T> function)booleanisEmpty()Returns true if this iterable has zero items.intlastIndexOf(char value)intlength()charmax()charmin()CharAdapternewWith(char element)CharAdapternewWithAll(CharIterable elements)CharAdapternewWithout(char element)CharAdapternewWithoutAll(CharIterable elements)booleannoneSatisfy(CharPredicate predicate)Returns true if none of the elements in the CharIterable return true for the specified predicate, otherwise returns false.CharAdapterreject(CharPredicate predicate)Returns a new CharIterable with all of the elements in the CharIterable that return false for the specified predicate.CharAdapterselect(CharPredicate predicate)Returns a new CharIterable with all of the elements in the CharIterable that return true for the specified predicate.intsize()Returns the number of items in this iterable.ImmutableCharListsubList(int fromIndex, int toIndex)StringsubSequence(int start, int end)longsum()char[]toArray()Converts the CharIterable to a primitive char array.char[]toArray(char[] target)Converts the CharIterable to a primitive char array.MutableCharBagtoBag()Converts the CharIterable to a new MutableCharBag.ImmutableCharListtoImmutable()Returns an immutable copy of this list.MutableCharListtoList()Converts the CharIterable to a new MutableCharList.CharAdaptertoReversed()MutableCharSettoSet()Converts the CharIterable to a new MutableCharSet.StringtoString()The value of toString must be strictly implemented as defined in CharSequence.StringBuildertoStringBuilder()<T> ImmutableList<CharObjectPair<T>>zip(Iterable<T> iterable)Returns anImmutableListformed from thisImmutableCharListand aListIterableby combining corresponding elements in pairs.ImmutableList<CharCharPair>zipChar(CharIterable iterable)Returns anImmutableListformed from thisImmutableCharListand anotherCharListby combining corresponding elements in pairs.Methods inherited from class org.eclipse.collections.impl.primitive.AbstractCharIterable
asLazy, average, containsAll, containsAll, maxIfEmpty, median, minIfEmpty, toSortedArray, toSortedListMethods inherited from interface org.eclipse.collections.api.CharIterable
asLazy, average, averageIfEmpty, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, containsAll, containsAll, flatCollect, maxIfEmpty, median, medianIfEmpty, minIfEmpty, reduce, reduceIfEmpty, reject, select, summaryStatistics, toSortedArray, toSortedListMethods inherited from interface org.eclipse.collections.api.list.primitive.ImmutableCharList
collectWithIndex, tapMethods inherited from interface org.eclipse.collections.api.ordered.primitive.OrderedCharIterable
collectWithIndexMethods inherited from interface org.eclipse.collections.api.PrimitiveIterable
appendString, appendString, makeString, makeString, makeString, notEmpty
-
Constructor Details
-
Method Details
-
adapt
-
from
-
from
-
charAt
public char charAt(int index)- Specified by:
charAtin interfaceCharSequence
-
length
public int length()- Specified by:
lengthin interfaceCharSequence
-
isEmpty
public boolean isEmpty()Description copied from interface:PrimitiveIterableReturns true if this iterable has zero items.- Specified by:
isEmptyin interfacePrimitiveIterable
-
subSequence
- Specified by:
subSequencein interfaceCharSequence
-
toStringBuilder
-
toString
The value of toString must be strictly implemented as defined in CharSequence.- Specified by:
toStringin interfaceCharSequence- Specified by:
toStringin interfacePrimitiveIterable- Overrides:
toStringin classAbstractCharIterable- Returns:
- a string representation of this PrimitiveIterable
- See Also:
AbstractCollection.toString()
-
charIterator
Description copied from interface:CharIterableReturns a primitive iterator that can be used to iterate over the CharIterable in an imperative style.- Specified by:
charIteratorin interfaceCharIterable
-
toArray
public char[] toArray()Description copied from interface:CharIterableConverts the CharIterable to a primitive char array.- Specified by:
toArrayin interfaceCharIterable
-
toArray
public char[] toArray(char[] target)Description copied from interface:CharIterableConverts the CharIterable to a primitive char array. If the collection fits into the provided array it is used to store its elements and is returned from the method, otherwise a new array of the appropriate size is allocated and returned. If the iterable is empty, the target array is returned unchanged.- Specified by:
toArrayin interfaceCharIterable
-
contains
public boolean contains(char expected)Description copied from interface:CharIterableReturns true if the value is contained in the CharIterable, and false if it is not.- Specified by:
containsin interfaceCharIterable
-
forEach
Description copied from interface:CharIterableApplies the CharProcedure to each element in the CharIterable.- Specified by:
forEachin interfaceCharIterable
-
each
Description copied from interface:CharIterableA synonym for forEach.- Specified by:
eachin interfaceCharIterable
-
distinct
- Specified by:
distinctin interfaceCharList- Specified by:
distinctin interfaceImmutableCharList- Specified by:
distinctin interfaceReversibleCharIterable
-
newWith
- Specified by:
newWithin interfaceImmutableCharCollection- Specified by:
newWithin interfaceImmutableCharList
-
newWithout
- Specified by:
newWithoutin interfaceImmutableCharCollection- Specified by:
newWithoutin interfaceImmutableCharList
-
newWithAll
- Specified by:
newWithAllin interfaceImmutableCharCollection- Specified by:
newWithAllin interfaceImmutableCharList
-
newWithoutAll
- Specified by:
newWithoutAllin interfaceImmutableCharCollection- Specified by:
newWithoutAllin interfaceImmutableCharList
-
toReversed
- Specified by:
toReversedin interfaceCharList- Specified by:
toReversedin interfaceImmutableCharList- Specified by:
toReversedin interfaceReversibleCharIterable
-
subList
- Specified by:
subListin interfaceCharList- Specified by:
subListin interfaceImmutableCharList- See Also:
List.subList(int fromIndex, int toIndex)
-
get
public char get(int index) -
getCharacter
-
dotProduct
- Specified by:
dotProductin interfaceCharList
-
binarySearch
public int binarySearch(char value)- Specified by:
binarySearchin interfaceCharList
-
lastIndexOf
public int lastIndexOf(char value)- Specified by:
lastIndexOfin interfaceCharList
-
toImmutable
Description copied from interface:CharListReturns an immutable copy of this list. If the list is immutable, it returns itself.- Specified by:
toImmutablein interfaceCharList
-
getLast
public char getLast()- Specified by:
getLastin interfaceReversibleCharIterable
-
asReversed
- Specified by:
asReversedin interfaceReversibleCharIterable
-
injectIntoWithIndex
public <T> T injectIntoWithIndex(T injectedValue, ObjectCharIntToObjectFunction<? super T,? extends T> function)- Specified by:
injectIntoWithIndexin interfaceOrderedCharIterable- Specified by:
injectIntoWithIndexin interfaceReversibleCharIterable
-
getFirst
public char getFirst()- Specified by:
getFirstin interfaceOrderedCharIterable
-
indexOf
public int indexOf(char value)- Specified by:
indexOfin interfaceOrderedCharIterable
-
forEachWithIndex
- Specified by:
forEachWithIndexin interfaceOrderedCharIterable
-
select
Description copied from interface:CharIterableReturns a new CharIterable with all of the elements in the CharIterable that return true for the specified predicate.- Specified by:
selectin interfaceCharIterable- Specified by:
selectin interfaceCharList- Specified by:
selectin interfaceImmutableCharCollection- Specified by:
selectin interfaceImmutableCharList- Specified by:
selectin interfaceOrderedCharIterable- Specified by:
selectin interfaceReversibleCharIterable
-
reject
Description copied from interface:CharIterableReturns a new CharIterable with all of the elements in the CharIterable that return false for the specified predicate.- Specified by:
rejectin interfaceCharIterable- Specified by:
rejectin interfaceCharList- Specified by:
rejectin interfaceImmutableCharCollection- Specified by:
rejectin interfaceImmutableCharList- Specified by:
rejectin interfaceOrderedCharIterable- Specified by:
rejectin interfaceReversibleCharIterable
-
collect
Description copied from interface:CharIterableReturns a new collection with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.- Specified by:
collectin interfaceCharIterable- Specified by:
collectin interfaceCharList- Specified by:
collectin interfaceImmutableCharCollection- Specified by:
collectin interfaceImmutableCharList- Specified by:
collectin interfaceOrderedCharIterable- Specified by:
collectin interfaceReversibleCharIterable
-
collectChar
-
detectIfNone
- Specified by:
detectIfNonein interfaceCharIterable
-
count
Description copied from interface:CharIterableReturns a count of the number of elements in the CharIterable that return true for the specified predicate.- Specified by:
countin interfaceCharIterable
-
anySatisfy
Description copied from interface:CharIterableReturns true if any of the elements in the CharIterable return true for the specified predicate, otherwise returns false.- Specified by:
anySatisfyin interfaceCharIterable
-
allSatisfy
Description copied from interface:CharIterableReturns true if all of the elements in the CharIterable return true for the specified predicate, otherwise returns false.- Specified by:
allSatisfyin interfaceCharIterable
-
noneSatisfy
Description copied from interface:CharIterableReturns true if none of the elements in the CharIterable return true for the specified predicate, otherwise returns false.- Specified by:
noneSatisfyin interfaceCharIterable
-
toList
Description copied from interface:CharIterableConverts the CharIterable to a new MutableCharList.- Specified by:
toListin interfaceCharIterable- Overrides:
toListin classAbstractCharIterable
-
toSet
Description copied from interface:CharIterableConverts the CharIterable to a new MutableCharSet.- Specified by:
toSetin interfaceCharIterable- Overrides:
toSetin classAbstractCharIterable
-
toBag
Description copied from interface:CharIterableConverts the CharIterable to a new MutableCharBag.- Specified by:
toBagin interfaceCharIterable- Overrides:
toBagin classAbstractCharIterable
-
injectInto
public <T> T injectInto(T injectedValue, ObjectCharToObjectFunction<? super T,? extends T> function)- Specified by:
injectIntoin interfaceCharIterable
-
chunk
Description copied from interface:CharIterablePartitions elements in fixed size chunks.- Specified by:
chunkin interfaceCharIterable- Parameters:
size- the number of elements per chunk- Returns:
- A
RichIterablecontainingCharIterables of sizesize, except the last will be truncated if the elements don't divide evenly.
-
sum
public long sum()- Specified by:
sumin interfaceCharIterable
-
max
public char max()- Specified by:
maxin interfaceCharIterable
-
min
public char min()- Specified by:
minin interfaceCharIterable
-
size
public int size()Description copied from interface:PrimitiveIterableReturns the number of items in this iterable.- Specified by:
sizein interfacePrimitiveIterable
-
appendString
Description copied from interface:PrimitiveIterablePrints a string representation of this collection onto the givenAppendable. Prints the string returned byPrimitiveIterable.makeString(String, String, String).- Specified by:
appendStringin interfacePrimitiveIterable
-
equals
Description copied from interface:CharListFollows the same general contract asList.equals(Object). -
hashCode
public int hashCode()Description copied from interface:CharListFollows the same general contract asList.hashCode(). -
zipChar
Description copied from interface:ImmutableCharListReturns anImmutableListformed from thisImmutableCharListand anotherCharListby combining corresponding elements in pairs. If one of the twoCharLists is longer than the other, its remaining elements are ignored.- Specified by:
zipCharin interfaceCharList- Specified by:
zipCharin interfaceImmutableCharList- Since:
- 9.1.
-
zip
Description copied from interface:ImmutableCharListReturns anImmutableListformed from thisImmutableCharListand aListIterableby combining corresponding elements in pairs. If one of the two Lists is longer than the other, its remaining elements are ignored.- Specified by:
zipin interfaceCharList- Specified by:
zipin interfaceImmutableCharList- Since:
- 9.1.
-