public final class CharSeq extends java.lang.Object implements java.lang.CharSequence, IndexedSeq<java.lang.Character>, java.io.Serializable, java.lang.Comparable<CharSeq>
Note:Because CharSeq represents a sequence of primitive characters (i.e. a String),
it breaks the Liskov Substitution Principle in the way, that the CharSeq cannot contain null
elements.
In future version of Java, CharSeq should extend IndexedSeq<char> instead.
Modifier and Type | Class and Description |
---|---|
static interface |
CharSeq.CharFunction<R> |
static interface |
CharSeq.CharUnaryOperator |
Modifier and Type | Method and Description |
---|---|
CharSeq |
append(java.lang.Character element)
Appends an element to this.
|
CharSeq |
appendAll(java.lang.Iterable<? extends java.lang.Character> elements)
Appends all given elements to this.
|
java.lang.Character |
apply(java.lang.Integer index)
A
Seq is a partial function which returns the element at the specified index if the
index is valid. |
java.util.List<java.lang.Character> |
asJava()
Creates an immutable
List view on top of this Seq ,
i.e. |
CharSeq |
asJava(java.util.function.Consumer<? super java.util.List<java.lang.Character>> action)
Creates an immutable
List view on top of this Seq
that is passed to the given action . |
java.util.List<java.lang.Character> |
asJavaMutable()
Creates a mutable
List view on top of this Seq ,
i.e. |
CharSeq |
asJavaMutable(java.util.function.Consumer<? super java.util.List<java.lang.Character>> action)
Creates a mutable
List view on top of this Seq
that is passed to the given action . |
CharSeq |
capitalize()
Converts the first character in this
CharSeq to upper
case using the rules of the default locale. |
CharSeq |
capitalize(java.util.Locale locale)
Converts the first character in this
CharSeq to upper
case using the rules of the given Locale . |
char |
charAt(int index)
Returns the
char value at the
specified index. |
int |
codePointAt(int index)
Returns the character (Unicode code point) at the specified
index.
|
int |
codePointBefore(int index)
Returns the character (Unicode code point) before the specified
index.
|
int |
codePointCount(int beginIndex,
int endIndex)
Returns the number of Unicode code points in the specified text
range of this
CharSeq . |
<R> IndexedSeq<R> |
collect(PartialFunction<? super java.lang.Character,? extends R> partialFunction)
Collects all elements that are in the domain of the given
partialFunction by mapping the elements to type R . |
static java.util.stream.Collector<java.lang.Character,java.util.ArrayList<java.lang.Character>,CharSeq> |
collector()
Returns a
Collector which may be used in conjunction with
Stream.collect(java.util.stream.Collector) to obtain a CharSeq . |
IndexedSeq<CharSeq> |
combinations()
Returns the union of all combinations from k = 0 to length().
|
IndexedSeq<CharSeq> |
combinations(int k)
Returns the k-combination of this traversable, i.e.
|
int |
compareTo(CharSeq anotherString)
Compares two strings lexicographically.
|
int |
compareToIgnoreCase(CharSeq str)
Compares two strings lexicographically, ignoring case
differences.
|
CharSeq |
concat(CharSeq str)
Concatenates the specified string to the end of this string.
|
boolean |
contains(java.lang.CharSequence s)
Returns true if and only if this string contains the specified
sequence of char values.
|
boolean |
contentEquals(java.lang.CharSequence cs)
Compares this string to the specified
CharSequence . |
boolean |
contentEquals(java.lang.StringBuffer sb)
Compares this string to the specified
StringBuffer . |
Iterator<CharSeq> |
crossProduct(int power)
Calculates the n-ary cartesian power (or cross product or simply product) of this.
|
java.lang.Byte |
decodeByte()
Decodes this
CharSeq into a Byte by calling Byte.decode(String) . |
java.lang.Integer |
decodeInteger()
Decodes this
CharSeq into an Integer by calling Integer.decode(String) . |
java.lang.Long |
decodeLong()
Decodes this
CharSeq into a Long by calling Long.decode(String) . |
java.lang.Short |
decodeShort()
Decodes this
CharSeq into a Short by calling Short.decode(String) . |
CharSeq |
distinct()
Returns a new version of this which contains no duplicates.
|
CharSeq |
distinctBy(java.util.Comparator<? super java.lang.Character> comparator)
Returns a new version of this which contains no duplicates.
|
<U> CharSeq |
distinctBy(java.util.function.Function<? super java.lang.Character,? extends U> keyExtractor)
Returns a new version of this which contains no duplicates.
|
CharSeq |
drop(int n)
Drops the first n elements of this or all elements, if this length < n.
|
CharSeq |
dropRight(int n)
Drops the last n elements of this or all elements, if this length < n.
|
CharSeq |
dropRightUntil(java.util.function.Predicate<? super java.lang.Character> predicate)
Drops elements until the predicate holds for the current element, starting from the end.
|
CharSeq |
dropRightWhile(java.util.function.Predicate<? super java.lang.Character> predicate)
Drops elements while the predicate holds for the current element, starting from the end.
|
CharSeq |
dropUntil(java.util.function.Predicate<? super java.lang.Character> predicate)
Drops elements until the predicate holds for the current element.
|
CharSeq |
dropWhile(java.util.function.Predicate<? super java.lang.Character> predicate)
Drops elements while the predicate holds for the current element.
|
static CharSeq |
empty() |
boolean |
endsWith(CharSeq suffix)
Tests if this string ends with the specified suffix.
|
boolean |
equals(java.lang.Object o)
In Vavr there are four basic classes of collections:
Seq (sequential elements)
Set (distinct elements)
Map (indexed elements)
Multimap (indexed collections)
Two collection instances of these classes are equal if and only if both collections
belong to the same basic collection class (Seq, Set, Map or Multimap)
contain the same elements
have the same element order, if the collections are of type Seq
Two Map/Multimap elements, resp.
|
boolean |
equalsIgnoreCase(CharSeq anotherString)
Compares this
CharSeq to another CharSeq , ignoring case
considerations. |
static CharSeq |
fill(int n,
java.util.function.Supplier<? extends java.lang.Character> s)
Returns a CharSeq containing
n values supplied by a given Supplier s . |
CharSeq |
filter(java.util.function.Predicate<? super java.lang.Character> predicate)
Returns a new traversable consisting of all elements which satisfy the given predicate.
|
CharSeq |
filterNot(java.util.function.Predicate<? super java.lang.Character> predicate)
Returns a new traversable consisting of all elements which do not satisfy the given predicate.
|
<U> IndexedSeq<U> |
flatMap(java.util.function.Function<? super java.lang.Character,? extends java.lang.Iterable<? extends U>> mapper)
FlatMaps this Traversable.
|
CharSeq |
flatMapChars(CharSeq.CharFunction<? extends java.lang.CharSequence> mapper) |
byte[] |
getBytes()
Encodes this
CharSeq into a sequence of bytes using the
platform's default charset, storing the result into a new byte array. |
byte[] |
getBytes(java.nio.charset.Charset charset)
Encodes this
CharSeq into a sequence of bytes using the given
charset, storing the result into a
new byte array. |
byte[] |
getBytes(java.lang.String charsetName)
Encodes this
CharSeq into a sequence of bytes using the named
charset, storing the result into a new byte array. |
void |
getChars(int srcBegin,
int srcEnd,
char[] dst,
int dstBegin)
Copies characters from this string into the destination character
array.
|
<C> Map<C,CharSeq> |
groupBy(java.util.function.Function<? super java.lang.Character,? extends C> classifier)
Groups this elements by classifying the elements.
|
Iterator<CharSeq> |
grouped(int size)
Groups this
Traversable into fixed size blocks. |
boolean |
hasDefiniteSize()
Checks if this Traversable is known to have a finite size.
|
int |
hashCode()
Returns the hash code of this collection.
|
java.lang.Character |
head()
Returns the first element of a non-empty Traversable.
|
int |
indexOf(java.lang.Character element,
int from)
Returns the index of the first occurrence of the given element after or at some start index
or -1 if this does not contain the given element.
|
int |
indexOf(CharSeq str)
Returns the index within this string of the first occurrence of the
specified substring.
|
int |
indexOf(CharSeq str,
int fromIndex)
Returns the index within this string of the first occurrence of the
specified substring, starting at the specified index.
|
int |
indexOf(int ch)
Returns the index within this string of the first occurrence of
the specified character.
|
int |
indexOf(int ch,
int fromIndex)
Returns the index within this string of the first occurrence of the
specified character, starting the search at the specified index.
|
Option<java.lang.Integer> |
indexOfOption(CharSeq str)
Returns the index of the first occurrence of the given element as an
Option . |
Option<java.lang.Integer> |
indexOfOption(CharSeq str,
int fromIndex)
Returns the index of the first occurrence of the given element as an
Option ,
starting the search at the specified index. |
CharSeq |
init()
Dual of Traversable.tail(), returning all elements except the last.
|
Option<CharSeq> |
initOption()
Dual of Traversable.tailOption(), returning all elements except the last as
Option . |
CharSeq |
insert(int index,
java.lang.Character element)
Inserts the given element at the specified index.
|
CharSeq |
insertAll(int index,
java.lang.Iterable<? extends java.lang.Character> elements)
Inserts the given elements at the specified index.
|
CharSeq |
intersperse(java.lang.Character element)
Inserts an element between all elements of this Traversable.
|
boolean |
isAsync()
A
CharSeq is computed synchronously. |
boolean |
isEmpty()
Checks if this Traversable is empty.
|
boolean |
isLazy()
A
CharSeq is computed eagerly. |
boolean |
isTraversableAgain()
Checks if this Traversable can be repeatedly traversed.
|
Iterator<java.lang.Character> |
iterator()
An iterator by means of head() and tail().
|
int |
lastIndexOf(java.lang.Character element,
int end)
Returns the index of the last occurrence of the given element before or at a given end index
or -1 if this does not contain the given element.
|
int |
lastIndexOf(CharSeq str)
Returns the index within this string of the last occurrence of the
specified substring.
|
int |
lastIndexOf(CharSeq str,
int fromIndex)
Returns the index within this string of the last occurrence of the
specified substring, searching backward starting at the specified index.
|
int |
lastIndexOf(int ch)
Returns the index within this string of the last occurrence of
the specified character.
|
int |
lastIndexOf(int ch,
int fromIndex)
Returns the index within this string of the last occurrence of
the specified character, searching backward starting at the
specified index.
|
Option<java.lang.Integer> |
lastIndexOfOption(CharSeq str)
Returns the index of the last occurrence of the given element as an
Option . |
Option<java.lang.Integer> |
lastIndexOfOption(CharSeq str,
int fromIndex)
Returns the index of the last occurrence of the given element as an
Option ,
starting the search at the specified index. |
Option<java.lang.Integer> |
lastIndexOfOption(int ch,
int fromIndex)
Returns the index of the last occurrence of the given element as an
Option ,
starting the search at the specified index. |
CharSeq |
leftPadTo(int length,
java.lang.Character element)
A copy of this sequence with an element prepended until a given target length is reached.
|
int |
length()
Returns the length of this string.
|
<U> IndexedSeq<U> |
map(java.util.function.Function<? super java.lang.Character,? extends U> mapper)
Maps the elements of this
Traversable to elements of a new type preserving their order, if any. |
CharSeq |
mapChars(CharSeq.CharUnaryOperator mapper) |
boolean |
matches(java.lang.String regex)
Tells whether or not this string matches the given regular expression.
|
java.lang.String |
mkString()
Joins the elements of this by concatenating their string representations.
|
static CharSeq |
of(char... characters)
Creates a String of the given characters.
|
static CharSeq |
of(char character)
Returns a singleton
CharSeq , i.e. |
static CharSeq |
of(java.lang.CharSequence sequence)
Creates a String of
CharSequence . |
static CharSeq |
ofAll(java.lang.Iterable<? extends java.lang.Character> elements)
Creates a String of the given elements.
|
int |
offsetByCodePoints(int index,
int codePointOffset)
Returns the index within this
CharSeq that is
offset from the given index by
codePointOffset code points. |
CharSeq |
orElse(java.lang.Iterable<? extends java.lang.Character> other)
Returns this
Traversable if it is nonempty, otherwise return the alternative. |
CharSeq |
orElse(java.util.function.Supplier<? extends java.lang.Iterable<? extends java.lang.Character>> supplier)
Returns this
Traversable if it is nonempty, otherwise return the result of evaluating supplier. |
CharSeq |
padTo(int length,
java.lang.Character element)
A copy of this sequence with an element appended until a given target length is reached.
|
boolean |
parseBoolean()
Parses this
CharSeq as a boolean by calling Boolean.parseBoolean(String) . |
byte |
parseByte()
Parses this
CharSeq as a signed decimal byte by calling Byte.parseByte(String) . |
byte |
parseByte(int radix)
Parses this
CharSeq as a signed byte in the specified radix
by calling Byte.parseByte(String, int) . |
double |
parseDouble()
Parses this
CharSeq as a double by calling Double.parseDouble(String) . |
float |
parseFloat()
Parses this
CharSeq as a float by calling Float.parseFloat(String) . |
int |
parseInt()
Parses this
CharSeq as a signed decimal int by calling Integer.parseInt(String) . |
int |
parseInt(int radix)
Parses this
CharSeq as a signed int in the specified radix
by calling Integer.parseInt(String, int) . |
long |
parseLong()
Parses this
CharSeq as a signed decimal long by calling Long.parseLong(String) . |
long |
parseLong(int radix)
Parses this
CharSeq as a signed long in the specified radix
by calling Long.parseLong(String, int) . |
short |
parseShort()
Parses this
CharSeq as a signed decimal short by calling Short.parseShort(String) . |
short |
parseShort(int radix)
Parses this
CharSeq as a signed short in the specified radix
by calling Short.parseShort(String, int) . |
int |
parseUnsignedInt()
Parses this
CharSeq as a unsigned decimal int by calling Integer.parseUnsignedInt(String) . |
int |
parseUnsignedInt(int radix)
Parses this
CharSeq as a unsigned int in the specified radix
by calling Integer.parseUnsignedInt(String, int) . |
long |
parseUnsignedLong()
Parses this
CharSeq as a unsigned decimal long by calling Long.parseUnsignedLong(String) . |
long |
parseUnsignedLong(int radix)
Parses this
CharSeq as a unsigned long in the specified radix
by calling Long.parseUnsignedLong(String, int) . |
Tuple2<CharSeq,CharSeq> |
partition(java.util.function.Predicate<? super java.lang.Character> predicate)
Creates a partition of this
Traversable by splitting this elements in two in distinct traversables
according to a predicate. |
CharSeq |
patch(int from,
java.lang.Iterable<? extends java.lang.Character> that,
int replaced)
Produces a new list where a slice of elements in this list is replaced by another sequence.
|
CharSeq |
peek(java.util.function.Consumer<? super java.lang.Character> action)
Performs the given
action on the first element if this is an eager implementation. |
IndexedSeq<CharSeq> |
permutations()
Computes all unique permutations.
|
CharSeq |
prepend(java.lang.Character element)
Prepends an element to this.
|
CharSeq |
prependAll(java.lang.Iterable<? extends java.lang.Character> elements)
Prepends all given elements to this.
|
static CharSeq |
range(char from,
char toExclusive)
Creates a CharSeq starting from character
from , extending to character toExclusive - 1 . |
static CharSeq |
rangeBy(char from,
char toExclusive,
int step) |
static CharSeq |
rangeClosed(char from,
char toInclusive)
Creates a CharSeq starting from character
from , extending to character toInclusive . |
static CharSeq |
rangeClosedBy(char from,
char toInclusive,
int step)
Creates a CharSeq starting from character
from , extending to character toInclusive ,
with step . |
boolean |
regionMatches(boolean ignoreCase,
int toffset,
CharSeq other,
int ooffset,
int len)
Tests if two string regions are equal.
|
boolean |
regionMatches(int toffset,
CharSeq other,
int ooffset,
int len)
Tests if two string regions are equal.
|
CharSeq |
remove(java.lang.Character element)
Removes the first occurrence of the given element.
|
CharSeq |
removeAll(java.lang.Character element)
Removes all occurrences of the given element.
|
CharSeq |
removeAll(java.lang.Iterable<? extends java.lang.Character> elements)
Removes all occurrences of the given elements.
|
CharSeq |
removeAt(int index)
Removes the element at the specified position in this sequence.
|
CharSeq |
removeFirst(java.util.function.Predicate<java.lang.Character> predicate)
Removes the first occurrence that satisfy predicate
|
CharSeq |
removeLast(java.util.function.Predicate<java.lang.Character> predicate)
Removes the last occurrence that satisfy predicate
|
static CharSeq |
repeat(char character,
int times)
Repeats a character
times times. |
CharSeq |
repeat(int times)
Repeats this CharSeq
times times. |
CharSeq |
replace(java.lang.Character currentElement,
java.lang.Character newElement)
Replaces the first occurrence (if exists) of the given currentElement with newElement.
|
CharSeq |
replace(java.lang.CharSequence target,
java.lang.CharSequence replacement)
Replaces each substring of this string that matches the literal target
sequence with the specified literal replacement sequence.
|
CharSeq |
replaceAll(java.lang.Character currentElement,
java.lang.Character newElement)
Replaces all occurrences of the given currentElement with newElement.
|
CharSeq |
replaceAll(java.lang.String regex,
java.lang.String replacement)
Replaces each substring of this string that matches the given regular expression with the
given replacement.
|
CharSeq |
replaceFirst(java.lang.String regex,
java.lang.String replacement)
Replaces the first substring of this string that matches the given regular expression with the
given replacement.
|
CharSeq |
retainAll(java.lang.Iterable<? extends java.lang.Character> elements)
Keeps all occurrences of the given elements from this.
|
CharSeq |
reverse()
Reverses the order of elements.
|
CharSeq |
rotateLeft(int n)
Circular rotates the elements by the specified distance to the left direction.
|
CharSeq |
rotateRight(int n)
Circular rotates the elements by the specified distance to the right direction.
|
CharSeq |
scan(java.lang.Character zero,
java.util.function.BiFunction<? super java.lang.Character,? super java.lang.Character,? extends java.lang.Character> operation)
Computes a prefix scan of the elements of the collection.
|
<U> IndexedSeq<U> |
scanLeft(U zero,
java.util.function.BiFunction<? super U,? super java.lang.Character,? extends U> operation)
Produces a collection containing cumulative results of applying the
operator going left to right.
|
<U> IndexedSeq<U> |
scanRight(U zero,
java.util.function.BiFunction<? super java.lang.Character,? super U,? extends U> operation)
Produces a collection containing cumulative results of applying the
operator going right to left.
|
CharSeq |
shuffle()
Randomize the order of the elements in the current sequence.
|
CharSeq |
shuffle(java.util.Random random)
Randomize the order of the elements in the current sequence using the given source
of randomness.
|
CharSeq |
slice(int beginIndex,
int endIndex)
Returns a Seq that is a slice of this.
|
Iterator<CharSeq> |
slideBy(java.util.function.Function<? super java.lang.Character,?> classifier)
Slides a non-overlapping window of a variable size over this
Traversable . |
Iterator<CharSeq> |
sliding(int size)
Slides a window of a specific
size and step size 1 over this Traversable by calling
Traversable.sliding(int, int) . |
Iterator<CharSeq> |
sliding(int size,
int step)
Slides a window of a specific
size and step size over this Traversable . |
<U> CharSeq |
sortBy(java.util.Comparator<? super U> comparator,
java.util.function.Function<? super java.lang.Character,? extends U> mapper)
Sorts this elements by comparing the elements in a different domain, using the given
mapper . |
<U extends java.lang.Comparable<? super U>> |
sortBy(java.util.function.Function<? super java.lang.Character,? extends U> mapper)
Sorts this elements by comparing the elements in a different domain, using the given
mapper . |
CharSeq |
sorted()
Sorts this elements according to their natural order.
|
CharSeq |
sorted(java.util.Comparator<? super java.lang.Character> comparator)
Sorts this elements according to the provided
Comparator . |
Tuple2<CharSeq,CharSeq> |
span(java.util.function.Predicate<? super java.lang.Character> predicate)
Returns a tuple where the first element is the longest prefix of elements that satisfy the given
predicate and the second element is the remainder. |
Seq<CharSeq> |
split(java.lang.String regex)
Splits this string around matches of the given
regular expression.
|
Seq<CharSeq> |
split(java.lang.String regex,
int limit)
Splits this string around matches of the given
regular expression.
|
Tuple2<CharSeq,CharSeq> |
splitAt(int n)
Splits a Seq at the specified index.
|
Tuple2<CharSeq,CharSeq> |
splitAt(java.util.function.Predicate<? super java.lang.Character> predicate)
Splits a sequence at the first element which satisfies the
Predicate , e.g. |
Tuple2<CharSeq,CharSeq> |
splitAtInclusive(java.util.function.Predicate<? super java.lang.Character> predicate)
Splits a sequence at the first element which satisfies the
Predicate , e.g. |
boolean |
startsWith(CharSeq prefix)
Tests if this string starts with the specified prefix.
|
boolean |
startsWith(CharSeq prefix,
int toffset)
Tests if the substring of this string beginning at the
specified index starts with the specified prefix.
|
boolean |
startsWith(java.lang.Iterable<? extends java.lang.Character> that,
int offset)
Tests whether this list contains the given sequence at a given index.
|
java.lang.String |
stringPrefix()
Returns the name of this Value type, which is used by toString().
|
CharSeq |
subSequence(int beginIndex)
Returns a Seq that is a subsequence of this.
|
CharSeq |
subSequence(int beginIndex,
int endIndex)
Returns a Seq that is a subsequence of this.
|
CharSeq |
substring(int beginIndex)
Returns a string that is a substring of this string.
|
CharSeq |
substring(int beginIndex,
int endIndex)
Returns a string that is a substring of this string.
|
static CharSeq |
tabulate(int n,
java.util.function.Function<? super java.lang.Integer,? extends java.lang.Character> f)
Returns a CharSeq containing
n values of a given Function f
over a range of integer values from 0 to n - 1 . |
CharSeq |
tail()
Drops the first element of a non-empty Traversable.
|
Option<CharSeq> |
tailOption()
Drops the first element of a non-empty Traversable and returns an
Option . |
CharSeq |
take(int n)
Takes the first n elements of this or all elements, if this length < n.
|
CharSeq |
takeRight(int n)
Takes the last n elements of this or all elements, if this length < n.
|
CharSeq |
takeRightUntil(java.util.function.Predicate<? super java.lang.Character> predicate)
Takes elements until the predicate holds for the current element, starting from the end.
|
CharSeq |
takeRightWhile(java.util.function.Predicate<? super java.lang.Character> predicate)
Takes elements while the predicate holds for the current element, starting from the end.
|
CharSeq |
takeUntil(java.util.function.Predicate<? super java.lang.Character> predicate)
Takes elements until the predicate holds for the current element.
|
CharSeq |
takeWhile(java.util.function.Predicate<? super java.lang.Character> predicate)
Takes elements while the predicate holds for the current element.
|
java.lang.Boolean |
toBoolean()
Converts this
CharSeq to a Boolean by calling Boolean.valueOf(String) . |
java.lang.Byte |
toByte()
Converts this
CharSeq to a Byte by calling Byte.valueOf(String) . |
java.lang.Byte |
toByte(int radix)
Converts this
CharSeq to a Byte in the specified radix
by calling Byte.valueOf(String, int) . |
char[] |
toCharArray()
Converts this string to a new character array.
|
java.lang.Double |
toDouble()
Converts this
CharSeq to a Double by calling Double.valueOf(String) . |
java.lang.Float |
toFloat()
Converts this
CharSeq to a Float by calling Float.valueOf(String) . |
java.lang.Integer |
toInteger()
Converts this
CharSeq to an Integer by calling Integer.valueOf(String) . |
java.lang.Integer |
toInteger(int radix)
Converts this
CharSeq to an Integer in the specified radix
by calling Integer.valueOf(String, int) . |
java.lang.Character[] |
toJavaArray()
Converts this to a Java array with component type
Object |
java.lang.Long |
toLong()
Converts this
CharSeq to a Long by calling Long.valueOf(String) . |
java.lang.Long |
toLong(int radix)
Converts this
CharSeq to a Long in the specified radix
by calling Long.valueOf(String, int) . |
CharSeq |
toLowerCase()
Converts all of the characters in this
CharSeq to lower
case using the rules of the default locale. |
CharSeq |
toLowerCase(java.util.Locale locale)
Converts all of the characters in this
CharSeq to lower
case using the rules of the given Locale . |
java.lang.Short |
toShort()
Converts this
CharSeq to a Short by calling Short.valueOf(String) . |
java.lang.Short |
toShort(int radix)
Converts this
CharSeq to a Short in the specified radix
by calling Short.valueOf(String, int) . |
java.lang.String |
toString()
Returns a string containing the characters in this sequence in the same
order as this sequence.
|
CharSeq |
toUpperCase()
Converts all of the characters in this
CharSeq to upper
case using the rules of the default locale. |
CharSeq |
toUpperCase(java.util.Locale locale)
Converts all of the characters in this
CharSeq to upper
case using the rules of the given Locale . |
<U> U |
transform(java.util.function.Function<? super CharSeq,? extends U> f)
Transforms this
CharSeq . |
CharSeq |
trim()
Returns a string whose value is this string, with any leading and trailing
whitespace removed.
|
static CharSeq |
unfold(java.lang.Character seed,
java.util.function.Function<? super java.lang.Character,Option<Tuple2<? extends java.lang.Character,? extends java.lang.Character>>> f)
Creates a CharSeq from a seed value and a function.
|
static <T> CharSeq |
unfoldLeft(T seed,
java.util.function.Function<? super T,Option<Tuple2<? extends T,? extends java.lang.Character>>> f)
Creates a CharSeq from a seed value and a function.
|
static <T> CharSeq |
unfoldRight(T seed,
java.util.function.Function<? super T,Option<Tuple2<? extends java.lang.Character,? extends T>>> f)
Creates a CharSeq from a seed value and a function.
|
CharSeq |
update(int index,
java.lang.Character element)
Updates the given element at the specified index.
|
CharSeq |
update(int index,
java.util.function.Function<? super java.lang.Character,? extends java.lang.Character> updater)
Updates the given element at the specified index using the specified function.
|
<U> IndexedSeq<Tuple2<java.lang.Character,U>> |
zip(java.lang.Iterable<? extends U> that)
Returns a traversable formed from this traversable and another Iterable collection by combining
corresponding elements in pairs.
|
<U> IndexedSeq<Tuple2<java.lang.Character,U>> |
zipAll(java.lang.Iterable<? extends U> that,
java.lang.Character thisElem,
U thatElem)
Returns a traversable formed from this traversable and another Iterable by combining corresponding elements in
pairs.
|
<U,R> IndexedSeq<R> |
zipWith(java.lang.Iterable<? extends U> that,
java.util.function.BiFunction<? super java.lang.Character,? super U,? extends R> mapper)
Returns a traversable formed from this traversable and another Iterable collection by mapping elements.
|
IndexedSeq<Tuple2<java.lang.Character,java.lang.Integer>> |
zipWithIndex()
Zips this traversable with its indices.
|
<U> IndexedSeq<U> |
zipWithIndex(java.util.function.BiFunction<? super java.lang.Character,? super java.lang.Integer,? extends U> mapper)
Returns a traversable formed from this traversable and another Iterable collection by mapping elements.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
asPartialFunction, endsWith, indexOfSlice, indexWhere, isDefinedAt, last, lastIndexOfSlice, lastIndexWhere, narrow, reverseIterator, search, search, segmentLength
containsSlice, crossProduct, crossProduct, foldRight, get, getOption, getOrElse, indexOf, indexOfOption, indexOfOption, indexOfSlice, indexOfSliceOption, indexOfSliceOption, indexWhere, indexWhereOption, indexWhereOption, isSequential, iterator, lastIndexOf, lastIndexOfOption, lastIndexOfOption, lastIndexOfSlice, lastIndexOfSliceOption, lastIndexOfSliceOption, lastIndexWhere, lastIndexWhereOption, lastIndexWhereOption, lift, narrow, prefixLength, startsWith
arrangeBy, average, containsAll, count, existsUnique, find, findLast, fold, foldLeft, forEachWithIndex, get, headOption, isDistinct, isOrdered, isSingleValued, lastOption, max, maxBy, maxBy, min, minBy, minBy, mkCharSeq, mkCharSeq, mkCharSeq, mkString, mkString, narrow, nonEmpty, product, reduce, reduceLeft, reduceLeftOption, reduceOption, reduceRight, reduceRightOption, single, singleOption, size, spliterator, sum, toLinkedMap, toMap, toSortedMap, toSortedMap, unzip, unzip3
collect, collect, contains, corresponds, eq, exists, forAll, forEach, getOrElse, getOrElse, getOrElseThrow, getOrElseTry, getOrNull, narrow, out, out, stderr, stdout, toArray, toCharSeq, toCompletableFuture, toEither, toEither, toInvalid, toInvalid, toJavaArray, toJavaArray, toJavaCollection, toJavaList, toJavaList, toJavaMap, toJavaMap, toJavaMap, toJavaOptional, toJavaParallelStream, toJavaSet, toJavaSet, toJavaStream, toLeft, toLeft, toLinkedMap, toLinkedMap, toLinkedSet, toList, toMap, toMap, toOption, toPriorityQueue, toPriorityQueue, toQueue, toRight, toRight, toSet, toSortedMap, toSortedMap, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toStream, toTree, toTree, toTry, toTry, toValid, toValid, toValidation, toValidation, toVector
public static CharSeq empty()
public static java.util.stream.Collector<java.lang.Character,java.util.ArrayList<java.lang.Character>,CharSeq> collector()
Collector
which may be used in conjunction with
Stream.collect(java.util.stream.Collector)
to obtain a CharSeq
.Collector
which collects all the input elements into a
CharSeq
, in encounter orderpublic static CharSeq of(java.lang.CharSequence sequence)
CharSequence
.sequence
- CharSequence
instance.CharSeq
public static CharSeq of(char character)
CharSeq
, i.e. a CharSeq
of one character.character
- A character.CharSeq
instance containing the given elementpublic static CharSeq of(char... characters)
characters
- Zero or more characters.java.lang.NullPointerException
- if elements
is nullpublic static CharSeq ofAll(java.lang.Iterable<? extends java.lang.Character> elements)
The resulting string has the same iteration order as the given iterable of elements if the iteration order of the elements is stable.
elements
- An Iterable of elements.java.lang.NullPointerException
- if elements
is null or elements
contains nullpublic static CharSeq tabulate(int n, java.util.function.Function<? super java.lang.Integer,? extends java.lang.Character> f)
n
values of a given Function f
over a range of integer values from 0 to n - 1
.n
- The number of elements in the CharSeqf
- The Function computing element valuesf(0),f(1), ..., f(n - 1)
java.lang.NullPointerException
- if f
is nullpublic static CharSeq fill(int n, java.util.function.Supplier<? extends java.lang.Character> s)
n
values supplied by a given Supplier s
.n
- The number of elements in the CharSeqs
- The Supplier computing element valuesn
, where each element contains the result supplied by s
.java.lang.NullPointerException
- if s
is nullpublic static CharSeq range(char from, char toExclusive)
from
, extending to character toExclusive - 1
.
Examples:
CharSeq.range('a', 'c') // = "ab"
CharSeq.range('c', 'a') // = ""
from
- the first charactertoExclusive
- the successor of the last characterfrom >= toExclusive
public static CharSeq rangeBy(char from, char toExclusive, int step)
public static CharSeq rangeClosed(char from, char toInclusive)
from
, extending to character toInclusive
.
Examples:
CharSeq.rangeClosed('a', 'c') // = "abc"
CharSeq.rangeClosed('c', 'a') // = ""
from
- the first charactertoInclusive
- the last characterfrom > toInclusive
public static CharSeq rangeClosedBy(char from, char toInclusive, int step)
from
, extending to character toInclusive
,
with step
.
Examples:
CharSeq.rangeClosedBy('a', 'c', 1) // = ('a', 'b', 'c')
CharSeq.rangeClosedBy('a', 'd', 2) // = ('a', 'c')
CharSeq.rangeClosedBy('d', 'a', -2) // = ('d', 'b')
CharSeq.rangeClosedBy('d', 'a', 2) // = ()
from
- the first charactertoInclusive
- the last characterstep
- the stepstep * (from - toInclusive) > 0
.java.lang.IllegalArgumentException
- if step
is zeropublic static <T> CharSeq unfoldRight(T seed, java.util.function.Function<? super T,Option<Tuple2<? extends java.lang.Character,? extends T>>> f)
None
when it's
done generating the CharSeq, otherwise Some
Tuple
of the element for the next call and the value to add to the
resulting CharSeq.
Example:
CharSeq.unfoldRight('j', x -> x == 'a'
? Option.none()
: Option.of(new Tuple2<>(new Character(x), (char)(x-1))));
// CharSeq.of("jihgfedcb"))
T
- type of seedsseed
- the start value for the iterationf
- the function to get the next step of the iterationjava.lang.NullPointerException
- if f
is nullpublic static <T> CharSeq unfoldLeft(T seed, java.util.function.Function<? super T,Option<Tuple2<? extends T,? extends java.lang.Character>>> f)
None
when it's
done generating the CharSeq, otherwise Some
Tuple
of the value to add to the resulting CharSeq and
the element for the next call.
Example:
CharSeq.unfoldLeft('j', x -> x == 'a'
? Option.none()
: Option.of(new Tuple2<>((char)(x-1), new Character(x))));
// CharSeq.of("bcdefghij"))
T
- type of seedsseed
- the start value for the iterationf
- the function to get the next step of the iterationjava.lang.NullPointerException
- if f
is nullpublic static CharSeq unfold(java.lang.Character seed, java.util.function.Function<? super java.lang.Character,Option<Tuple2<? extends java.lang.Character,? extends java.lang.Character>>> f)
None
when it's
done generating the CharSeq, otherwise Some
Tuple
of the value to add to the resulting CharSeq and
the element for the next call.
Example:
CharSeq.unfold('j', x -> x == 'a'
? Option.none()
: Option.of(new Tuple2<>((char)(x-1), new Character(x))));
// CharSeq.of("bcdefghij"))
seed
- the start value for the iterationf
- the function to get the next step of the iterationjava.lang.NullPointerException
- if f
is nullpublic static CharSeq repeat(char character, int times)
times
times.character
- A charactertimes
- Repetition countcharacter * times
public CharSeq repeat(int times)
times
times.
Example: CharSeq.of("ja").repeat(13) = "jajajajajajajajajajajajaja"
times
- Repetition countthis * times
public CharSeq append(java.lang.Character element)
Seq
append
in interface IndexedSeq<java.lang.Character>
append
in interface Seq<java.lang.Character>
element
- An elementpublic CharSeq appendAll(java.lang.Iterable<? extends java.lang.Character> elements)
Seq
appendAll
in interface IndexedSeq<java.lang.Character>
appendAll
in interface Seq<java.lang.Character>
elements
- An Iterable of elementspublic java.util.List<java.lang.Character> asJava()
Seq
List
view on top of this Seq
,
i.e. calling mutators will result in UnsupportedOperationException
at runtime.
The difference to conversion methods toJava*()
is that
java.util.List
view throws UnsupportedOperationException
before
checking method arguments. Java does handle this case inconsistently.public CharSeq asJava(java.util.function.Consumer<? super java.util.List<java.lang.Character>> action)
Seq
List
view on top of this Seq
that is passed to the given action
.asJava
in interface IndexedSeq<java.lang.Character>
asJava
in interface Seq<java.lang.Character>
action
- A side-effecting unit of work that operates on an immutable java.util.List
view.Seq.asJava()
public java.util.List<java.lang.Character> asJavaMutable()
Seq
List
view on top of this Seq
,
i.e. all mutator methods of the List
are implemented.asJavaMutable
in interface Seq<java.lang.Character>
Collection
view on this Traversable
.Seq.asJava()
public CharSeq asJavaMutable(java.util.function.Consumer<? super java.util.List<java.lang.Character>> action)
Seq
List
view on top of this Seq
that is passed to the given action
.asJavaMutable
in interface IndexedSeq<java.lang.Character>
asJavaMutable
in interface Seq<java.lang.Character>
action
- A side-effecting unit of work that operates on a mutable java.util.List
view.java.util.List
view or a new instance of this type, if write operations are performed on the java.util.List
view.Seq.asJavaMutable()
public <R> IndexedSeq<R> collect(PartialFunction<? super java.lang.Character,? extends R> partialFunction)
Traversable
partialFunction
by mapping the elements to type R
.
More specifically, for each of this elements in iteration order first it is checked
partialFunction.isDefinedAt(element)
If the elements makes it through that filter, the mapped instance is added to the result collection
R newElement = partialFunction.apply(element)
Note:If this Traversable
is ordered (i.e. extends Ordered
,
the caller of collect
has to ensure that the elements are comparable (i.e. extend Comparable
).collect
in interface IndexedSeq<java.lang.Character>
collect
in interface Seq<java.lang.Character>
collect
in interface Traversable<java.lang.Character>
R
- The new element typepartialFunction
- A function that is not necessarily defined of all elements of this traversable.Traversable
instance containing elements of type R
public IndexedSeq<CharSeq> combinations()
Seq
Examples:
[].combinations() = [[]]
[1,2,3].combinations() = [
[], // k = 0
[1], [2], [3], // k = 1
[1,2], [1,3], [2,3], // k = 2
[1,2,3] // k = 3
]
combinations
in interface IndexedSeq<java.lang.Character>
combinations
in interface Seq<java.lang.Character>
public IndexedSeq<CharSeq> combinations(int k)
Seq
combinations
in interface IndexedSeq<java.lang.Character>
combinations
in interface Seq<java.lang.Character>
k
- Size of subsetspublic Iterator<CharSeq> crossProduct(int power)
Seq
Example:
// = ((A,A), (A,B), (A,C), ..., (B,A), (B,B), ..., (Z,Y), (Z,Z))
CharSeq.rangeClosed('A', 'Z').crossProduct(2);
Cartesian power of negative value will return empty iterator.
Example:
// = ()
CharSeq.rangeClosed('A', 'Z').crossProduct(-1);
crossProduct
in interface IndexedSeq<java.lang.Character>
crossProduct
in interface Seq<java.lang.Character>
power
- the number of cartesian multiplicationspublic CharSeq distinct()
Traversable
equals
.distinct
in interface IndexedSeq<java.lang.Character>
distinct
in interface Seq<java.lang.Character>
distinct
in interface Traversable<java.lang.Character>
Traversable
containing this elements without duplicatespublic CharSeq distinctBy(java.util.Comparator<? super java.lang.Character> comparator)
Traversable
comparator
.distinctBy
in interface IndexedSeq<java.lang.Character>
distinctBy
in interface Seq<java.lang.Character>
distinctBy
in interface Traversable<java.lang.Character>
comparator
- A comparatorTraversable
containing this elements without duplicatespublic <U> CharSeq distinctBy(java.util.function.Function<? super java.lang.Character,? extends U> keyExtractor)
Traversable
equals
.
The elements of the result are determined in the order of their occurrence - first match wins.
distinctBy
in interface IndexedSeq<java.lang.Character>
distinctBy
in interface Seq<java.lang.Character>
distinctBy
in interface Traversable<java.lang.Character>
U
- key typekeyExtractor
- A key extractorTraversable
containing this elements without duplicatespublic CharSeq drop(int n)
Traversable
drop
in interface IndexedSeq<java.lang.Character>
drop
in interface Seq<java.lang.Character>
drop
in interface Traversable<java.lang.Character>
n
- The number of elements to drop.public CharSeq dropUntil(java.util.function.Predicate<? super java.lang.Character> predicate)
Traversable
dropUntil
in interface IndexedSeq<java.lang.Character>
dropUntil
in interface Seq<java.lang.Character>
dropUntil
in interface Traversable<java.lang.Character>
predicate
- A condition tested subsequently for this elements.public CharSeq dropWhile(java.util.function.Predicate<? super java.lang.Character> predicate)
Traversable
Note: This is essentially the same as dropUntil(predicate.negate())
.
It is intended to be used with method references, which cannot be negated directly.
dropWhile
in interface IndexedSeq<java.lang.Character>
dropWhile
in interface Seq<java.lang.Character>
dropWhile
in interface Traversable<java.lang.Character>
predicate
- A condition tested subsequently for this elements.public CharSeq dropRight(int n)
Traversable
dropRight
in interface IndexedSeq<java.lang.Character>
dropRight
in interface Seq<java.lang.Character>
dropRight
in interface Traversable<java.lang.Character>
n
- The number of elements to drop.public CharSeq dropRightWhile(java.util.function.Predicate<? super java.lang.Character> predicate)
Seq
Note: This is essentially the same as dropRightUntil(predicate.negate())
.
It is intended to be used with method references, which cannot be negated directly.
dropRightWhile
in interface IndexedSeq<java.lang.Character>
dropRightWhile
in interface Seq<java.lang.Character>
predicate
- A condition tested subsequently for this elements, starting from the end.public CharSeq dropRightUntil(java.util.function.Predicate<? super java.lang.Character> predicate)
Seq
dropRightUntil
in interface IndexedSeq<java.lang.Character>
dropRightUntil
in interface Seq<java.lang.Character>
predicate
- A condition tested subsequently for this elements, starting from the end.public CharSeq filter(java.util.function.Predicate<? super java.lang.Character> predicate)
Traversable
filter
in interface IndexedSeq<java.lang.Character>
filter
in interface Seq<java.lang.Character>
filter
in interface Traversable<java.lang.Character>
predicate
- A predicatepublic CharSeq filterNot(java.util.function.Predicate<? super java.lang.Character> predicate)
Traversable
The default implementation is equivalent to
filter(predicate.negate()
filterNot
in interface IndexedSeq<java.lang.Character>
filterNot
in interface Seq<java.lang.Character>
filterNot
in interface Traversable<java.lang.Character>
predicate
- A predicatepublic <U> IndexedSeq<U> flatMap(java.util.function.Function<? super java.lang.Character,? extends java.lang.Iterable<? extends U>> mapper)
Traversable
flatMap
in interface IndexedSeq<java.lang.Character>
flatMap
in interface Seq<java.lang.Character>
flatMap
in interface Traversable<java.lang.Character>
U
- The resulting component type.mapper
- A mapperpublic CharSeq flatMapChars(CharSeq.CharFunction<? extends java.lang.CharSequence> mapper)
public <C> Map<C,CharSeq> groupBy(java.util.function.Function<? super java.lang.Character,? extends C> classifier)
Traversable
groupBy
in interface IndexedSeq<java.lang.Character>
groupBy
in interface Seq<java.lang.Character>
groupBy
in interface Traversable<java.lang.Character>
C
- classified class typeclassifier
- A function which classifies elements into classesTraversable.arrangeBy(Function)
public Iterator<CharSeq> grouped(int size)
Traversable
Traversable
into fixed size blocks.
Let length be the length of this Iterable. Then grouped is defined as follows:
this.isEmpty()
, the resulting Iterator
is empty.size <= length
, the resulting Iterator
will contain length / size
blocks of size
size
and maybe a non-empty block of size length % size
, if there are remaining elements.size > length
, the resulting Iterator
will contain one block of size length
.
[].grouped(1) = []
[].grouped(0) throws
[].grouped(-1) throws
[1,2,3,4].grouped(2) = [[1,2],[3,4]]
[1,2,3,4,5].grouped(2) = [[1,2],[3,4],[5]]
[1,2,3,4].grouped(5) = [[1,2,3,4]]
Please note that grouped(int)
is a special case of Traversable.sliding(int, int), i.e.
grouped(size)
is the same as sliding(size, size)
.grouped
in interface IndexedSeq<java.lang.Character>
grouped
in interface Seq<java.lang.Character>
grouped
in interface Traversable<java.lang.Character>
size
- a positive block sizepublic boolean hasDefiniteSize()
Traversable
This method should be implemented by classes only, i.e. not by interfaces.
hasDefiniteSize
in interface Traversable<java.lang.Character>
public CharSeq init()
Traversable
init
in interface IndexedSeq<java.lang.Character>
init
in interface Seq<java.lang.Character>
init
in interface Traversable<java.lang.Character>
public Option<CharSeq> initOption()
Traversable
Option
.initOption
in interface IndexedSeq<java.lang.Character>
initOption
in interface Seq<java.lang.Character>
initOption
in interface Traversable<java.lang.Character>
Some(traversable)
or None
if this is empty.public CharSeq insert(int index, java.lang.Character element)
Seq
insert
in interface IndexedSeq<java.lang.Character>
insert
in interface Seq<java.lang.Character>
index
- an indexelement
- an elementpublic CharSeq insertAll(int index, java.lang.Iterable<? extends java.lang.Character> elements)
Seq
insertAll
in interface IndexedSeq<java.lang.Character>
insertAll
in interface Seq<java.lang.Character>
index
- an indexelements
- An Iterable of elementspublic Iterator<java.lang.Character> iterator()
Traversable
iterator
in interface Traversable<java.lang.Character>
iterator
in interface Value<java.lang.Character>
iterator
in interface java.lang.Iterable<java.lang.Character>
public CharSeq intersperse(java.lang.Character element)
Seq
intersperse
in interface IndexedSeq<java.lang.Character>
intersperse
in interface Seq<java.lang.Character>
element
- An element.public <U> IndexedSeq<U> map(java.util.function.Function<? super java.lang.Character,? extends U> mapper)
Traversable
Traversable
to elements of a new type preserving their order, if any.map
in interface IndexedSeq<java.lang.Character>
map
in interface Seq<java.lang.Character>
map
in interface Traversable<java.lang.Character>
map
in interface Value<java.lang.Character>
U
- Component type of the target Traversablemapper
- A mapper.public java.lang.String mkString()
Traversable
This has the same effect as calling mkString("", "", "")
.
mkString
in interface Traversable<java.lang.Character>
public CharSeq padTo(int length, java.lang.Character element)
Seq
Note: lazily-evaluated Seq implementations need to process all elements in order to gather the overall length.
padTo
in interface IndexedSeq<java.lang.Character>
padTo
in interface Seq<java.lang.Character>
length
- the target lengthelement
- the padding elementelement
so that the resulting sequence has a length of at least length
.public CharSeq leftPadTo(int length, java.lang.Character element)
Seq
Note: lazily-evaluated Seq implementations need to process all elements in order to gather the overall length.
leftPadTo
in interface Seq<java.lang.Character>
length
- the target lengthelement
- the padding elementelement
so that the resulting sequence has a length of at least length
.public CharSeq orElse(java.lang.Iterable<? extends java.lang.Character> other)
Traversable
Traversable
if it is nonempty, otherwise return the alternative.orElse
in interface IndexedSeq<java.lang.Character>
orElse
in interface Seq<java.lang.Character>
orElse
in interface Traversable<java.lang.Character>
other
- An alternative Traversable
Traversable
if it is nonempty, otherwise return the alternative.public CharSeq orElse(java.util.function.Supplier<? extends java.lang.Iterable<? extends java.lang.Character>> supplier)
Traversable
Traversable
if it is nonempty, otherwise return the result of evaluating supplier.orElse
in interface IndexedSeq<java.lang.Character>
orElse
in interface Seq<java.lang.Character>
orElse
in interface Traversable<java.lang.Character>
supplier
- An alternative Traversable
supplierTraversable
if it is nonempty, otherwise return the result of evaluating supplier.public CharSeq patch(int from, java.lang.Iterable<? extends java.lang.Character> that, int replaced)
Seq
patch
in interface IndexedSeq<java.lang.Character>
patch
in interface Seq<java.lang.Character>
from
- the index of the first replaced elementthat
- sequence for replacementreplaced
- the number of elements to drop in the original listpublic CharSeq mapChars(CharSeq.CharUnaryOperator mapper)
public Tuple2<CharSeq,CharSeq> partition(java.util.function.Predicate<? super java.lang.Character> predicate)
Traversable
Traversable
by splitting this elements in two in distinct traversables
according to a predicate.partition
in interface IndexedSeq<java.lang.Character>
partition
in interface Seq<java.lang.Character>
partition
in interface Traversable<java.lang.Character>
predicate
- A predicate which classifies an element if it is in the first or the second traversable.Traversable
contains all elements that satisfy the given predicate
, the second Traversable
contains all elements that don't. The original order of elements is preserved.public CharSeq peek(java.util.function.Consumer<? super java.lang.Character> action)
Value
action
on the first element if this is an eager implementation.
Performs the given action
on all elements (the first immediately, successive deferred),
if this is a lazy implementation.peek
in interface IndexedSeq<java.lang.Character>
peek
in interface Seq<java.lang.Character>
peek
in interface Traversable<java.lang.Character>
peek
in interface Value<java.lang.Character>
action
- The action that will be performed on the element(s).public IndexedSeq<CharSeq> permutations()
Seq
Example:
[].permutations() = []
[1,2,3].permutations() = [
[1,2,3],
[1,3,2],
[2,1,3],
[2,3,1],
[3,1,2],
[3,2,1]
]
permutations
in interface IndexedSeq<java.lang.Character>
permutations
in interface Seq<java.lang.Character>
public CharSeq prepend(java.lang.Character element)
Seq
prepend
in interface IndexedSeq<java.lang.Character>
prepend
in interface Seq<java.lang.Character>
element
- An elementpublic CharSeq prependAll(java.lang.Iterable<? extends java.lang.Character> elements)
Seq
prependAll
in interface IndexedSeq<java.lang.Character>
prependAll
in interface Seq<java.lang.Character>
elements
- An Iterable of elementspublic CharSeq remove(java.lang.Character element)
Seq
remove
in interface IndexedSeq<java.lang.Character>
remove
in interface Seq<java.lang.Character>
element
- An element to be removed from this Seq.public CharSeq removeFirst(java.util.function.Predicate<java.lang.Character> predicate)
Seq
removeFirst
in interface IndexedSeq<java.lang.Character>
removeFirst
in interface Seq<java.lang.Character>
predicate
- an predicatepublic CharSeq removeLast(java.util.function.Predicate<java.lang.Character> predicate)
Seq
removeLast
in interface IndexedSeq<java.lang.Character>
removeLast
in interface Seq<java.lang.Character>
predicate
- an predicatepublic CharSeq removeAt(int index)
Seq
removeAt
in interface IndexedSeq<java.lang.Character>
removeAt
in interface Seq<java.lang.Character>
index
- position of element to removepublic CharSeq removeAll(java.lang.Character element)
Seq
removeAll
in interface IndexedSeq<java.lang.Character>
removeAll
in interface Seq<java.lang.Character>
element
- An element to be removed from this Seq.public CharSeq removeAll(java.lang.Iterable<? extends java.lang.Character> elements)
Seq
removeAll
in interface IndexedSeq<java.lang.Character>
removeAll
in interface Seq<java.lang.Character>
elements
- Elements to be removed from this Seq.public CharSeq replace(java.lang.Character currentElement, java.lang.Character newElement)
Traversable
replace
in interface IndexedSeq<java.lang.Character>
replace
in interface Seq<java.lang.Character>
replace
in interface Traversable<java.lang.Character>
currentElement
- An element to be substituted.newElement
- A replacement for currentElement.public CharSeq replaceAll(java.lang.Character currentElement, java.lang.Character newElement)
Traversable
replaceAll
in interface IndexedSeq<java.lang.Character>
replaceAll
in interface Seq<java.lang.Character>
replaceAll
in interface Traversable<java.lang.Character>
currentElement
- An element to be substituted.newElement
- A replacement for currentElement.public CharSeq retainAll(java.lang.Iterable<? extends java.lang.Character> elements)
Traversable
retainAll
in interface IndexedSeq<java.lang.Character>
retainAll
in interface Seq<java.lang.Character>
retainAll
in interface Traversable<java.lang.Character>
elements
- Elements to be kept.public CharSeq reverse()
Seq
reverse
in interface IndexedSeq<java.lang.Character>
reverse
in interface Seq<java.lang.Character>
public CharSeq rotateLeft(int n)
Seq
// = List(3, 4, 5, 1, 2)
List.of(1, 2, 3, 4, 5).rotateLeft(2);
rotateLeft
in interface IndexedSeq<java.lang.Character>
rotateLeft
in interface Seq<java.lang.Character>
n
- distance of left rotationpublic CharSeq rotateRight(int n)
Seq
// = List(4, 5, 1, 2, 3)
List.of(1, 2, 3, 4, 5).rotateRight(2);
rotateRight
in interface IndexedSeq<java.lang.Character>
rotateRight
in interface Seq<java.lang.Character>
n
- distance of right rotationpublic CharSeq scan(java.lang.Character zero, java.util.function.BiFunction<? super java.lang.Character,? super java.lang.Character,? extends java.lang.Character> operation)
Traversable
scan
in interface IndexedSeq<java.lang.Character>
scan
in interface Seq<java.lang.Character>
scan
in interface Traversable<java.lang.Character>
zero
- neutral element for the operator opoperation
- the associative operator for the scanpublic <U> IndexedSeq<U> scanLeft(U zero, java.util.function.BiFunction<? super U,? super java.lang.Character,? extends U> operation)
Traversable
scanLeft
in interface IndexedSeq<java.lang.Character>
scanLeft
in interface Seq<java.lang.Character>
scanLeft
in interface Traversable<java.lang.Character>
U
- the type of the elements in the resulting collectionzero
- the initial valueoperation
- the binary operator applied to the intermediate result and the elementpublic <U> IndexedSeq<U> scanRight(U zero, java.util.function.BiFunction<? super java.lang.Character,? super U,? extends U> operation)
Traversable
scanRight
in interface IndexedSeq<java.lang.Character>
scanRight
in interface Seq<java.lang.Character>
scanRight
in interface Traversable<java.lang.Character>
U
- the type of the elements in the resulting collectionzero
- the initial valueoperation
- the binary operator applied to the intermediate result and the elementpublic CharSeq shuffle()
Seq
shuffle
in interface IndexedSeq<java.lang.Character>
shuffle
in interface Seq<java.lang.Character>
public CharSeq shuffle(java.util.Random random)
Seq
shuffle
in interface IndexedSeq<java.lang.Character>
shuffle
in interface Seq<java.lang.Character>
random
- A random number generatorpublic CharSeq slice(int beginIndex, int endIndex)
Seq
beginIndex
and extends to the element at index endIndex - 1
.
Examples:
List.of(1, 2, 3, 4).slice(1, 3); // = (2, 3)
List.of(1, 2, 3, 4).slice(0, 4); // = (1, 2, 3, 4)
List.of(1, 2, 3, 4).slice(2, 2); // = ()
List.of(1, 2).slice(1, 0); // = ()
List.of(1, 2).slice(-10, 10); // = (1, 2)
See also Seq.subSequence(int, int)
which throws in some cases instead of returning a sequence.slice
in interface IndexedSeq<java.lang.Character>
slice
in interface Seq<java.lang.Character>
beginIndex
- the beginning index, inclusiveendIndex
- the end index, exclusivepublic Iterator<CharSeq> slideBy(java.util.function.Function<? super java.lang.Character,?> classifier)
Traversable
Traversable
.
Each window contains elements with the same class, as determined by classifier
. Two consecutive
values in this Traversable
will be in the same window only if classifier
returns equal
values for them. Otherwise, the values will constitute the last element of the previous window and the
first element of the next window.
Examples:
[].slideBy(Function.identity()) = []
[1,2,3,4,4,5].slideBy(Function.identity()) = [[1],[2],[3],[4,4],[5]]
[1,2,3,10,12,5,7,20,29].slideBy(x -> x/10) = [[1,2,3],[10,12],[5,7],[20,29]]
slideBy
in interface IndexedSeq<java.lang.Character>
slideBy
in interface Seq<java.lang.Character>
slideBy
in interface Traversable<java.lang.Character>
classifier
- A function which classifies elements into classespublic Iterator<CharSeq> sliding(int size)
Traversable
size
and step size 1 over this Traversable
by calling
Traversable.sliding(int, int)
.sliding
in interface IndexedSeq<java.lang.Character>
sliding
in interface Seq<java.lang.Character>
sliding
in interface Traversable<java.lang.Character>
size
- a positive window sizepublic Iterator<CharSeq> sliding(int size, int step)
Traversable
size
and step
size over this Traversable
.
Examples:
[].sliding(1,1) = []
[1,2,3,4,5].sliding(2,3) = [[1,2],[4,5]]
[1,2,3,4,5].sliding(2,4) = [[1,2],[5]]
[1,2,3,4,5].sliding(2,5) = [[1,2]]
[1,2,3,4].sliding(5,3) = [[1,2,3,4]]
sliding
in interface IndexedSeq<java.lang.Character>
sliding
in interface Seq<java.lang.Character>
sliding
in interface Traversable<java.lang.Character>
size
- a positive window sizestep
- a positive step sizepublic CharSeq sorted()
Seq
Comparable
, a java.lang.ClassCastException
may be thrown.sorted
in interface IndexedSeq<java.lang.Character>
sorted
in interface Seq<java.lang.Character>
public CharSeq sorted(java.util.Comparator<? super java.lang.Character> comparator)
Seq
Comparator
. If this elements are not
Comparable
, a java.lang.ClassCastException
may be thrown.sorted
in interface IndexedSeq<java.lang.Character>
sorted
in interface Seq<java.lang.Character>
comparator
- A comparatorpublic <U extends java.lang.Comparable<? super U>> CharSeq sortBy(java.util.function.Function<? super java.lang.Character,? extends U> mapper)
Seq
mapper
.sortBy
in interface IndexedSeq<java.lang.Character>
sortBy
in interface Seq<java.lang.Character>
U
- The domain where elements are comparedmapper
- A mapperpublic <U> CharSeq sortBy(java.util.Comparator<? super U> comparator, java.util.function.Function<? super java.lang.Character,? extends U> mapper)
Seq
mapper
.sortBy
in interface IndexedSeq<java.lang.Character>
sortBy
in interface Seq<java.lang.Character>
U
- The domain where elements are comparedcomparator
- A comparatormapper
- A mapperpublic Tuple2<CharSeq,CharSeq> span(java.util.function.Predicate<? super java.lang.Character> predicate)
Traversable
predicate
and the second element is the remainder.span
in interface IndexedSeq<java.lang.Character>
span
in interface Seq<java.lang.Character>
span
in interface Traversable<java.lang.Character>
predicate
- A predicate.Tuple
containing the longest prefix of elements that satisfy p and the remainder.public CharSeq subSequence(int beginIndex)
Seq
beginIndex
and extends to the end of this Seq.
Examples:
List.of(1, 2).subSequence(0); // = (1, 2)
List.of(1, 2).subSequence(1); // = (2)
List.of(1, 2).subSequence(2); // = ()
List.of(1, 2).subSequence(10); // throws IndexOutOfBoundsException
List.of(1, 2).subSequence(-10); // throws IndexOutOfBoundsException
See also Seq.drop(int)
which is similar but does not throw.subSequence
in interface IndexedSeq<java.lang.Character>
subSequence
in interface Seq<java.lang.Character>
beginIndex
- the beginning index, inclusivepublic CharSeq tail()
Traversable
tail
in interface IndexedSeq<java.lang.Character>
tail
in interface Seq<java.lang.Character>
tail
in interface Traversable<java.lang.Character>
public Option<CharSeq> tailOption()
Traversable
Option
.tailOption
in interface IndexedSeq<java.lang.Character>
tailOption
in interface Seq<java.lang.Character>
tailOption
in interface Traversable<java.lang.Character>
Some(traversable)
or None
if this is empty.public CharSeq take(int n)
Traversable
The result is equivalent to sublist(0, max(0, min(length(), n)))
but does not throw if n < 0
or
n > length()
.
In the case of n < 0
the empty instance is returned, in the case of n > length()
this is returned.
take
in interface IndexedSeq<java.lang.Character>
take
in interface Seq<java.lang.Character>
take
in interface Traversable<java.lang.Character>
n
- The number of elements to take.public CharSeq takeUntil(java.util.function.Predicate<? super java.lang.Character> predicate)
Traversable
Note: This is essentially the same as takeWhile(predicate.negate())
. It is intended to be used with
method references, which cannot be negated directly.
takeUntil
in interface IndexedSeq<java.lang.Character>
takeUntil
in interface Seq<java.lang.Character>
takeUntil
in interface Traversable<java.lang.Character>
predicate
- A condition tested subsequently for this elements.public CharSeq takeWhile(java.util.function.Predicate<? super java.lang.Character> predicate)
Traversable
takeWhile
in interface IndexedSeq<java.lang.Character>
takeWhile
in interface Seq<java.lang.Character>
takeWhile
in interface Traversable<java.lang.Character>
predicate
- A condition tested subsequently for the contained elements.public CharSeq takeRight(int n)
Traversable
The result is equivalent to sublist(max(0, min(length(), length() - n)), n)
, i.e. takeRight will not
throw if n < 0
or n > length()
.
In the case of n < 0
the empty instance is returned, in the case of n > length()
this is returned.
takeRight
in interface IndexedSeq<java.lang.Character>
takeRight
in interface Seq<java.lang.Character>
takeRight
in interface Traversable<java.lang.Character>
n
- The number of elements to take.public CharSeq takeRightUntil(java.util.function.Predicate<? super java.lang.Character> predicate)
Seq
takeRightUntil
in interface IndexedSeq<java.lang.Character>
takeRightUntil
in interface Seq<java.lang.Character>
predicate
- A condition tested subsequently for this elements, starting from the end.public CharSeq takeRightWhile(java.util.function.Predicate<? super java.lang.Character> predicate)
Seq
Note: This is essentially the same as takeRightUntil(predicate.negate())
.
It is intended to be used with method references, which cannot be negated directly.
takeRightWhile
in interface IndexedSeq<java.lang.Character>
takeRightWhile
in interface Seq<java.lang.Character>
predicate
- A condition tested subsequently for this elements, starting from the end.public <U> U transform(java.util.function.Function<? super CharSeq,? extends U> f)
CharSeq
.U
- Type of transformation resultf
- A transformationU
java.lang.NullPointerException
- if f
is nullpublic CharSeq update(int index, java.lang.Character element)
Seq
update
in interface IndexedSeq<java.lang.Character>
update
in interface Seq<java.lang.Character>
index
- an indexelement
- an elementpublic CharSeq update(int index, java.util.function.Function<? super java.lang.Character,? extends java.lang.Character> updater)
Seq
update
in interface IndexedSeq<java.lang.Character>
update
in interface Seq<java.lang.Character>
index
- an indexupdater
- a function transforming the previous valuepublic <U> IndexedSeq<Tuple2<java.lang.Character,U>> zip(java.lang.Iterable<? extends U> that)
Traversable
The length of the returned traversable is the minimum of the lengths of this traversable and that
iterable.
zip
in interface IndexedSeq<java.lang.Character>
zip
in interface Seq<java.lang.Character>
zip
in interface Traversable<java.lang.Character>
U
- The type of the second half of the returned pairs.that
- The Iterable providing the second half of each result pair.that
iterable.public <U,R> IndexedSeq<R> zipWith(java.lang.Iterable<? extends U> that, java.util.function.BiFunction<? super java.lang.Character,? super U,? extends R> mapper)
Traversable
The length of the returned traversable is the minimum of the lengths of this traversable and that
iterable.
zipWith
in interface IndexedSeq<java.lang.Character>
zipWith
in interface Seq<java.lang.Character>
zipWith
in interface Traversable<java.lang.Character>
U
- The type of the second parameter of the mapper.R
- The type of the mapped elements.that
- The Iterable providing the second parameter of the mapper.mapper
- a mapper.that
iterable.public <U> IndexedSeq<Tuple2<java.lang.Character,U>> zipAll(java.lang.Iterable<? extends U> that, java.lang.Character thisElem, U thatElem)
Traversable
The length of the returned traversable is the maximum of the lengths of this traversable and that
iterable.
Special case: if this traversable is shorter than that elements, and that elements contains duplicates, the resulting traversable may be shorter than the maximum of the lengths of this and that because a traversable contains an element at most once.
If this Traversable is shorter than that, thisElem values are used to fill the result. If that is shorter than this Traversable, thatElem values are used to fill the result.
zipAll
in interface IndexedSeq<java.lang.Character>
zipAll
in interface Seq<java.lang.Character>
zipAll
in interface Traversable<java.lang.Character>
U
- The type of the second half of the returned pairs.that
- The Iterable providing the second half of each result pair.thisElem
- The element to be used to fill up the result if this traversable is shorter than that.thatElem
- The element to be used to fill up the result if that is shorter than this traversable.public IndexedSeq<Tuple2<java.lang.Character,java.lang.Integer>> zipWithIndex()
Traversable
zipWithIndex
in interface IndexedSeq<java.lang.Character>
zipWithIndex
in interface Seq<java.lang.Character>
zipWithIndex
in interface Traversable<java.lang.Character>
public <U> IndexedSeq<U> zipWithIndex(java.util.function.BiFunction<? super java.lang.Character,? super java.lang.Integer,? extends U> mapper)
Traversable
The length of the returned traversable is the minimum of the lengths of this traversable and that
iterable.
zipWithIndex
in interface IndexedSeq<java.lang.Character>
zipWithIndex
in interface Seq<java.lang.Character>
zipWithIndex
in interface Traversable<java.lang.Character>
U
- The type of the mapped elements.mapper
- a mapper.that
iterable.public java.lang.Character apply(java.lang.Integer index)
Seq
Seq
is a partial function which returns the element at the specified index if the
index is valid. It's up to the caller to make sure the index is valid (for instance through
isDefinedAt
).
The behaviour is undefined if the index is out of bounds.
It may throw any RuntimeException
or return an arbitrary value.apply
in interface Seq<java.lang.Character>
apply
in interface Function1<java.lang.Integer,java.lang.Character>
apply
in interface PartialFunction<java.lang.Integer,java.lang.Character>
apply
in interface java.util.function.Function<java.lang.Integer,java.lang.Character>
index
- an indexpublic int indexOf(java.lang.Character element, int from)
Seq
public int lastIndexOf(java.lang.Character element, int end)
Seq
lastIndexOf
in interface Seq<java.lang.Character>
element
- an elementend
- the end indexpublic Tuple2<CharSeq,CharSeq> splitAt(int n)
Seq
splitAt(n)
is equivalent to
Tuple.of(take(n), drop(n))
.public Tuple2<CharSeq,CharSeq> splitAt(java.util.function.Predicate<? super java.lang.Character> predicate)
Seq
Predicate
, e.g. Tuple(init, element+tail).public Tuple2<CharSeq,CharSeq> splitAtInclusive(java.util.function.Predicate<? super java.lang.Character> predicate)
Seq
Predicate
, e.g. Tuple(init+element, tail).splitAtInclusive
in interface Seq<java.lang.Character>
predicate
- An predicateTuple
containing divided sequencespublic boolean startsWith(java.lang.Iterable<? extends java.lang.Character> that, int offset)
Seq
Note: If the both the receiver object this and the argument that are infinite sequences this method may not terminate.
startsWith
in interface IndexedSeq<java.lang.Character>
startsWith
in interface Seq<java.lang.Character>
that
- the sequence to testoffset
- the index where the sequence is searched.public java.lang.Character head()
Traversable
head
in interface Traversable<java.lang.Character>
public boolean isAsync()
CharSeq
is computed synchronously.public boolean isEmpty()
Traversable
isEmpty
in interface Traversable<java.lang.Character>
isEmpty
in interface Value<java.lang.Character>
public boolean isLazy()
CharSeq
is computed eagerly.public boolean isTraversableAgain()
Traversable
This method should be implemented by classes only, i.e. not by interfaces.
isTraversableAgain
in interface Traversable<java.lang.Character>
public boolean equals(java.lang.Object o)
Traversable
Notes:
equals
in interface Traversable<java.lang.Character>
equals
in interface Value<java.lang.Character>
equals
in class java.lang.Object
o
- an object, may be nullpublic int hashCode()
Traversable
int hash = 1;
for (T t : this) { hash = hash * 31 + Objects.hashCode(t); }
Collections with arbitrary iteration order are hashed in a way such that the hash of a fixed number of elements is independent of their iteration order.
int hash = 1;
for (T t : this) { hash += Objects.hashCode(t); }
Please note that the particular hashing algorithms may change in a future version of Vavr.
public final class Hashed<K> {
private final K key;
private final Lazy<Integer> hashCode;
public Hashed(K key) {
this.key = key;
this.hashCode = Lazy.of(() -> Objects.hashCode(key));
}
public K key() {
return key;
}
@Override
public boolean equals(Object o) {
if (o == key) {
return true;
} else if (key != null && o instanceof Hashed) {
final Hashed that = (Hashed) o;
return key.equals(that.key);
} else {
return false;
}
}
@Override
public int hashCode() {
return hashCode.get();
}
@Override
public String toString() {
return "Hashed(" + (key == null ? "null" : key.toString()) + ")";
}
}
hashCode
in interface Traversable<java.lang.Character>
hashCode
in interface Value<java.lang.Character>
hashCode
in class java.lang.Object
public char charAt(int index)
char
value at the
specified index. An index ranges from 0
to
length() - 1
. The first char
value of the sequence
is at index 0
, the next at index 1
,
and so on, as for array indexing.
If the char
value specified by the index is a
surrogate, the surrogate
value is returned.
charAt
in interface java.lang.CharSequence
index
- the index of the char
value.char
value at the specified index of this string.
The first char
value is at index 0
.java.lang.IndexOutOfBoundsException
- if the index
argument is negative or not less than the length of this
string.public int length()
length
in interface Traversable<java.lang.Character>
length
in interface java.lang.CharSequence
public int codePointAt(int index)
char
values
(Unicode code units) and ranges from 0
to
length()
- 1
.
If the char
value specified at the given index
is in the high-surrogate range, the following index is less
than the length of this CharSeq
, and the
char
value at the following index is in the
low-surrogate range, then the supplementary code point
corresponding to this surrogate pair is returned. Otherwise,
the char
value at the given index is returned.
index
- the index to the char
valuesindex
java.lang.IndexOutOfBoundsException
- if the index
argument is negative or not less than the length of this
string.public int codePointBefore(int index)
char
values
(Unicode code units) and ranges from 1
to length
.
If the char
value at (index - 1)
is in the low-surrogate range, (index - 2)
is not
negative, and the char
value at (index -
2)
is in the high-surrogate range, then the
supplementary code point value of the surrogate pair is
returned. If the char
value at index -
1
is an unpaired low-surrogate or a high-surrogate, the
surrogate value is returned.
index
- the index following the code point that should be returnedjava.lang.IndexOutOfBoundsException
- if the index
argument is less than 1 or greater than the length
of this string.public int codePointCount(int beginIndex, int endIndex)
CharSeq
. The text range begins at the
specified beginIndex
and extends to the
char
at index endIndex - 1
. Thus the
length (in char
s) of the text range is
endIndex-beginIndex
. Unpaired surrogates within
the text range count as one code point each.beginIndex
- the index to the first char
of
the text range.endIndex
- the index after the last char
of
the text range.java.lang.IndexOutOfBoundsException
- if the
beginIndex
is negative, or endIndex
is larger than the length of this CharSeq
, or
beginIndex
is larger than endIndex
.public int offsetByCodePoints(int index, int codePointOffset)
CharSeq
that is
offset from the given index
by
codePointOffset
code points. Unpaired surrogates
within the text range given by index
and
codePointOffset
count as one code point each.index
- the index to be offsetcodePointOffset
- the offset in code pointsCharSeq
java.lang.IndexOutOfBoundsException
- if index
is negative or larger then the length of this
CharSeq
, or if codePointOffset
is positive
and the substring starting with index
has fewer
than codePointOffset
code points,
or if codePointOffset
is negative and the substring
before index
has fewer than the absolute value
of codePointOffset
code points.public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
The first character to be copied is at index srcBegin
;
the last character to be copied is at index srcEnd-1
(thus the total number of characters to be copied is
srcEnd-srcBegin
). The characters are copied into the
subarray of dst
starting at index dstBegin
and ending at index:
dstbegin + (srcEnd-srcBegin) - 1
srcBegin
- index of the first character in the string
to copy.srcEnd
- index after the last character in the string
to copy.dst
- the destination array.dstBegin
- the start offset in the destination array.java.lang.IndexOutOfBoundsException
- If any of the following
is true:
srcBegin
is negative.
srcBegin
is greater than srcEnd
srcEnd
is greater than the length of this
string
dstBegin
is negative
dstBegin+(srcEnd-srcBegin)
is larger than
dst.length
public byte[] getBytes(java.lang.String charsetName) throws java.io.UnsupportedEncodingException
CharSeq
into a sequence of bytes using the named
charset, storing the result into a new byte array.
The behavior of this method when this string cannot be encoded in
the given charset is unspecified. The CharsetEncoder
class should be used when more control
over the encoding process is required.
charsetName
- The name of a supported charsetjava.io.UnsupportedEncodingException
- If the named charset is not supportedpublic byte[] getBytes(java.nio.charset.Charset charset)
CharSeq
into a sequence of bytes using the given
charset, storing the result into a
new byte array.
This method always replaces malformed-input and unmappable-character
sequences with this charset's default replacement byte array. The
CharsetEncoder
class should be used when more
control over the encoding process is required.
charset
- The Charset to be used to encode
the CharSeq
public byte[] getBytes()
CharSeq
into a sequence of bytes using the
platform's default charset, storing the result into a new byte array.
The behavior of this method when this string cannot be encoded in
the default charset is unspecified. The CharsetEncoder
class should be used when more control
over the encoding process is required.
public boolean contentEquals(java.lang.StringBuffer sb)
StringBuffer
. The result
is true
if and only if this CharSeq
represents the same
sequence of characters as the specified StringBuffer
. This method
synchronizes on the StringBuffer
.sb
- The StringBuffer
to compare this CharSeq
againsttrue
if this CharSeq
represents the same
sequence of characters as the specified StringBuffer
,
false
otherwisepublic boolean contentEquals(java.lang.CharSequence cs)
CharSequence
. The
result is true
if and only if this CharSeq
represents the
same sequence of char values as the specified sequence. Note that if the
CharSequence
is a StringBuffer
then the method
synchronizes on it.cs
- The sequence to compare this CharSeq
againsttrue
if this CharSeq
represents the same
sequence of char values as the specified sequence, false
otherwisepublic boolean equalsIgnoreCase(CharSeq anotherString)
CharSeq
to another CharSeq
, ignoring case
considerations. Two strings are considered equal ignoring case if they
are of the same length and corresponding characters in the two strings
are equal ignoring case.
Two characters c1
and c2
are considered the same
ignoring case if at least one of the following is true:
==
operator)
Character.toUpperCase(char)
to each character
produces the same result
Character.toLowerCase(char)
to each character
produces the same result
anotherString
- The CharSeq
to compare this CharSeq
againsttrue
if the argument is not null
and it
represents an equivalent CharSeq
ignoring case; false
otherwiseequals(Object)
public int compareTo(CharSeq anotherString)
CharSeq
object is compared lexicographically to the
character sequence represented by the argument string. The result is
a negative integer if this CharSeq
object
lexicographically precedes the argument string. The result is a
positive integer if this CharSeq
object lexicographically
follows the argument string. The result is zero if the strings
are equal; compareTo
returns 0
exactly when
the equals(Object)
method would return true
.
This is the definition of lexicographic ordering. If two strings are
different, then either they have different characters at some index
that is a valid index for both strings, or their lengths are different,
or both. If they have different characters at one or more index
positions, let k be the smallest such index; then the string
whose character at position k has the smaller value, as
determined by using the < operator, lexicographically precedes the
other string. In this case, compareTo
returns the
difference of the two character values at position k
in
the two string -- that is, the value:
If there is no index position at which they differ, then the shorter string lexicographically precedes the longer string. In this case,this.charAt(k)-anotherString.charAt(k)
compareTo
returns the difference of the lengths of the
strings -- that is, the value:
this.length()-anotherString.length()
compareTo
in interface java.lang.Comparable<CharSeq>
anotherString
- the CharSeq
to be compared.0
if the argument string is equal to
this string; a value less than 0
if this string
is lexicographically less than the string argument; and a
value greater than 0
if this string is
lexicographically greater than the string argument.public int compareToIgnoreCase(CharSeq str)
compareTo
with normalized versions of the strings
where case differences have been eliminated by calling
Character.toLowerCase(Character.toUpperCase(character))
on
each character.
Note that this method does not take locale into account, and will result in an unsatisfactory ordering for certain locales. The java.text package provides collators to allow locale-sensitive ordering.
str
- the CharSeq
to be compared.public boolean regionMatches(int toffset, CharSeq other, int ooffset, int len)
A substring of this CharSeq
object is compared to a substring
of the argument other. The result is true if these substrings
represent identical character sequences. The substring of this
CharSeq
object to be compared begins at index toffset
and has length len
. The substring of other to be compared
begins at index ooffset
and has length len
. The
result is false
if and only if at least one of the following
is true:
toffset
is negative.
ooffset
is negative.
toffset+len
is greater than the length of this
CharSeq
object.
ooffset+len
is greater than the length of the other
argument.
len
such that:
this.charAt(toffset +
k) != other.charAt(ooffset +
k)
toffset
- the starting offset of the subregion in this string.other
- the string argument.ooffset
- the starting offset of the subregion in the string
argument.len
- the number of characters to compare.true
if the specified subregion of this string
exactly matches the specified subregion of the string argument;
false
otherwise.public boolean regionMatches(boolean ignoreCase, int toffset, CharSeq other, int ooffset, int len)
A substring of this CharSeq
object is compared to a substring
of the argument other
. The result is true
if these
substrings represent character sequences that are the same, ignoring
case if and only if ignoreCase
is true. The substring of
this CharSeq
object to be compared begins at index
toffset
and has length len
. The substring of
other
to be compared begins at index ooffset
and
has length len
. The result is false
if and only if
at least one of the following is true:
toffset
is negative.
ooffset
is negative.
toffset+len
is greater than the length of this
CharSeq
object.
ooffset+len
is greater than the length of the other
argument.
ignoreCase
is false
and there is some nonnegative
integer k less than len
such that:
this.charAt(toffset+k) != other.charAt(ooffset+k)
ignoreCase
is true
and there is some nonnegative
integer k less than len
such that:
and:Character.toLowerCase(this.charAt(toffset+k)) != Character.toLowerCase(other.charAt(ooffset+k))
Character.toUpperCase(this.charAt(toffset+k)) != Character.toUpperCase(other.charAt(ooffset+k))
ignoreCase
- if true
, ignore case when comparing
characters.toffset
- the starting offset of the subregion in this
string.other
- the string argument.ooffset
- the starting offset of the subregion in the string
argument.len
- the number of characters to compare.true
if the specified subregion of this string
matches the specified subregion of the string argument;
false
otherwise. Whether the matching is exact
or case insensitive depends on the ignoreCase
argument.public CharSeq subSequence(int beginIndex, int endIndex)
Seq
beginIndex
and extends to the element at index endIndex - 1
.
Examples:
List.of(1, 2, 3, 4).subSequence(1, 3); // = (2, 3)
List.of(1, 2, 3, 4).subSequence(0, 4); // = (1, 2, 3, 4)
List.of(1, 2, 3, 4).subSequence(2, 2); // = ()
List.of(1, 2).subSequence(1, 0); // throws IndexOutOfBoundsException
List.of(1, 2).subSequence(-10, 1); // throws IndexOutOfBoundsException
List.of(1, 2).subSequence(0, 10); // throws IndexOutOfBoundsException
See also Seq.slice(int, int)
which returns an empty sequence instead of throwing.subSequence
in interface IndexedSeq<java.lang.Character>
subSequence
in interface Seq<java.lang.Character>
subSequence
in interface java.lang.CharSequence
beginIndex
- the beginning index, inclusiveendIndex
- the end index, exclusivepublic boolean startsWith(CharSeq prefix, int toffset)
prefix
- the prefix.toffset
- where to begin looking in this string.true
if the character sequence represented by the
argument is a prefix of the substring of this object starting
at index toffset
; false
otherwise.
The result is false
if toffset
is
negative or greater than the length of this
CharSeq
object; otherwise the result is the same
as the result of the expression
this.substring(toffset).startsWith(prefix)
public boolean startsWith(CharSeq prefix)
prefix
- the prefix.true
if the character sequence represented by the
argument is a prefix of the character sequence represented by
this string; false
otherwise.
Note also that true
will be returned if the
argument is an empty string or is equal to this
CharSeq
object as determined by the
equals(Object)
method.public boolean endsWith(CharSeq suffix)
suffix
- the suffix.true
if the character sequence represented by the
argument is a suffix of the character sequence represented by
this object; false
otherwise. Note that the
result will be true
if the argument is the
empty string or is equal to this CharSeq
object
as determined by the equals(Object)
method.public int indexOf(int ch)
ch
occurs in the character sequence represented by
this CharSeq
object, then the index (in Unicode
code units) of the first such occurrence is returned. For
values of ch
in the range from 0 to 0xFFFF
(inclusive), this is the smallest value k such that:
is true. For other values ofthis.charAt(k) == ch
ch
, it is the
smallest value k such that:
is true. In either case, if no such character occurs in this string, thenthis.codePointAt(k) == ch
-1
is returned.ch
- a character (Unicode code point).-1
if the character does not occur.public int indexOf(int ch, int fromIndex)
If a character with value ch
occurs in the
character sequence represented by this CharSeq
object at an index no smaller than fromIndex
, then
the index of the first such occurrence is returned. For values
of ch
in the range from 0 to 0xFFFF (inclusive),
this is the smallest value k such that:
is true. For other values of(this.charAt(k) == ch)&&
(k >= fromIndex)
ch
, it is the
smallest value k such that:
is true. In either case, if no such character occurs in this string at or after position(this.codePointAt(k) == ch)&&
(k >= fromIndex)
fromIndex
, then
-1
is returned.
There is no restriction on the value of fromIndex
. If it
is negative, it has the same effect as if it were zero: this entire
string may be searched. If it is greater than the length of this
string, it has the same effect as if it were equal to the length of
this string: -1
is returned.
All indices are specified in char
values
(Unicode code units).
ch
- a character (Unicode code point).fromIndex
- the index to start the search from.fromIndex
, or -1
if the character does not occur.public int lastIndexOf(int ch)
ch
in the
range from 0 to 0xFFFF (inclusive), the index (in Unicode code
units) returned is the largest value k such that:
is true. For other values ofthis.charAt(k) == ch
ch
, it is the
largest value k such that:
is true. In either case, if no such character occurs in this string, thenthis.codePointAt(k) == ch
-1
is returned. The
CharSeq
is searched backwards starting at the last
character.ch
- a character (Unicode code point).-1
if the character does not occur.public int lastIndexOf(int ch, int fromIndex)
ch
in the range
from 0 to 0xFFFF (inclusive), the index returned is the largest
value k such that:
is true. For other values of(this.charAt(k) == ch)&&
(k <= fromIndex)
ch
, it is the
largest value k such that:
is true. In either case, if no such character occurs in this string at or before position(this.codePointAt(k) == ch)&&
(k <= fromIndex)
fromIndex
, then
-1
is returned.
All indices are specified in char
values
(Unicode code units).
ch
- a character (Unicode code point).fromIndex
- the index to start the search from. There is no
restriction on the value of fromIndex
. If it is
greater than or equal to the length of this string, it has
the same effect as if it were equal to one less than the
length of this string: this entire string may be searched.
If it is negative, it has the same effect as if it were -1:
-1 is returned.fromIndex
, or -1
if the character does not occur before that point.public Option<java.lang.Integer> lastIndexOfOption(int ch, int fromIndex)
Option
,
starting the search at the specified index.ch
- a character (Unicode code point).fromIndex
- the index to start the search from.Some(index)
or None
if not found.public int indexOf(CharSeq str)
The returned index is the smallest value k for which:
If no such value of k exists, thenthis.startsWith(str, k)
-1
is returned.str
- the substring to search for.-1
if there is no such occurrence.public Option<java.lang.Integer> indexOfOption(CharSeq str)
Option
.str
- the substring to search for.Some(index)
or None
if not found.public int indexOf(CharSeq str, int fromIndex)
The returned index is the smallest value k for which:
If no such value of k exists, thenk >= fromIndex&&
this.startsWith(str, k)
-1
is returned.str
- the substring to search for.fromIndex
- the index from which to start the search.-1
if there is no such occurrence.public Option<java.lang.Integer> indexOfOption(CharSeq str, int fromIndex)
Option
,
starting the search at the specified index.str
- the substring to search for.fromIndex
- the index from which to start the search.Some(index)
or None
if not found.public int lastIndexOf(CharSeq str)
this.length()
.
The returned index is the largest value k for which:
If no such value of k exists, thenthis.startsWith(str, k)
-1
is returned.str
- the substring to search for.-1
if there is no such occurrence.public Option<java.lang.Integer> lastIndexOfOption(CharSeq str)
Option
.str
- the substring to search for.Some(index)
or None
if not found.public int lastIndexOf(CharSeq str, int fromIndex)
The returned index is the largest value k for which:
If no such value of k exists, thenk<=
fromIndex&&
this.startsWith(str, k)
-1
is returned.str
- the substring to search for.fromIndex
- the index to start the search from.-1
if there is no such occurrence.public Option<java.lang.Integer> lastIndexOfOption(CharSeq str, int fromIndex)
Option
,
starting the search at the specified index.str
- the substring to search for.fromIndex
- the index to start the search from.Some(index)
or None
if not found.public CharSeq substring(int beginIndex)
Examples:
"unhappy".substring(2) returns "happy" "Harbison".substring(3) returns "bison" "emptiness".substring(9) returns "" (an empty string)
beginIndex
- the beginning index, inclusive.java.lang.IndexOutOfBoundsException
- if
beginIndex
is negative or larger than the
length of this CharSeq
object.public CharSeq substring(int beginIndex, int endIndex)
beginIndex
and
extends to the character at index endIndex - 1
.
Thus the length of the substring is endIndex-beginIndex
.
Examples:
"hamburger".substring(4, 8) returns "urge" "smiles".substring(1, 5) returns "mile"
beginIndex
- the beginning index, inclusive.endIndex
- the ending index, exclusive.java.lang.IndexOutOfBoundsException
- if the
beginIndex
is negative, or
endIndex
is larger than the length of
this CharSeq
object, or
beginIndex
is larger than
endIndex
.public java.lang.String stringPrefix()
Value
stringPrefix
in interface Value<java.lang.Character>
public java.lang.String toString()
public CharSeq concat(CharSeq str)
If the length of the argument string is 0
, then this
CharSeq
object is returned. Otherwise, a
CharSeq
object is returned that represents a character
sequence that is the concatenation of the character sequence
represented by this CharSeq
object and the character
sequence represented by the argument string.
Examples:
"cares".concat("s") returns "caress" "to".concat("get").concat("her") returns "together"
str
- the CharSeq
that is concatenated to the end
of this CharSeq
.public boolean matches(java.lang.String regex)
An invocation of this method of the form
str.matches(
regex)
yields exactly the
same result as the expression
Pattern
.matches(regex, str)
regex
- the regular expression to which this string is to be matchedtrue
if, and only if, this string matches the
given regular expressionjava.util.regex.PatternSyntaxException
- if the regular expression's syntax is invalidPattern
public boolean contains(java.lang.CharSequence s)
s
- the sequence to search fors
, false otherwisepublic CharSeq replaceFirst(java.lang.String regex, java.lang.String replacement)
An invocation of this method of the form
str.replaceFirst(
regex,
repl)
yields exactly the same result as the expression
Pattern
.compile
(regex).matcher
(str).replaceFirst
(repl)
Note that backslashes (\
) and dollar signs ($
) in the
replacement string may cause the results to be different than if it were
being treated as a literal replacement string; see
Matcher.replaceFirst(java.lang.String)
.
Use Matcher.quoteReplacement(java.lang.String)
to suppress the special
meaning of these characters, if desired.regex
- the regular expression to which this string is to be matchedreplacement
- the string to be substituted for the first matchCharSeq
java.util.regex.PatternSyntaxException
- if the regular expression's syntax is invalidPattern
public CharSeq replaceAll(java.lang.String regex, java.lang.String replacement)
An invocation of this method of the form
str.replaceAll(
regex,
repl)
yields exactly the same result as the expression
Pattern
.compile
(regex).matcher
(str).replaceAll
(repl)
Note that backslashes (\
) and dollar signs ($
) in the
replacement string may cause the results to be different than if it were
being treated as a literal replacement string; see
Matcher.replaceAll
.
Use Matcher.quoteReplacement(java.lang.String)
to suppress the special
meaning of these characters, if desired.regex
- the regular expression to which this string is to be matchedreplacement
- the string to be substituted for each matchCharSeq
java.util.regex.PatternSyntaxException
- if the regular expression's syntax is invalidPattern
public CharSeq replace(java.lang.CharSequence target, java.lang.CharSequence replacement)
target
- The sequence of char values to be replacedreplacement
- The replacement sequence of char valuespublic Seq<CharSeq> split(java.lang.String regex)
This method works as if by invoking the two-argument split(String, int)
method with the given expression and a limit argument of zero.
Trailing empty strings are therefore not included in the resulting Seq
.
The string "boo:and:foo"
, for example, yields the following results with these expressions:
Split examples showing regex and result Regex Result : { "boo", "and", "foo" }
o { "b", "", ":and:f" }
regex
- the delimiting regular expressionjava.util.regex.PatternSyntaxException
- if the regular expression's syntax is invalidPattern
public Seq<CharSeq> split(java.lang.String regex, int limit)
The array returned by this method contains each substring of this string that is terminated by another substring that matches the given expression or is terminated by the end of the string. The substrings in the array are in the order in which they occur in this string. If the expression does not match any part of the input then the resulting array has just one element, namely this string.
When there is a positive-width match at the beginning of this string then an empty leading substring is included at the beginning of the resulting array. A zero-width match at the beginning however never produces such empty leading substring.
The limit
parameter controls the number of times the
pattern is applied and therefore affects the length of the resulting
array. If the limit n is greater than zero then the pattern
will be applied at most n - 1 times, the array's
length will be no greater than n, and the array's last entry
will contain all input beyond the last matched delimiter. If n
is non-positive then the pattern will be applied as many times as
possible and the array can have any length. If n is zero then
the pattern will be applied as many times as possible, the array can
have any length, and trailing empty strings will be discarded.
The string "boo:and:foo"
, for example, yields the
following results with these parameters:
An invocation of this method of the form str.
Split example showing regex, limit, and result Regex Limit Result : 2 { "boo", "and:foo" }
: 5 { "boo", "and", "foo" }
: -2 { "boo", "and", "foo" }
o 5 { "b", "", ":and:f", "", "" }
o -2 { "b", "", ":and:f", "", "" }
o 0 { "b", "", ":and:f" }
split(
regex,
n)
yields the same result as the expression
Pattern
.compile
(regex).split
(str, n)
regex
- the delimiting regular expressionlimit
- the result threshold, as described abovejava.util.regex.PatternSyntaxException
- if the regular expression's syntax is invalidPattern
public CharSeq toLowerCase(java.util.Locale locale)
CharSeq
to lower
case using the rules of the given Locale
. Case mapping is based
on the Unicode Standard version specified by the Character
class. Since case mappings are not always 1:1 char mappings, the resulting
CharSeq
may be a different length than the original CharSeq
.
Examples of lowercase mappings are in the following table:
Language Code of Locale | Upper Case | Lower Case | Description |
---|---|---|---|
tr (Turkish) | \u0130 | \u0069 | capital letter I with dot above -> small letter i |
tr (Turkish) | \u0049 | \u0131 | capital letter I -> small letter dotless i |
(all) | French Fries | french fries | lowercased all chars in String |
(all) | ![]() ![]() ![]() ![]() ![]() |
![]() ![]() ![]() ![]() ![]() |
lowercased all chars in String |
locale
- use the case transformation rules for this localeCharSeq
, converted to lowercase.String.toLowerCase()
,
String.toUpperCase()
,
String.toUpperCase(Locale)
public CharSeq toLowerCase()
CharSeq
to lower
case using the rules of the default locale. This is equivalent to calling
toLowerCase(Locale.getDefault())
.
Note: This method is locale sensitive, and may produce unexpected
results if used for strings that are intended to be interpreted locale
independently.
Examples are programming language identifiers, protocol keys, and HTML
tags.
For instance, "TITLE".toLowerCase()
in a Turkish locale
returns "t\u0131tle"
, where '\u0131' is the
LATIN SMALL LETTER DOTLESS I character.
To obtain correct results for locale insensitive strings, use
toLowerCase(Locale.ROOT)
.
CharSeq
, converted to lowercase.String.toLowerCase(Locale)
public CharSeq toUpperCase(java.util.Locale locale)
CharSeq
to upper
case using the rules of the given Locale
. Case mapping is based
on the Unicode Standard version specified by the Character
class. Since case mappings are not always 1:1 char mappings, the resulting
CharSeq
may be a different length than the original CharSeq
.
Examples of locale-sensitive and 1:M case mappings are in the following table.
Language Code of Locale | Lower Case | Upper Case | Description |
---|---|---|---|
tr (Turkish) | \u0069 | \u0130 | small letter i -> capital letter I with dot above |
tr (Turkish) | \u0131 | \u0049 | small letter dotless i -> capital letter I |
(all) | \u00df | \u0053 \u0053 | small letter sharp s -> two letters: SS |
(all) | Fahrvergnügen | FAHRVERGNÜGEN |
locale
- use the case transformation rules for this localeCharSeq
, converted to uppercase.String.toUpperCase()
,
String.toLowerCase()
,
String.toLowerCase(Locale)
public CharSeq toUpperCase()
CharSeq
to upper
case using the rules of the default locale. This method is equivalent to
toUpperCase(Locale.getDefault())
.
Note: This method is locale sensitive, and may produce unexpected
results if used for strings that are intended to be interpreted locale
independently.
Examples are programming language identifiers, protocol keys, and HTML
tags.
For instance, "title".toUpperCase()
in a Turkish locale
returns "T\u0130TLE"
, where '\u0130' is the
LATIN CAPITAL LETTER I WITH DOT ABOVE character.
To obtain correct results for locale insensitive strings, use
toUpperCase(Locale.ROOT)
.
CharSeq
, converted to uppercase.String.toUpperCase(Locale)
public CharSeq capitalize(java.util.Locale locale)
CharSeq
to upper
case using the rules of the given Locale
. If the CharSeq
is
empty, it won't have any effect. Case mapping is based
on the Unicode Standard version specified by the Character
class. Since case mappings are not always 1:1 char mappings, the resulting
CharSeq
may be a different length than the original CharSeq
.
Examples of locale-sensitive and 1:M case mappings are in the following table.
Language Code of Locale | Lower Case | Upper Case | Description |
---|---|---|---|
tr (Turkish) | \u0069 | \u0130 | small letter i -> capital letter I with dot above |
tr (Turkish) | \u0131 | \u0049 | small letter dotless i -> capital letter I |
(all) | \u00df | \u0053 \u0053 | small letter sharp s -> two letters: SS |
(all) | Fahrvergnügen | FAHRVERGNÜGEN |
locale
- use the case transformation rules for this localeCharSeq
, capitalized.public CharSeq capitalize()
CharSeq
to upper
case using the rules of the default locale. If the CharSeq
is
empty, it won't have any effect. This method is equivalent to
capitalize(Locale.getDefault())
.
Note: This method is locale sensitive, and may produce unexpected
results if used for strings that are intended to be interpreted locale
independently.
Examples are programming language identifiers, protocol keys, and HTML
tags.
For instance, "title".toUpperCase()
in a Turkish locale
returns "T\u0130TLE"
, where '\u0130' is the
LATIN CAPITAL LETTER I WITH DOT ABOVE character.
To obtain correct results for locale insensitive strings, use
toUpperCase(Locale.ROOT)
.
CharSeq
, capitalized.public CharSeq trim()
If this CharSeq
object represents an empty character
sequence, or the first and last characters of character sequence
represented by this CharSeq
object both have codes
greater than '\u0020'
(the space character), then a
reference to this CharSeq
object is returned.
Otherwise, if there is no character with a code greater than
'\u0020'
in the string, then a
CharSeq
object representing an empty string is
returned.
Otherwise, let k be the index of the first character in the
string whose code is greater than '\u0020'
, and let
m be the index of the last character in the string whose code
is greater than '\u0020'
. A CharSeq
object is returned, representing the substring of this string that
begins with the character at index k and ends with the
character at index m-that is, the result of
this.substring(k, m + 1)
.
This method may be used to trim whitespace (as defined above) from the beginning and end of a string.
public char[] toCharArray()
public java.lang.Byte decodeByte()
CharSeq
into a Byte
by calling Byte.decode(String)
.
We write
Byte value = charSeq.decodeByte();
instead of
Byte value = Byte.decode(charSeq.mkString());
Byte
object holding the byte value represented by this CharSeq
java.lang.NumberFormatException
- if this CharSeq
does not contain a parsable byte.public java.lang.Integer decodeInteger()
CharSeq
into an Integer
by calling Integer.decode(String)
.
We write
Integer value = charSeq.decodeInteger();
instead of
Integer value = Integer.decode(charSeq.mkString());
Integer
object holding the int value represented by this CharSeq
java.lang.NumberFormatException
- if this CharSeq
does not contain a parsable int.public java.lang.Long decodeLong()
CharSeq
into a Long
by calling Long.decode(String)
.
We write
Long value = charSeq.decodeLong();
instead of
Long value = Long.decode(charSeq.mkString());
Long
object holding the long value represented by this CharSeq
java.lang.NumberFormatException
- if this CharSeq
does not contain a parsable long.public java.lang.Short decodeShort()
CharSeq
into a Short
by calling Short.decode(String)
.
We write
Short value = charSeq.decodeShort();
instead of
Short value = Short.decode(charSeq.mkString());
Short
object holding the short value represented by this CharSeq
java.lang.NumberFormatException
- if this CharSeq
does not contain a parsable short.public boolean parseBoolean()
CharSeq
as a boolean by calling Boolean.parseBoolean(String)
.
We write
boolean value = charSeq.parseBoolean();
instead of
boolean value = Boolean.parseBoolean(charSeq.mkString());
CharSeq
public byte parseByte()
CharSeq
as a signed decimal byte by calling Byte.parseByte(String)
.
We write
byte value = charSeq.parseByte();
instead of
byte value = Byte.parseByte(charSeq.mkString());
CharSeq
in decimaljava.lang.NumberFormatException
- If this CharSeq
does not contain a parsable byte.public byte parseByte(int radix)
CharSeq
as a signed byte in the specified radix
by calling Byte.parseByte(String, int)
.
We write
byte value = charSeq.parseByte(radix);
instead of
byte value = Byte.parseByte(charSeq.mkString(), radix);
radix
- the radix to be used in interpreting this CharSeq
CharSeq
in the specified radixjava.lang.NumberFormatException
- If this CharSeq
does not contain a parsable byte.public double parseDouble()
CharSeq
as a double by calling Double.parseDouble(String)
.
We write
double value = charSeq.parseDouble();
instead of
double value = Double.parseDouble(charSeq.mkString());
CharSeq
java.lang.NumberFormatException
- If this CharSeq
does not contain a parsable double.public float parseFloat()
CharSeq
as a float by calling Float.parseFloat(String)
.
We write
float value = charSeq.parseFloat();
instead of
float value = Double.parseFloat(charSeq.mkString());
CharSeq
java.lang.NumberFormatException
- If this CharSeq
does not contain a parsable float.public int parseInt()
CharSeq
as a signed decimal int by calling Integer.parseInt(String)
.
We write
int value = charSeq.parseInt();
instead of
int value = Integer.parseInt(charSeq.mkString());
CharSeq
in decimaljava.lang.NumberFormatException
- If this CharSeq
does not contain a parsable int.public int parseInt(int radix)
CharSeq
as a signed int in the specified radix
by calling Integer.parseInt(String, int)
.
We write
int value = charSeq.parseInt(radix);
instead of
int value = Integer.parseInt(charSeq.mkString(), radix);
radix
- the radix to be used in interpreting this CharSeq
CharSeq
in the specified radixjava.lang.NumberFormatException
- If this CharSeq
does not contain a parsable int.public int parseUnsignedInt()
CharSeq
as a unsigned decimal int by calling Integer.parseUnsignedInt(String)
.
We write
int value = charSeq.parseUnsignedInt();
instead of
int value = Integer.parseUnsignedInt(charSeq.mkString());
CharSeq
in decimaljava.lang.NumberFormatException
- If this CharSeq
does not contain a parsable unsigned int.public int parseUnsignedInt(int radix)
CharSeq
as a unsigned int in the specified radix
by calling Integer.parseUnsignedInt(String, int)
.
We write
int value = charSeq.parseUnsignedInt(radix);
instead of
int value = Integer.parseUnsignedInt(charSeq.mkString(), radix);
radix
- the radix to be used in interpreting this CharSeq
CharSeq
in the specified radixjava.lang.NumberFormatException
- If this CharSeq
does not contain a parsable unsigned int.public long parseLong()
CharSeq
as a signed decimal long by calling Long.parseLong(String)
.
We write
long value = charSeq.parseLong();
instead of
long value = Long.parseLong(charSeq.mkString());
CharSeq
in decimaljava.lang.NumberFormatException
- If this CharSeq
does not contain a parsable long.public long parseLong(int radix)
CharSeq
as a signed long in the specified radix
by calling Long.parseLong(String, int)
.
We write
long value = charSeq.parseLong(radix);
instead of
long value = Long.parseLong(charSeq.mkString(), radix);
radix
- the radix to be used in interpreting this CharSeq
CharSeq
in the specified radixjava.lang.NumberFormatException
- If this CharSeq
does not contain a parsable long.public long parseUnsignedLong()
CharSeq
as a unsigned decimal long by calling Long.parseUnsignedLong(String)
.
We write
long value = charSeq.parseUnsignedLong();
instead of
long value = Long.parseUnsignedLong(charSeq.mkString());
CharSeq
in decimaljava.lang.NumberFormatException
- If this CharSeq
does not contain a parsable unsigned long.public long parseUnsignedLong(int radix)
CharSeq
as a unsigned long in the specified radix
by calling Long.parseUnsignedLong(String, int)
.
We write
long value = charSeq.parseUnsignedLong(radix);
instead of
long value = Long.parseUnsignedLong(charSeq.mkString(), radix);
radix
- the radix to be used in interpreting this CharSeq
CharSeq
in the specified radixjava.lang.NumberFormatException
- If this CharSeq
does not contain a parsable unsigned long.public short parseShort()
CharSeq
as a signed decimal short by calling Short.parseShort(String)
.
We write
short value = charSeq.parseShort();
instead of
short value = Short.parseShort(charSeq.mkString());
CharSeq
in decimaljava.lang.NumberFormatException
- If this CharSeq
does not contain a parsable short.public short parseShort(int radix)
CharSeq
as a signed short in the specified radix
by calling Short.parseShort(String, int)
.
We write
short value = charSeq.parseShort(radix);
instead of
short value = Short.parseShort(charSeq.mkString(), radix);
radix
- the radix to be used in interpreting this CharSeq
CharSeq
in the specified radixjava.lang.NumberFormatException
- If this CharSeq
does not contain a parsable short.public java.lang.Boolean toBoolean()
CharSeq
to a Boolean
by calling Boolean.valueOf(String)
.
We write
Boolean value = charSeq.toBoolean();
instead of
Boolean value = Boolean.valueOf(charSeq.mkString());
Boolean
value represented by this CharSeq
public java.lang.Byte toByte()
CharSeq
to a Byte
by calling Byte.valueOf(String)
.
We write
Byte value = charSeq.toByte();
instead of
Byte value = Byte.valueOf(charSeq.mkString());
Byte
object holding the value represented by this CharSeq
java.lang.NumberFormatException
- If this CharSeq
does not contain a parsable byte.public java.lang.Byte toByte(int radix)
CharSeq
to a Byte
in the specified radix
by calling Byte.valueOf(String, int)
.
We write
Byte value = charSeq.toByte(radix);
instead of
Byte value = Byte.valueOf(charSeq.mkString(), radix);
radix
- the radix to be used in interpreting this char sequenceByte
object holding the value represented by this CharSeq
java.lang.NumberFormatException
- If this CharSeq
does not contain a parsable byte.public java.lang.Double toDouble()
CharSeq
to a Double
by calling Double.valueOf(String)
.
We write
Double value = charSeq.toDouble();
instead of
Double value = Double.valueOf(charSeq.mkString());
Double
object holding the value represented by this CharSeq
java.lang.NumberFormatException
- If this CharSeq
does not contain a parsable double.public java.lang.Float toFloat()
CharSeq
to a Float
by calling Float.valueOf(String)
.
We write
Float value = charSeq.toFloat();
instead of
Float value = Float.valueOf(charSeq.mkString());
Float
object holding the value represented by this CharSeq
java.lang.NumberFormatException
- If this CharSeq
does not contain a parsable float.public java.lang.Integer toInteger()
CharSeq
to an Integer
by calling Integer.valueOf(String)
.
We write
Integer value = charSeq.toInteger();
instead of
Integer value = Integer.valueOf(charSeq.mkString());
Integer
object holding the value represented by this CharSeq
java.lang.NumberFormatException
- If this CharSeq
does not contain a parsable int.public java.lang.Integer toInteger(int radix)
CharSeq
to an Integer
in the specified radix
by calling Integer.valueOf(String, int)
.
We write
Integer value = charSeq.toInteger(radix);
instead of
Integer value = Integer.valueOf(charSeq.mkString(), radix);
radix
- the radix to be used in interpreting this char sequenceInteger
object holding the value represented by this CharSeq
java.lang.NumberFormatException
- If this CharSeq
does not contain a parsable int.public java.lang.Long toLong()
CharSeq
to a Long
by calling Long.valueOf(String)
.
We write
Long value = charSeq.toLong();
instead of
Long value = Long.valueOf(charSeq.mkString());
Long
object holding the value represented by this CharSeq
java.lang.NumberFormatException
- If this CharSeq
does not contain a parsable long.public java.lang.Long toLong(int radix)
CharSeq
to a Long
in the specified radix
by calling Long.valueOf(String, int)
.
We write
Long value = charSeq.toLong(radix);
instead of
Long value = Long.valueOf(charSeq.mkString(), radix);
radix
- the radix to be used in interpreting this char sequenceLong
object holding the value represented by this CharSeq
java.lang.NumberFormatException
- If this CharSeq
does not contain a parsable long.public java.lang.Short toShort()
CharSeq
to a Short
by calling Short.valueOf(String)
.
We write
Short value = charSeq.toShort();
instead of
Short value = Short.valueOf(charSeq.mkString());
Short
object holding the value represented by this CharSeq
java.lang.NumberFormatException
- If this CharSeq
does not contain a parsable short.public java.lang.Short toShort(int radix)
CharSeq
to a Short
in the specified radix
by calling Short.valueOf(String, int)
.
We write
Short value = charSeq.toShort(radix);
instead of
Short value = Short.valueOf(charSeq.mkString(), radix);
radix
- the radix to be used in interpreting this char sequenceShort
object holding the value represented by this CharSeq
java.lang.NumberFormatException
- If this CharSeq
does not contain a parsable short.public java.lang.Character[] toJavaArray()
Value
Object
// = [] of type Object[]
Future.<String> of(() -> { throw new Error(); })
.toJavaArray()
// = [ok] of type Object[]
Try.of(() -> "ok")
.toJavaArray()
// = [1, 2, 3] of type Object[]
List.of(1, 2, 3)
.toJavaArray()
toJavaArray
in interface Value<java.lang.Character>