- All Superinterfaces:
BaseSeq<T>,Copyable<MSeq<T>>,IntFunction<T>,Iterable<T>,RandomAccess,Seq<T>
- Since:
- 1.0
- Version:
- 5.2
- See Also:
- Implementation Note:
- This implementation is not thread safe. All
ISeqandMSeqinstances created bytoISeq()andsubSeq(int), respectively, must be protected by the same lock, when they are accessed (get/set) by different threads.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionReturn a newSeqwith the givenvaluesappended.Return a newSeqwith the givenvaluesappended.asList()Returns a fixed-size list backed by the specified sequence.static <T> MSeq<T> Return a sequence whose elements are all the elements of the first sequence followed by all the elements of the second sequence.static <T> MSeq<T> Return a sequence whose elements are all the elements of the first sequence followed by all the elements of the vararg array.static <T> MSeq<T> Return a sequence whose elements are all the elements of the first element followed by all the elements of the sequence.static <T> MSeq<T> empty()Return an emptyMSeq.Fill the sequence with values generated by the given factory.default ListIterator<T> Returns a list iterator over the elements in this sequence (in a proper sequence).<B> MSeq<B> Builds a new sequence by applying a function to all elements of this sequence.static <T> MSeq<T> Create a newMSeqfrom the values of the givenSeq.static <T> MSeq<T> Create a newMSeqfrom the given values.static <T> MSeq<T> Creates a new sequence, which is filled with objects created be the givensupplier.static <T> MSeq<T> of(T... values) Create a newMSeqfrom the given values.static <T> MSeq<T> ofLength(int length) Create a newMSeqwith the givenlength.Return a newSeqwith the givenvaluesprepended.Return a newSeqwith the givenvaluesprepended.reverse()Reverses the order of the elements this sequence (in place).voidSet thevalueat the givenindex.Fills the sequence with values of the given iterable.Fills the sequence with values of the given iterator.Fill the sequence with the given values.shuffle()Randomize thearrayusing theRandomGeneratorobject currently registered in theRandomRegistryclass.shuffle(RandomGenerator random) Randomize thearrayusing the givenRandomGeneratorobject.sort()Sorts this sequence according to the natural order of the elements.sort(int start) Sorts this sequence according to the natural order of the elements.sort(int start, int end) Sorts this sequence according to the natural order of the elements.sort(int start, int end, Comparator<? super T> comparator) Sorts this sequence according to the order induced by the specifiedComparator.sort(int start, Comparator<? super T> comparator) Sorts this sequence according to the order induced by the specifiedComparator.sort(Comparator<? super T> comparator) Sorts this sequence according to the order induced by the specifiedComparator.subSeq(int start) Returns a view of the portion of this sequence between the specifiedstart, inclusive, andend, exclusive.subSeq(int start, int end) Returns a view of the portion of this sequence between the specifiedstart, inclusive, andend, exclusive.default voidswap(int i, int j) Swap the elements at the two positions.default voidSwap a given range with a range of the same size with another array.default voidSwap the elements at the same position.toISeq()Return a read-only projection of this sequence.toMSeq()Returns aCollectorthat accumulates the input elements into a newMSeq.Methods inherited from interface io.jenetics.util.BaseSeq
forEach, get, isEmpty, iterator, length, nonEmpty, spliterator, streamMethods inherited from interface io.jenetics.util.Seq
apply, asISeq, asMSeq, contains, equals, forAll, hashCode, indexOf, indexOf, indexOf, indexWhere, indexWhere, indexWhere, isSorted, isSorted, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexWhere, lastIndexWhere, lastIndexWhere, parallelStream, size, toArray, toArray, toArray, toString, toString
-
Field Details
-
EMPTY
Single instance of an emptyMSeq.
-
-
Method Details
-
asList
Description copied from interface:SeqReturns a fixed-size list backed by the specified sequence. (Changes to the returned list "write through" to the array.) The returned list is fixed size, serializable and implementsRandomAccess. -
set
Set thevalueat the givenindex.- Parameters:
index- the index of the new value.value- the new value.- Throws:
IndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size()).
-
setAll
Fills the sequence with values of the given iterator.- Parameters:
it- the iterator of the values to fill this sequence.- Returns:
thissequence.
-
setAll
Fills the sequence with values of the given iterable.- Parameters:
values- the values to fill this sequence.- Returns:
thissequence.
-
setAll
Fill the sequence with the given values.- Parameters:
values- the first initial values of this sequence- Returns:
thissequence.
-
fill
Fill the sequence with values generated by the given factory.- Parameters:
supplier- the value factory.- Returns:
thissequence.- Throws:
NullPointerException- if the givenfactoryisnull.
-
swap
Swap the elements at the two positions.- Parameters:
i- the index of the first element.j- the index of the second element.- Throws:
IndexOutOfBoundsException- ifi < 0 || j >= length().
-
swap
Swap a given range with a range of the same size with another array.start end | | this: +---+---+---+---+---+---+---+---+---+---+---+---+ +---------------+ +---------------+ other: +---+---+---+---+---+---+---+---+---+---+---+---+ | otherStart- Parameters:
start- the start index ofthisrange, inclusively.end- the end index ofthisrange, exclusively.other- the other array to swap the elements with.otherStart- the start index of theotherarray.- Throws:
IndexOutOfBoundsException- ifstart > endor ifstart < 0 || end >= this.length() || otherStart < 0 || otherStart + (end - start) >= other.length()
-
swap
Swap the elements at the same position.- Parameters:
index- the index of swapped element.other- the other array to swap the elements with.- Throws:
IndexOutOfBoundsException- ifindex < 0 || index >= this.length() || index >= other.length().NullPointerException- if theothersequence isnull- Since:
- 4.0
-
shuffle
Randomize thearrayusing theRandomGeneratorobject currently registered in theRandomRegistryclass. The used shuffling algorithm is from D. Knuth TAOCP, Seminumerical Algorithms, Third edition, page 142, Algorithm S (Selection sampling technique).- Returns:
- this shuffled sequence
-
shuffle
Randomize thearrayusing the givenRandomGeneratorobject. The used shuffling algorithm is from D. Knuth TAOCP, Seminumerical Algorithms, Third edition, page 142, Algorithm S (Selection sampling technique).- Parameters:
random- theRandomGeneratorobject to use for randomize.- Returns:
- this shuffled sequence
- Throws:
NullPointerException- if the random object isnull.
-
sort
Sorts this sequence according to the order induced by the specifiedComparator.All elements in this sequence must be mutually comparable using the specified comparator (that is,
c.compare(e1, e2)must not throw aClassCastExceptionfor any elementse1ande2in the sequence).If the specified comparator is
nullthen all elements in this list must implement theComparableinterface and the elements' Comparable natural ordering should be used.- Parameters:
start- the start index where to start sorting (inclusively)end- the end index where to stop sorting (exclusively)comparator- theComparatorused to compare sequence elements. Anullvalue indicates that the elements' Comparable natural ordering should be used- Returns:
thissequence- Throws:
ClassCastException- if the sequence contains elements that are not mutually comparable using the specified comparator
-
sort
Sorts this sequence according to the natural order of the elements.- Parameters:
start- the start index where to start sorting (inclusively)end- the end index where to stop sorting (exclusively)- Returns:
thissequence- Throws:
ClassCastException- if the sequence contains elements that are not mutually comparable using the specified comparator
-
sort
Sorts this sequence according to the order induced by the specifiedComparator.All elements in this sequence must be mutually comparable using the specified comparator (that is,
c.compare(e1, e2)must not throw aClassCastExceptionfor any elementse1ande2in the sequence).If the specified comparator is
nullthen all elements in this list must implement theComparableinterface and the elements' Comparable natural ordering should be used.- Parameters:
start- the start index where to start sorting (inclusively)comparator- theComparatorused to compare sequence elements. Anullvalue indicates that the elements' Comparable natural ordering should be used- Returns:
thissequence- Throws:
ClassCastException- if the sequence contains elements that are not mutually comparable using the specified comparator
-
sort
Sorts this sequence according to the natural order of the elements.- Parameters:
start- the start index where to start sorting (inclusively)- Returns:
thissequence- Throws:
ClassCastException- if the sequence contains elements that are not mutually comparable using the specified comparator
-
sort
Sorts this sequence according to the order induced by the specifiedComparator.All elements in this sequence must be mutually comparable using the specified comparator (that is,
c.compare(e1, e2)must not throw aClassCastExceptionfor any elementse1ande2in the sequence).If the specified comparator is
nullthen all elements in this list must implement theComparableinterface and the elements' Comparable natural ordering should be used.- Parameters:
comparator- theComparatorused to compare sequence elements. Anullvalue indicates that the elements' Comparable natural ordering should be used- Returns:
thissequence- Throws:
ClassCastException- if the sequence contains elements that are not mutually comparable using the specified comparator
-
sort
Sorts this sequence according to the natural order of the elements.- Returns:
thissequence- Throws:
ClassCastException- if the sequence contains elements that are not mutually comparable using the specified comparator
-
reverse
Reverses the order of the elements this sequence (in place).- Returns:
- this sequence with reverse order or the elements
-
listIterator
Returns a list iterator over the elements in this sequence (in a proper sequence).- Specified by:
listIteratorin interfaceBaseSeq<T>- Returns:
- a list iterator over the elements in this list (in a proper sequence)
-
subSeq
Description copied from interface:SeqReturns a view of the portion of this sequence between the specifiedstart, inclusive, andend, exclusive. (Ifstartandendare equal, the returned sequence has length zero.) The returned sequence is backed by this sequence, so non-structural changes in the returned sequence are reflected in this array, and vice versa.This method eliminates the need for explicit range operations (of the populationSort that commonly exist for arrays). Any operation that expects an array can be used as a range operation by passing a subsequence view instead of a whole sequence.
-
subSeq
Description copied from interface:SeqReturns a view of the portion of this sequence between the specifiedstart, inclusive, andend, exclusive. (Ifstartandendare equal, the returned sequence has length zero.) The returned sequence is backed by this sequence, so non-structural changes in the returned sequence are reflected in this sequence, and vice versa.This method eliminates the need for explicit range operations (of the populationSort that commonly exist for arrays). Any operation that expects a sequence can be used as a range operation by passing a subsequence view instead of a whole sequence.
-
map
Description copied from interface:SeqBuilds a new sequence by applying a function to all elements of this sequence.- Specified by:
mapin interfaceSeq<T>- Type Parameters:
B- the element type of the returned collection.- Parameters:
mapper- the function to apply to each element.- Returns:
- a new sequence of type That resulting from applying the given function f to each element of this sequence and collecting the results.
-
append
Description copied from interface:SeqReturn a newSeqwith the givenvaluesappended. -
append
Description copied from interface:SeqReturn a newSeqwith the givenvaluesappended. -
prepend
Description copied from interface:SeqReturn a newSeqwith the givenvaluesprepended. -
prepend
Description copied from interface:SeqReturn a newSeqwith the givenvaluesprepended. -
toISeq
Return a read-only projection of this sequence. Changes to the original sequence will not influence the returnedISeq.- Returns:
- a read-only projection of this sequence
-
concat
Return a sequence whose elements are all the elements of the first element followed by all the elements of the sequence.- Type Parameters:
T- the type of the sequence elements- Parameters:
a- the first elementb- the appending sequence- Returns:
- the concatenation of the two inputs
- Throws:
NullPointerException- if one of the second arguments isnull- Since:
- 5.0
-
concat
Return a sequence whose elements are all the elements of the first sequence followed by all the elements of the vararg array.- Type Parameters:
T- the type of the sequence elements- Parameters:
a- the first sequenceb- the vararg elements- Returns:
- the concatenation of the two inputs
- Throws:
NullPointerException- if one of the arguments isnull- Since:
- 5.0
-
concat
Return a sequence whose elements are all the elements of the first sequence followed by all the elements of the second sequence.- Type Parameters:
T- the type of the sequence elements- Parameters:
a- the first sequenceb- the second sequence- Returns:
- the concatenation of the two input sequences
- Throws:
NullPointerException- if one of the arguments isnull- Since:
- 5.0
-
empty
Return an emptyMSeq.- Type Parameters:
T- the element type of the returnedMSeq.- Returns:
- an empty
MSeq.
-
toMSeq
Returns aCollectorthat accumulates the input elements into a newMSeq.- Type Parameters:
T- the type of the input elements- Returns:
- a
Collectorwhich collects all the input elements into aMSeq, in encounter order
-
ofLength
Create a newMSeqwith the givenlength.- Type Parameters:
T- the element type of the newMSeq.- Parameters:
length- the length of the createdMSeq.- Returns:
- the new mutable sequence.
- Throws:
NegativeArraySizeException- if the givenlengthis negative
-
of
Create a newMSeqfrom the given values.- Type Parameters:
T- the element type- Parameters:
values- the array values.- Returns:
- a new
Meqwith the given values. - Throws:
NullPointerException- if thevaluesarray isnull.
-
of
Create a newMSeqfrom the given values.- Type Parameters:
T- the element type- Parameters:
values- the array values.- Returns:
- a new
MSeqwith the given values. - Throws:
NullPointerException- if thevaluesobject isnull.
-
of
Creates a new sequence, which is filled with objects created be the givensupplier.- Type Parameters:
T- the element type of the sequence- Parameters:
supplier- theSupplierwhich creates the elements, the returned sequence is filled withlength- the length of the returned sequence- Returns:
- a new sequence filled with elements given by the
supplier - Throws:
NegativeArraySizeException- if the givenlengthis negativeNullPointerException- if the givensupplierisnull- Since:
- 3.3
-
of
Create a newMSeqfrom the values of the givenSeq.- Type Parameters:
T- the element type- Parameters:
values- the array values.- Returns:
- a new
MSeqwith the given values - Throws:
NullPointerException- if thevaluesarray isnull.
-