public final class CharPair extends java.lang.Object implements java.io.Serializable, CharIndexable
This is similar to Pair
, but for raw char
values.
As these values are defined final, this class is also immutable.
CharIndexable.Base
Modifier and Type | Field and Description |
---|---|
char |
first
The first value of this pair.
|
char |
second
The second value of this pair.
|
EMPTY
EMPTY_CHAR_ITERATOR
Constructor and Description |
---|
CharPair(char first,
char second)
Constructor.
|
CharPair(java.lang.String pair)
Create a character pair from a 2-character string.
|
Modifier and Type | Method and Description |
---|---|
<T> T |
applyAsChars(CharFunction2<T> function)
Apply a 2-character function on this pair.
|
boolean |
equals(java.lang.Object o) |
char |
get(int index)
Get the element at the given index.
|
int |
hashCode() |
char |
operate(CharOperator2 operator)
Call an 2-character operator on this pair.
|
int |
size()
Get the size.
|
CharPair |
swapped()
Get this pair with swapped values.
|
boolean |
test(CharPredicate2 predicate)
Call a 2-character predicate on this pair.
|
IntPair |
toIntPair()
Convert this char pair into an integer pair.
|
java.lang.String |
toString() |
Tuple2<java.lang.Character,java.lang.Character> |
toTuple()
Convert this into a tuple.
|
CharPair |
withFirst(char first)
Get this pair with a different first value.
|
CharPair |
withSecond(char second)
Get this pair with a different first value.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addAllTo, addToArray, addToArray, addToArray, addToArray, asBase, asCharSequence, asCollection, asIndexable, asIntIndexable, asList, binarySearch, binarySearch, charIterator, charIterator, compare, emptyIndexable, equal, equal, firstMatch, foldLeft, frozen, getMod, gyt, hash, headSet, indexes, init, initByIndex, intIndexes, intIterator, isEmpty, isOrdered, isOrdered, isStrictlyOrdered, isStrictlyOrdered, iterator, lastMatch, listIterator, makeString, nextMatch, ordered, previousMatch, reverse, rotated, singleton, subSet, sybSet, tailSet, toArray, toIntArray, toList, toString, toText, view, viewArray, viewArray, viewArray, viewAsBoolean, viewAsCharSequence, viewByIndex, viewChars, viewIndexable, viewIndexable, viewIndexable, viewList, viewList, viewList, viewOp, viewString, withAppendedValue, withExchangedValueAt, withInsertedValueAt, withRemovedValueAt, withSwappedValuesAt
asIntIterable, asLongIterable, containsChar, forEachChar, forEachCharFragile
public final char first
public final char second
public CharPair(char first, char second)
first
- first value of pairsecond
- second value of pairpublic CharPair(@NotNull java.lang.String pair)
pair
- string with 2 charactersjava.lang.IllegalArgumentException
- if string does not have 2 characters@NotNull public IntPair toIntPair()
@NotNull public CharPair withFirst(char first)
first
- new first valuefirst
value,
and the second
value of this pair@NotNull public CharPair withSecond(char second)
second
- new second valuefirst
value of this pair,
and the given second
valuepublic int size()
Sizeable
public char get(int index)
CharIndexable
get
in interface CharIndexable
index
- index between 0
and size() - 1
public <T> T applyAsChars(@NotNull CharFunction2<T> function)
public char operate(@NotNull CharOperator2 operator)
public boolean test(@NotNull CharPredicate2 predicate)
@NotNull public Tuple2<java.lang.Character,java.lang.Character> toTuple()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
@NotNull public java.lang.String toString()
toString
in class java.lang.Object