Package io.jenetics.util
Class CharSeq
- java.lang.Object
-
- ArraySeq<T>
-
- ArrayISeq<Character>
-
- io.jenetics.util.CharSeq
-
- All Implemented Interfaces:
BaseSeq<Character>,Copyable<MSeq<Character>>,ISeq<Character>,Seq<Character>,Serializable,CharSequence,Comparable<CharSeq>,Iterable<Character>,IntFunction<Character>,RandomAccess
public final class CharSeq extends ArrayISeq<Character> implements CharSequence, ISeq<Character>, Comparable<CharSeq>, Serializable
This class is used for holding the valid characters of anCharacterGene. 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));- Since:
- 1.0
- Version:
- 2.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CharSeq(char[] characters)Create a new (distinct) CharSeq from the givencharacters.CharSeq(CharSequence characters)Create a new (distinct) CharSeq from the givencharacters.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description charcharAt(int index)intcompareTo(CharSeq set)booleancontains(char c)Test whether this character set contains the given characterc.booleancontains(Character c)Test whether this character set contains the given characterc.booleancontains(Object object)Returnstrueif this sequence contains the specified element.booleanequals(Object obj)Compares the specified object with this sequence for equality.static Stringexpand(char a, char b)Expands the characters betweenaandb.static Stringexpand(CharSequence pattern)Expands the character range for the givenpattern.inthashCode()Returns the hash code value for this sequence.booleanisEmpty()Test whether this character set is empty.intlength()Return the length of this sequence.static CharSeqof(char a, char b)Expands the characters betweenaandb.static CharSeqof(CharSequence pattern)Expands the character range for the givenpattern.CharSeqsubSequence(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 givenCharSequence.StringtoString()-
Methods inherited from class io.jenetics.internal.collection.ArrayISeq
append, copy, map, prepend, subSeq, subSeq
-
Methods inherited from class io.jenetics.internal.collection.ArraySeq
forAll, forEach, get, indexWhere, lastIndexWhere
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.jenetics.util.BaseSeq
get, iterator, listIterator, nonEmpty, spliterator, stream
-
Methods inherited from interface java.lang.CharSequence
chars, codePoints
-
Methods inherited from interface io.jenetics.util.ISeq
append, append, copy, map, prepend, prepend, subSeq, subSeq
-
Methods inherited from interface io.jenetics.util.Seq
apply, asISeq, asList, asMSeq, forAll, indexOf, indexOf, indexOf, indexWhere, indexWhere, indexWhere, isSorted, isSorted, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexWhere, lastIndexWhere, lastIndexWhere, parallelStream, size, toArray, toArray, toArray, toString, toString
-
-
-
-
Constructor Detail
-
CharSeq
public CharSeq(char[] characters)
Create a new (distinct) CharSeq from the givencharacters. The givenCharSequenceis sorted and duplicate values are removed- Parameters:
characters- the characters.- Throws:
NullPointerException- if thecharactersarenull.- See Also:
CharSeq(CharSequence)
-
CharSeq
public CharSeq(CharSequence characters)
Create a new (distinct) CharSeq from the givencharacters. The givenCharSequenceis sorted and duplicate values are removed.- Parameters:
characters- the characters.- Throws:
NullPointerException- if thecharactersarenull.
-
-
Method Detail
-
contains
public boolean contains(Object object)
Description copied from interface:SeqReturnstrueif this sequence contains the specified element.
-
contains
public boolean contains(Character c)
Test whether this character set contains the given characterc.- Parameters:
c- the character to test.- Returns:
trueif this character set contains the given character,falseotherwise.- Throws:
NullPointerException- if the given charactercisnull.
-
contains
public boolean contains(char c)
Test whether this character set contains the given characterc.- Parameters:
c- the character to test.- Returns:
trueif this character set contains the given character,falseotherwise.
-
charAt
public char charAt(int index)
- Specified by:
charAtin interfaceCharSequence
-
length
public int length()
Description copied from interface:BaseSeqReturn the length of this sequence. Once the sequence is created, the length can't be changed.
-
subSequence
public CharSeq subSequence(int start, int end)
- Specified by:
subSequencein interfaceCharSequence
-
isEmpty
public boolean isEmpty()
Test whether this character set is empty.
-
hashCode
public int hashCode()
Description copied from interface:SeqReturns the hash code value for this sequence. The hash code is defined as followed: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()); }- Specified by:
hashCodein interfaceSeq<Character>- Overrides:
hashCodein classArraySeq<Character>- Returns:
- the hash code value for this list
- See Also:
List.hashCode(),Seq.hashCode(BaseSeq)
-
equals
public boolean equals(Object obj)
Description copied from interface:SeqCompares the specified object with this sequence for equality. Returns true if and only if the specified object is also a sequence, both sequence have the same size, and all corresponding pairs of elements in the two sequences are equal. (Two elements e1 and e2 are equal if (e1==null ? e2==null : e1.equals(e2)).) This definition ensures that the equals method works properly across different implementations of the Seq interface.- Specified by:
equalsin interfaceSeq<Character>- Overrides:
equalsin classArraySeq<Character>- Parameters:
obj- the object to be compared for equality with this sequence.- Returns:
trueif the specified object is equal to this sequence,falseotherwise.- See Also:
List.equals(Object),Seq.equals(BaseSeq, Object)
-
compareTo
public int compareTo(CharSeq set)
- Specified by:
compareToin interfaceComparable<CharSeq>
-
toString
public String toString()
- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin classArraySeq<Character>
-
expand
public static String expand(CharSequence pattern)
Expands the character range for the givenpattern. E.ga-zA-Z0-1will return a string containing all upper and lower case characters (from a to z) and all digits form 0 to 9.- Parameters:
pattern- thepatternto expand.- Returns:
- the expanded pattern.
- Throws:
PatternSyntaxException- if the pattern could not be expanded.NullPointerException- if the pattern isnull.
-
expand
public static String expand(char a, char b)
Expands the characters betweenaandb.- Parameters:
a- the start character.b- the stop character.- Returns:
- the expanded characters.
-
of
public static CharSeq of(CharSequence pattern)
Expands the character range for the givenpattern. E.g.a-zA-Z0-1will return a string containing all upper and lower case characters (from a to z) and all digits form 0 to 9.- Parameters:
pattern- thepatternto expand.- Returns:
- the expanded pattern.
- Throws:
PatternSyntaxException- if the pattern could not be expanded.NullPointerException- if the pattern isnull.- See Also:
expand(CharSequence)
-
of
public static CharSeq of(char a, char b)
Expands the characters betweenaandb.- Parameters:
a- the start character.b- the stop character.- Returns:
- the expanded characters.
- See Also:
expand(char, char)
-
toISeq
public static ISeq<Character> toISeq(CharSequence chars)
Helper method for creating a sequence of characters from the givenCharSequence. The returned sequence will contain all characters in the original order.- Parameters:
chars- the char sequence to convert.- Returns:
- a sequence which will contain all given chars in the original order.
-
-