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, streamclone, finalize, getClass, notify, notifyAll, wait, wait, waitchars, codePointsappend, append, copy, empty, map, of, of, of, prepend, prepend, subSeq, subSeq, toISeqasList, equals, forAll, get, hashCode, indexOf, indexOf, indexOf, indexWhere, indexWhere, indexWhere, isSorted, isSorted, iterator, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexWhere, lastIndexWhere, lastIndexWhere, listIterator, parallelStream, size, spliterator, stream, toArray, toArray, toSeq, toString, toStringpublic 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)
Seqtrue 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 CharSequencepublic int length()
Seqpublic CharSeq subSequence(int start, int end)
subSequence in interface CharSequencepublic 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)
Seqequals 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 CharSequencetoString 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-2016 Franz Wilhelmstötter (2016-04-24 10:25)