- All Superinterfaces:
BaseSeq<T>
,Copyable<MSeq<T>>
,IntFunction<T>
,Iterable<T>
,RandomAccess
,Seq<T>
- All Known Implementing Classes:
ArrayMSeq
,Empty.EmptyMSeq
- Since:
- 1.0
- Version:
- 5.2
- See Also:
- Implementation Note:
- This implementation is not thread safe. All
ISeq
andMSeq
instances created bytoISeq()
andsubSeq(int)
, respectively, must be protected by the same lock, when they are accessed (get/set) by different threads.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturn a newSeq
with the givenvalues
appended.Return a newSeq
with the givenvalues
appended.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 newMSeq
from the values of the givenSeq
.static <T> MSeq<T>
Create a newMSeq
from 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 newMSeq
from the given values.static <T> MSeq<T>
ofLength
(int length) Create a newMSeq
with the givenlength
.Return a newSeq
with the givenvalues
prepended.Return a newSeq
with the givenvalues
prepended.reverse()
Reverses the order of the elements this sequence (in place).void
Set thevalue
at 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 thearray
using theRandomGenerator
object currently registered in theRandomRegistry
class.shuffle
(RandomGenerator random) Randomize thearray
using the givenRandomGenerator
object.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 void
swap
(int i, int j) Swap the elements at the two positions.default void
Swap a given range with a range of the same size with another array.default void
Swap the elements at the same position.toISeq()
Return a read-only projection of this sequence.toMSeq()
Returns aCollector
that accumulates the input elements into a newMSeq
.Methods inherited from interface io.jenetics.util.BaseSeq
forEach, get, isEmpty, iterator, length, nonEmpty, spliterator, stream
Methods 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:Seq
Returns 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 thevalue
at 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:
this
sequence.
-
setAll
Fills the sequence with values of the given iterable.- Parameters:
values
- the values to fill this sequence.- Returns:
this
sequence.
-
setAll
Fill the sequence with the given values.- Parameters:
values
- the first initial values of this sequence- Returns:
this
sequence.
-
fill
Fill the sequence with values generated by the given factory.- Parameters:
supplier
- the value factory.- Returns:
this
sequence.- Throws:
NullPointerException
- if the givenfactory
isnull
.
-
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 ofthis
range, inclusively.end
- the end index ofthis
range, exclusively.other
- the other array to swap the elements with.otherStart
- the start index of theother
array.- Throws:
IndexOutOfBoundsException
- ifstart > end
or 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 theother
sequence isnull
- Since:
- 4.0
-
shuffle
Randomize thearray
using theRandomGenerator
object currently registered in theRandomRegistry
class. 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 thearray
using the givenRandomGenerator
object. The used shuffling algorithm is from D. Knuth TAOCP, Seminumerical Algorithms, Third edition, page 142, Algorithm S (Selection sampling technique).- Parameters:
random
- theRandomGenerator
object 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 aClassCastException
for any elementse1
ande2
in the sequence).If the specified comparator is
null
then all elements in this list must implement theComparable
interface 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
- theComparator
used to compare sequence elements. Anull
value indicates that the elements' Comparable natural ordering should be used- Returns:
this
sequence- 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:
this
sequence- 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 aClassCastException
for any elementse1
ande2
in the sequence).If the specified comparator is
null
then all elements in this list must implement theComparable
interface and the elements' Comparable natural ordering should be used.- Parameters:
start
- the start index where to start sorting (inclusively)comparator
- theComparator
used to compare sequence elements. Anull
value indicates that the elements' Comparable natural ordering should be used- Returns:
this
sequence- 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:
this
sequence- 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 aClassCastException
for any elementse1
ande2
in the sequence).If the specified comparator is
null
then all elements in this list must implement theComparable
interface and the elements' Comparable natural ordering should be used.- Parameters:
comparator
- theComparator
used to compare sequence elements. Anull
value indicates that the elements' Comparable natural ordering should be used- Returns:
this
sequence- 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:
this
sequence- 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:
listIterator
in interfaceBaseSeq<T>
- Returns:
- a list iterator over the elements in this list (in a proper sequence)
-
subSeq
Description copied from interface:Seq
Returns a view of the portion of this sequence between the specifiedstart
, inclusive, andend
, exclusive. (Ifstart
andend
are 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:Seq
Returns a view of the portion of this sequence between the specifiedstart
, inclusive, andend
, exclusive. (Ifstart
andend
are 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 sub-sequence view instead of a whole sequence.
-
map
Description copied from interface:Seq
Builds a new sequence by applying a function to all elements of this sequence.- Specified by:
map
in 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:Seq
Return a newSeq
with the givenvalues
appended. -
append
Description copied from interface:Seq
Return a newSeq
with the givenvalues
appended. -
prepend
Description copied from interface:Seq
Return a newSeq
with the givenvalues
prepended. -
prepend
Description copied from interface:Seq
Return a newSeq
with the givenvalues
prepended. -
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 aCollector
that accumulates the input elements into a newMSeq
.- Type Parameters:
T
- the type of the input elements- Returns:
- a
Collector
which collects all the input elements into aMSeq
, in encounter order
-
ofLength
Create a newMSeq
with 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 givenlength
is negative
-
of
Create a newMSeq
from the given values.- Type Parameters:
T
- the element type- Parameters:
values
- the array values.- Returns:
- a new
Meq
with the given values. - Throws:
NullPointerException
- if thevalues
array isnull
.
-
of
Create a newMSeq
from the given values.- Type Parameters:
T
- the element type- Parameters:
values
- the array values.- Returns:
- a new
MSeq
with the given values. - Throws:
NullPointerException
- if thevalues
object 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
- theSupplier
which 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 givenlength
is negativeNullPointerException
- if the givensupplier
isnull
- Since:
- 3.3
-
of
Create a newMSeq
from the values of the givenSeq
.- Type Parameters:
T
- the element type- Parameters:
values
- the array values.- Returns:
- a new
MSeq
with the given values - Throws:
NullPointerException
- if thevalues
array isnull
.
-