Package components.sequence
Interface Sequence<T>
- Type Parameters:
T
- type ofSequence
entries
- All Superinterfaces:
Iterable<T>
,SequenceKernel<T>
,Standard<Sequence<T>>
- All Known Implementing Classes:
Sequence1L
,Sequence2L
,Sequence3
,SequenceSecondary
SequenceKernel
enhanced with secondary methods.-
Method Summary
Modifier and TypeMethodDescriptionvoid
Concatenates ("appends")s
to the end ofthis
.entry
(int pos) Reports the entry at positionpos
ofthis
.void
Removes the substring ofthis
starting at positionpos1
and ending at positionpos2-1
and puts in its
.void
flip()
Reverses ("flips")this
.void
Insertss
intothis
at positionpos
, i.e., after thepos
-th entry ofthis
; and clearss
.replaceEntry
(int pos, T x) Replaces the entry at positionpos
ofthis
with the entryx
and returns the old entry at that position.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
Methods inherited from interface components.sequence.SequenceKernel
add, length, remove
Methods inherited from interface components.standard.Standard
clear, newInstance, transferFrom
-
Method Details
-
entry
Reports the entry at positionpos
ofthis
.- Parameters:
pos
- the position of the entry- Returns:
- the entry at that position
- Aliases:
- reference returned by
entry
- Requires:
0 <= pos and pos < |this|
- Ensures:
<entry> = this[pos, pos+1)
-
replaceEntry
Replaces the entry at positionpos
ofthis
with the entryx
and returns the old entry at that position.- Parameters:
pos
- the position at which to replace an entryx
- the entry replacing the old one- Returns:
- the old entry at that position
- Aliases:
- reference
x
- Updates:
this
- Requires:
0 <= pos and pos < |this|
- Ensures:
<replaceEntry> = #this[pos, pos+1) and this = #this[0, pos) * <x> * #this[pos+1, |#this|)
-
append
Concatenates ("appends")s
to the end ofthis
.- Parameters:
s
- theSequence
to be appended- Updates:
this
- Clears:
s
- Ensures:
this = #this * #s
-
flip
void flip()Reverses ("flips")this
.- Updates:
this
- Ensures:
this = rev(#this)
-
insert
Insertss
intothis
at positionpos
, i.e., after thepos
-th entry ofthis
; and clearss
.- Parameters:
pos
- the position at which to inserts
- theSequence
to be inserted- Updates:
this
- Clears:
s
- Requires:
0 <= pos and pos <= |this|
- Ensures:
this = #this[0, pos) * #s * #this[pos, |#this|)
-
extract
Removes the substring ofthis
starting at positionpos1
and ending at positionpos2-1
and puts in its
.- Parameters:
pos1
- the position of the first entry that is extractedpos2
- the position of the first entry, after the extracted substring, that is not extracteds
- upon return, the extracted substring- Updates:
this
- Replaces:
s
- Requires:
0 <= pos1 and pos1 <= pos2 and pos2 <= |this|
- Ensures:
this = #this[0, pos1) * #this[pos2, |#this|) and s = #this[pos1, pos2)
-