public final class CharSeq extends ArrayISeq<Character> implements CharSequence, ISeq<Character>, Comparable<CharSeq>, Serializable
CharacterGene
. It is not a character sequence in the
classical sense. The characters of this sequence are sorted and doesn't
contain duplicate values, like a set.
final CharSeq cs1 = new CharSeq("abcdeaafg");
final CharSeq cs2 = new CharSeq("gfedcbabb");
assert(cs1.equals(cs2));
Constructor and Description |
---|
CharSeq(char[] characters)
Create a new (distinct) CharSeq from the given
characters . |
CharSeq(CharSequence characters)
Create a new (distinct) CharSeq from the given
characters . |
Modifier and Type | Method and Description |
---|---|
char |
charAt(int index) |
int |
compareTo(CharSeq set) |
boolean |
contains(char c)
Test whether this character set contains the given character
c . |
boolean |
contains(Character c)
Test whether this character set contains the given character
c . |
boolean |
contains(Object object)
Returns
true if this sequence contains the specified element. |
boolean |
equals(Object obj)
Compares the specified object with this sequence for equality.
|
static String |
expand(char a,
char b)
Expands the characters between
a and b . |
static String |
expand(CharSequence pattern)
Expands the character range for the given
pattern . |
int |
hashCode()
Returns the hash code value for this sequence.
|
boolean |
isEmpty()
Test whether this character set is empty.
|
int |
length()
Return the length of this sequence.
|
static CharSeq |
of(char a,
char b)
Expands the characters between
a and b . |
static CharSeq |
of(CharSequence pattern)
Expands the character range for the given
pattern . |
CharSeq |
subSequence(int start,
int end) |
static Collector<Character,?,CharSeq> |
toCharSeq() |
static ISeq<Character> |
toISeq(CharSequence chars)
Helper method for creating a sequence of characters from the given
CharSequence . |
String |
toString() |
forAll, forEach, get, indexWhere, iterator, lastIndexWhere, listIterator, parallelStream, spliterator, stream
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
chars, codePoints
append, append, concat, concat, concat, copy, empty, map, of, of, of, prepend, prepend, subSeq, subSeq, toISeq, toISeq, upcast
apply, asISeq, asList, asMSeq, concat, concat, concat, equals, forAll, get, hashCode, indexOf, indexOf, indexOf, indexWhere, indexWhere, indexWhere, isSorted, isSorted, iterator, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexWhere, lastIndexWhere, lastIndexWhere, listIterator, nonEmpty, parallelStream, size, spliterator, stream, toArray, toArray, toArray, toSeq, toSeq, toString, toString, viewOf, viewOf
public CharSeq(char[] characters)
characters
. The
given CharSequence
is sorted and duplicate values are removedcharacters
- the characters.NullPointerException
- if the characters
are null
.CharSeq(CharSequence)
public CharSeq(CharSequence characters)
characters
. The
given CharSequence
is sorted and duplicate values are removed.characters
- the characters.NullPointerException
- if the characters
are null
.public boolean contains(Object object)
Seq
true
if this sequence contains the specified element.public boolean contains(Character c)
c
.c
- the character to test.true
if this character set contains the given character,
false
otherwise.NullPointerException
- if the given character c
is
null
.public boolean contains(char c)
c
.c
- the character to test.true
if this character set contains the given character,
false
otherwise.public char charAt(int index)
charAt
in interface CharSequence
public int length()
Seq
public CharSeq subSequence(int start, int end)
subSequence
in interface CharSequence
public boolean isEmpty()
public int hashCode()
Seq
int hashCode = 1;
final Iterator<E> it = seq.iterator();
while (it.hasNext()) {
final E obj = it.next();
hashCode = 31*hashCode + (obj == null ? 0 : obj.hashCode());
}
hashCode
in interface Seq<Character>
hashCode
in class ArraySeq<Character>
List.hashCode()
,
Seq.hashCode(Seq)
public boolean equals(Object obj)
Seq
equals
in interface Seq<Character>
equals
in class ArraySeq<Character>
obj
- the object to be compared for equality with this sequence.true
if the specified object is equal to this sequence,
false
otherwise.List.equals(Object)
,
Seq.equals(Seq, Object)
public int compareTo(CharSeq set)
compareTo
in interface Comparable<CharSeq>
public String toString()
toString
in interface CharSequence
toString
in class ArraySeq<Character>
public static String expand(CharSequence pattern)
pattern
. E.g
a-zA-Z0-1
will return a string containing all upper and lower
case characters (from a to z) and all digits form 0 to 9.pattern
- the pattern
to expand.PatternSyntaxException
- if the pattern could not be expanded.NullPointerException
- if the pattern is null
.public static String expand(char a, char b)
a
and b
.a
- the start character.b
- the stop character.public static CharSeq of(CharSequence pattern)
pattern
. E.g.
a-zA-Z0-1
will return a string containing all upper and lower
case characters (from a to z) and all digits form 0 to 9.pattern
- the pattern
to expand.PatternSyntaxException
- if the pattern could not be expanded.NullPointerException
- if the pattern is null
.expand(CharSequence)
public static CharSeq of(char a, char b)
a
and b
.a
- the start character.b
- the stop character.expand(char, char)
public static ISeq<Character> toISeq(CharSequence chars)
CharSequence
. The returned sequence will contain all characters
in the original order.chars
- the char sequence to convert.© 2007-2019 Franz Wilhelmstötter (2019-11-18 20:30)