|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jaggregate.AbstractCollection<E> jaggregate.AbstractExtensibleCollection<E> jaggregate.OrderedCollection<E>
E
- a restriction on the types of elements that may be included in the
collectionpublic class OrderedCollection<E>
Represents an ordered, variable-sized collection of objects, where elements may be added, removed, or inserted, and can be accessed using external integer keys.
Constructor Summary | |
---|---|
OrderedCollection()
Creates an empty ordered collection. |
|
OrderedCollection(Collection<? extends E> elements)
Creates an ordered collection containing the elements in the given collection. |
|
OrderedCollection(E... elements)
Creates an ordered collection containing the elements in the given array. |
|
OrderedCollection(int capacity)
Creates an empty ordered collection with the given initial capacity. |
|
OrderedCollection(Iterable<? extends E> elements)
Creates an ordered collection containing the elements in the given iterable object. |
Method Summary | ||
---|---|---|
void |
add(E newElement)
Adds a new element to this collection. newElement is added to the end of this collection's elements so that it
becomes the last element in the traversal order. |
|
void |
addAfter(E newElement,
E target)
Adds a new element to this collection immediately following the first element which is equivalent to a given target. |
|
void |
addAfterIndex(E newElement,
int index)
Adds a new element to this collection immediately following the element at the given index. |
|
void |
addAllAfter(Collection<? extends E> newElements,
E target)
Adds each element of the given collection to this collection immediately after the first element in this collection which is equivalent to a given target. |
|
void |
addAllAfter(E[] newElements,
E target)
|
|
void |
addAllAfter(Iterable<? extends E> newElements,
E target)
|
|
void |
addAllAfterIndex(Collection<? extends E> newElements,
int index)
Adds each element of the given collection to this collection immediately following the element at the given index. |
|
void |
addAllAfterIndex(E[] newElements,
int index)
|
|
void |
addAllAfterIndex(Iterable<? extends E> newElements,
int index)
|
|
void |
addAllBefore(Collection<? extends E> newElements,
E target)
Adds each element of the given collection to this collection immediately before the first element in this collection which is equivalent to a given target. |
|
void |
addAllBefore(E[] newElements,
E target)
|
|
void |
addAllBefore(Iterable<? extends E> newElements,
E target)
|
|
void |
addAllBeforeIndex(Collection<? extends E> newElements,
int index)
Adds each element of the given collection to this collection immediately preceding the element at the given index. |
|
void |
addAllBeforeIndex(E[] newElements,
int index)
|
|
void |
addAllBeforeIndex(Iterable<? extends E> newElements,
int index)
|
|
void |
addAllFirst(Collection<? extends E> newElements)
Adds each element of the given collection to the beginning of this collection's elements. |
|
void |
addAllFirst(E... newElements)
|
|
void |
addAllFirst(Iterable<? extends E> newElements)
|
|
void |
addAllLast(Collection<? extends E> newElements)
Adds each element of the given collection to the end of this collection's elements. |
|
void |
addAllLast(E... newElements)
|
|
void |
addAllLast(Iterable<? extends E> newElements)
|
|
void |
addBefore(E newElement,
E target)
Adds a new element to this collection immediately preceding the first element which is equivalent to a given target. |
|
void |
addBeforeIndex(E newElement,
int index)
Adds a new element to this collection immediately preceding the element at the given index. |
|
void |
addFirst(E newElement)
Adds a new element to the beginning of this collection's elements. |
|
void |
addLast(E newElement)
Adds a new element to the end of this collection's elements. |
|
E |
after(E target)
Answers the object immediately following the first element which is equivalent to the given target in this sequence. |
|
E |
at(int index)
Answers the element at the given position in this sequence. |
|
E |
before(E target)
Answers the object immediately preceding the first element which is equivalent to the given target in this sequence. |
|
|
collect(UnaryFunctor<? super E,? extends R> transformer)
Evaluates the given transformer for each element of this collection, with the element as the parameter, and answers a new collection containing the results of these evaluations. The elements are traversed in the order specified by forEachDo for this collection.
Unless specifically refined, this message is defined to answer an object
conforming to the same protocol as this collection. |
|
OrderedCollection<E> |
concat(ReadOnlySequence<? extends E> otherSequence)
Answers a new sequence containing all of this sequence's elements in their original order followed by all of the elements of the given sequence, in their original order. |
|
OrderedCollection<E> |
copyRange(int start,
int stop)
Answers a new sequence containing the specified range of elements of this sequence in their original order. |
|
OrderedCollection<E> |
copyWith(E newElement)
Answers a new sequence with size one greater than the size of this sequence, containing the elements of this sequence and a given new element placed at the end. |
|
OrderedCollection<E> |
copyWithout(E oldElement)
Answers a new sequence with all of the elements of this sequence that are not equivalent to the given element, in their original order. |
|
void |
doWithIndex(BinaryFunctor<? super Integer,? super E,?> operation)
Evaluates the given operation with the index of each element of this sequence, in order, together with the element itself. |
|
|
doWithOthers(ReadOnlySequence<? extends T> otherSequence,
BinaryFunctor<? super E,? super T,?> operation)
For each element of this sequence and the corresponding element of the given sequence, evaluates the given operation with this sequence's element as the first parameter, and the element of the other sequence as the second parameter. |
|
static
|
emptyOrderedCollection()
Creates an empty ordered collection. |
|
boolean |
equals(Object that)
|
|
int |
findFirst(UnaryCondition<? super E> discriminator)
Answers the index of the first element which causes the given discriminator to answer true when the element is used as a parameter. |
|
int |
findLast(UnaryCondition<? super E> discriminator)
Answers the index of the last element which causes the given discriminator to answer true when the element is used as a parameter. |
|
E |
first()
Answers the element at index 0 in this sequence. |
|
void |
forEachDo(UnaryFunctor<? super E,?> operation)
For each element of this collection, evaluates the given operation with the element as the parameter. |
|
void |
forEachInRangeDo(int start,
int stop,
UnaryFunctor<? super E,?> operation)
For those elements of this sequence between two given positions, inclusive, evaluates the given operation with the element at that index as its argument. |
|
void |
forEachInRangeDoWithIndex(int start,
int stop,
BinaryFunctor<? super Integer,? super E,?> operation)
For those elements of this sequence between two given positions, inclusive, evaluates the given operation with an element of this sequence as the first argument and the element's position (index) as the second. |
|
void |
forEachInReverseDo(UnaryFunctor<? super E,?> operation)
Evaluates the given operation with each element of this sequence in the reverse of this sequence's standard traversal order. |
|
int |
hashCode()
|
|
int |
indexOf(E target)
Answers the index of the first element which is equivalent to the given target}. |
|
int |
indexOf(ReadOnlySequence<? extends E> targetSequence,
int start)
Answers the index of the first element of this sequence which is the start of a subsequence which matches a given target sequence. |
|
E |
last()
Answers the last element of this sequence, the element at the index equal to this sequence's size minus 1. |
|
static
|
orderedCollectionFrom(Collection<? extends T> elements)
Creates an ordered collection containing the elements in the given collection. |
|
static
|
orderedCollectionFrom(Iterable<? extends T> elements)
Creates an ordered collection containing the elements in the given iterable object. |
|
static
|
orderedCollectionFrom(T[] elements)
Creates an ordered collection containing the elements in the given array. |
|
static
|
orderedCollectionWith(T newElement,
T... restOfNewElements)
Creates an ordered collection containing the given elements. |
|
E |
putAt(int index,
E newElement)
Replaces the element in this sequence at a given index with a new element. |
|
void |
putAtAll(Collection<? extends Integer> indices,
E newElement)
Replaces the elements in this sequence specified by the given indices with a new element. |
|
void |
putAtAll(E newElement)
Replaces all the elements in this sequence with a new element. |
|
void |
putAtAll(int[] indices,
E newElement)
|
|
void |
putAtAll(Integer[] indices,
E newElement)
|
|
void |
putAtAll(Iterable<? extends Integer> indices,
E newElement)
|
|
OrderedCollection<E> |
reject(UnaryCondition<? super E> discriminator)
Answers a new collection which contains only the elements in this collection which cause the given discriminator to answer false .
For each element of this collection, discriminator is evaluated with the
element as the parameter. Each element which causes discriminator to
answer false is included in the new collection.
The elements are traversed in the order specified by forEachDo for this collection.
Unless specifically refined, this message is defined to answer an object
conforming to the same protocol as this collection. If both this collection
and the result maintain an ordering of their elements, the elements of the
result will be in the same relative order as the elements of this collection. |
|
boolean |
remove(E oldElement)
Removes the first element of this collection which is equivalent to the given element. |
|
E |
removeAt(int index)
Removes and answers the element at a given position in this sequence. |
|
E |
removeFirst()
Removes and answers the first element of this sequence. |
|
boolean |
removeIf(UnaryCondition<? super E> discriminator)
Removes each element of this collection which causes the given discriminator to answer true .
The elements are tested in the same order in which they would be enumerated by
forEachDo for this collection. |
|
E |
removeLast()
Removes and answers the last element of this sequence. |
|
void |
replace(int start,
int stop,
E replacement)
Replaces the elements of this sequence between two positions, inclusive, with a given element. |
|
void |
replaceRange(int start,
int stop,
ReadOnlySequence<? extends E> replacements)
Replaces the elements of this sequence between two positions, inclusive, with a given replacement sequence in their original order. |
|
void |
replaceRange(int start,
int stop,
ReadOnlySequence<? extends E> replacements,
int replacementStart)
Replaces the elements of this sequence between two positions, inclusive, with a given replacement sequence, in their original order, starting at a given position in the replacement sequence. |
|
boolean |
retainIf(UnaryCondition<? super E> discriminator)
Removes each element of this collection which causes the given discriminator to answer false .
The elements are tested in the same order in which they would be enumerated by
forEachDo for this collection. |
|
OrderedCollection<E> |
reverse()
Answers a sequence with the elements of this sequence arranged in reverse order. |
|
OrderedCollection<E> |
select(UnaryCondition<? super E> discriminator)
Answers a new collection which contains only the elements in this collection which cause the given discriminator to answer true .
For each element of this collection, discriminator is evaluated with the
element as the parameter. Each element which causes discriminator to
answer true is included in the new collection.
The elements are traversed in order specified by forEachDo for this collection.
Unless specifically refined, this message is defined to answer an object
conforming to the same protocol as this collection. If both this collection
and the result maintain an ordering of their elements, the elements of the
result will be in the same relative order as the elements of this collection. |
|
int |
size()
Answers the number of elements in this collection. |
|
Object[] |
toArray(Class<? super E> componentClass)
Answers an array with the same elements as this collection, with the same size as this collection, and a component type of the given class. This means that only elements of the given class or any of its derivatives may be inserted into the result. Note that even though the given class will be the runtime component class of the result array, the return type of this method is Object[] . With Java
generics, it is not possible to express the return type as an array of the
component class without sacrificing the flexibility of providing a
componentClass that is a supertype of the generic parameter's actual
argument. Therefore, the caller should downcast to the desired type, or risk
raising ArrayStoreException when inserting via a reference of type
Object[] .
If this collection maintains an ordering for its elements, the order of those
elements will be preserved in the result. |
|
OrderedCollection<E> |
toOrderedCollection()
Answers an ordered collection with the same elements as this collection. The result has the same size as this collection. If this collection maintains an ordering for its elements, the order of those elements will be preserved in the result. Answers self. |
|
String |
toString()
|
Methods inherited from class jaggregate.AbstractExtensibleCollection |
---|
addAll, addAll, addAll, addAll, removeAll, removeAll, removeAll, removeAll, retainAll, retainAll, retainAll, retainAll |
Methods inherited from class jaggregate.AbstractCollection |
---|
allSatisfy, anySatisfy, detect, includes, inject, isEmpty, occurrencesOf, rehash, toArray, toBag, toIdentityBag, toIdentitySet, toSet, toSortedCollection, toSortedCollection |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public OrderedCollection()
public OrderedCollection(Collection<? extends E> elements)
elements
- elements to add to the new ordered collection
NullPointerException
- if elements
is null
public OrderedCollection(E... elements)
elements
- elements to add to the new ordered collection
NullPointerException
- if elements
is null
public OrderedCollection(Iterable<? extends E> elements)
elements
- elements to add to the new ordered collection
NullPointerException
- if elements
is null
public OrderedCollection(int capacity)
capacity
- the initial capacity
IllegalArgumentException
- if capacity <= 0
Method Detail |
---|
public static <T> OrderedCollection<T> emptyOrderedCollection()
T
- the type of elements allowed in the new ordered collection
public static <T> OrderedCollection<T> orderedCollectionFrom(Collection<? extends T> elements)
T
- the type of elements allowed in the new ordered collectionelements
- elements to add to the new ordered collection
NullPointerException
- if elements
is null
public static <T> OrderedCollection<T> orderedCollectionFrom(T[] elements)
T
- the type of elements allowed in the new ordered collectionelements
- elements to add to the new ordered collection
NullPointerException
- if elements
is null
public static <T> OrderedCollection<T> orderedCollectionWith(T newElement, T... restOfNewElements)
T
- the type of elements allowed in the new ordered collectionnewElement
- first new element to ordered collectionrestOfNewElements
- remainder of the elements to ordered collection
NullPointerException
- if restOfNewElements
is null
IllegalArgumentException
- if any of the new elements is found to violate
restrictions on the characteristics of valid elementsAbstractExtensibleCollection.addAll(Collection)
public static <T> OrderedCollection<T> orderedCollectionFrom(Iterable<? extends T> elements)
T
- the type of elements allowed in the new ordered collectionelements
- elements to add to the new ordered collection
NullPointerException
- if elements
is null
public Object[] toArray(Class<? super E> componentClass)
Object[]
. With Java
generics, it is not possible to express the return type as an array of the
component class without sacrificing the flexibility of providing a
componentClass
that is a supertype of the generic parameter's actual
argument. Therefore, the caller should downcast to the desired type, or risk
raising ArrayStoreException
when inserting via a reference of type
Object[]
.
If this collection maintains an ordering for its elements, the order of those
elements will be preserved in the result.
toArray
in interface Collection<E>
toArray
in class AbstractCollection<E>
componentClass
- the desired type of the result array's components
Collections.toArray(Collection,Class)
public OrderedCollection<E> toOrderedCollection()
toOrderedCollection
in interface Collection<E>
toOrderedCollection
in class AbstractCollection<E>
public <R> OrderedCollection<R> collect(UnaryFunctor<? super E,? extends R> transformer)
forEachDo
for this collection.
Unless specifically refined, this message is defined to answer an object
conforming to the same protocol as this collection.
collect
in interface Collection<E>
collect
in interface ContractibleSequence<E>
collect
in interface ExtensibleCollection<E>
collect
in interface ReadOnlySequence<E>
collect
in interface Sequence<E>
collect
in class AbstractExtensibleCollection<E>
R
- return type of the transformertransformer
- the transformer to evaluate
public void forEachDo(UnaryFunctor<? super E,?> operation)
forEachDo
in interface Collection<E>
forEachDo
in interface ReadOnlySequence<E>
operation
- the operation to performpublic OrderedCollection<E> reject(UnaryCondition<? super E> discriminator)
false
.
For each element of this collection, discriminator
is evaluated with the
element as the parameter. Each element which causes discriminator
to
answer false
is included in the new collection.
The elements are traversed in the order specified by forEachDo
for this collection.
Unless specifically refined, this message is defined to answer an object
conforming to the same protocol as this collection. If both this collection
and the result maintain an ordering of their elements, the elements of the
result will be in the same relative order as the elements of this collection.
reject
in interface Collection<E>
reject
in interface ContractibleSequence<E>
reject
in interface ExtensibleCollection<E>
reject
in interface ReadOnlySequence<E>
reject
in interface Sequence<E>
reject
in class AbstractExtensibleCollection<E>
discriminator
- the discriminator to evaluate
public OrderedCollection<E> select(UnaryCondition<? super E> discriminator)
true
.
For each element of this collection, discriminator
is evaluated with the
element as the parameter. Each element which causes discriminator
to
answer true
is included in the new collection.
The elements are traversed in order specified by forEachDo
for this collection.
Unless specifically refined, this message is defined to answer an object
conforming to the same protocol as this collection. If both this collection
and the result maintain an ordering of their elements, the elements of the
result will be in the same relative order as the elements of this collection.
select
in interface Collection<E>
select
in interface ContractibleSequence<E>
select
in interface ExtensibleCollection<E>
select
in interface ReadOnlySequence<E>
select
in interface Sequence<E>
select
in class AbstractExtensibleCollection<E>
discriminator
- the discriminator to evaluate
public int size()
size
in interface Collection<E>
public int findFirst(UnaryCondition<? super E> discriminator)
true
when the element is used as a parameter. Answers -1
if no such element is found.
The elements are traversed in the order specified by forEachDo
for this sequence.
findFirst
in interface ReadOnlySequence<E>
discriminator
- the discriminator to evaluate
-1
if there is no matchpublic int findLast(UnaryCondition<? super E> discriminator)
true
when the element is used as a parameter. Answers -1
if no such element is found.
The elements are traversed in the order specified by forEachInReverseDo
for this sequence.
findLast
in interface ReadOnlySequence<E>
discriminator
- the discriminator to evaluate
-1
if there is no matchpublic void forEachInReverseDo(UnaryFunctor<? super E,?> operation)
forEachDo
. Each element
is visited exactly once.
forEachInReverseDo
in interface ReadOnlySequence<E>
operation
- the operation to evaluatepublic E first()
0
in this sequence.
first
in interface ReadOnlySequence<E>
public void forEachInRangeDo(int start, int stop, UnaryFunctor<? super E,?> operation)
forEachInRangeDo
in interface ReadOnlySequence<E>
start
- beginning indexstop
- ending indexoperation
- the operation to evaluatepublic void forEachInRangeDoWithIndex(int start, int stop, BinaryFunctor<? super Integer,? super E,?> operation)
forEachInRangeDoWithIndex
in interface ReadOnlySequence<E>
start
- beginning indexstop
- ending indexoperation
- the operation to evaluatepublic int indexOf(E target)
-1
if no such element is found.
The elements are traversed in the order specified by forEachDo
for this sequence.
indexOf
in interface ReadOnlySequence<E>
target
- element to match
-1
if no matchpublic int indexOf(ReadOnlySequence<? extends E> targetSequence, int start)
start
is checked for
a match with targetSequence
. To match, each element of a subsequence of
this sequence must be equivalent to the corresponding element of\
targetSequence
. Answers the index of the first element which begins a
matching subsequence; no further subsequences are considered.
Answers -1
if no such subsequence is found in this sequence, or if
targetSequence
is empty.
The elements are traversed in the order specified by forEachDo
message for this sequence.
indexOf
in interface ReadOnlySequence<E>
targetSequence
- sequence to matchstart
- index at which to begin the search
-1
if nonepublic void doWithIndex(BinaryFunctor<? super Integer,? super E,?> operation)
operation
is evaluated with the index of each element of this sequence as
the first argument and the element itself as the second argument. Evaluation is
in indexed order starting at 0
. The first element is at index 0
,
the second at index 1
, etc. The index of the last element is equal to
this sequence's size minus 1.
doWithIndex
in interface ReadOnlySequence<E>
operation
- the operation to performpublic E last()
last
in interface ReadOnlySequence<E>
public void add(E newElement)
newElement
in the element traversal order is unspecified.
Conformant protocols may place restrictions on the characteristics of objects
that are valid elements. Unless otherwise specified, any object that is of the
same class as or of a subclass of this collection's type parameter is acceptable.
newElement
is added to the end of this collection's elements so that it
becomes the last element in the traversal order.
This message is equivalent to addLast
for this
collection with newElement
as the parameter.
add
in interface ExtensibleCollection<E>
newElement
- the element to addpublic boolean remove(E oldElement)
forEachDo
for this collection.
remove
in interface ExtensibleCollection<E>
oldElement
- the element to remove
true
if any removal occurredpublic boolean removeIf(UnaryCondition<? super E> discriminator)
true
.
The elements are tested in the same order in which they would be enumerated by
forEachDo
for this collection.
removeIf
in interface ExtensibleCollection<E>
removeIf
in class AbstractExtensibleCollection<E>
discriminator
- the discriminator to evaluate
true
if any removal occurredpublic boolean retainIf(UnaryCondition<? super E> discriminator)
false
.
The elements are tested in the same order in which they would be enumerated by
forEachDo
for this collection.
retainIf
in interface ExtensibleCollection<E>
retainIf
in class AbstractExtensibleCollection<E>
discriminator
- the discriminator to evaluate
true
if any removal occurredpublic E removeAt(int index)
removeAt
in interface ContractibleSequence<E>
index
- the index at which to remove the element
public E removeFirst()
removeFirst
in interface ContractibleSequence<E>
public E removeLast()
removeLast
in interface ContractibleSequence<E>
public OrderedCollection<E> concat(ReadOnlySequence<? extends E> otherSequence)
otherSequence
.
Sequences that enforce an ordering on their elements are permitted to refine
this message to reorder the result.
concat
in interface ReadOnlySequence<E>
concat
in interface Sequence<E>
otherSequence
- the sequence to concatenate
public E after(E target)
target
is the traversal order defined by forEachDo
for
this sequence.
after
in interface ReadOnlySequence<E>
target
- the object to lookup
target
public E at(int index)
at
in interface ReadOnlySequence<E>
index
- the index to lookup
public E before(E target)
before
in interface ReadOnlySequence<E>
target
- the object to lookup
target
public OrderedCollection<E> copyRange(int start, int stop)
start
in this
sequence is at index 0
in the new sequence; the element at
start + 1
is at index 1
, etc. If stop < start
, then the
new sequence is empty. Otherwise, the size of the new sequence is max(0, stop - start)
.
The given indices must be non-negative.
copyRange
in interface ReadOnlySequence<E>
copyRange
in interface Sequence<E>
start
- the beginning indexstop
- the ending index
public OrderedCollection<E> copyWith(E newElement)
copyWith
in interface ReadOnlySequence<E>
copyWith
in interface Sequence<E>
newElement
- element to add to the copy
newElement
appendedpublic OrderedCollection<E> copyWithout(E oldElement)
copyWithout
in interface ReadOnlySequence<E>
copyWithout
in interface Sequence<E>
oldElement
- the element to strip from the copy of this sequence
oldElement
removedpublic OrderedCollection<E> reverse()
forEachInReverseDo
message,
adding each element of this sequence to the new sequence.
reverse
in interface ReadOnlySequence<E>
reverse
in interface Sequence<E>
public <T> void doWithOthers(ReadOnlySequence<? extends T> otherSequence, BinaryFunctor<? super E,? super T,?> operation)
otherSequence
must have the same size.
The elements of this sequence and otherSequence
are traversed in indexed
order starting at 0
. The operation
is evaluated with the
elements at index 0
in the two sequences, then index 1
, etc.
doWithOthers
in interface ReadOnlySequence<E>
T
- a constraint on the types of elements in the given sequenceotherSequence
- the other elements to use in the evaluationoperation
- the operation to performpublic E putAt(int index, E newElement)
putAt
in interface Sequence<E>
index
- the index at which to replace the elementnewElement
- the element to place at index
index
, or null
if there is
no such elementpublic void putAtAll(Collection<? extends Integer> indices, E newElement)
newElement
in this sequence at
each index specified by indices
using putAt
.
putAtAll
in interface Sequence<E>
indices
- the indices at which to replace elementsnewElement
- the element to place at each of the indices
public void putAtAll(int[] indices, E newElement)
putAtAll
in interface Sequence<E>
indices
- the indices at which to replace elementsnewElement
- the element to place at each of the indices
Sequence.putAtAll(Collection,Object)
public void putAtAll(Integer[] indices, E newElement)
putAtAll
in interface Sequence<E>
indices
- the indices at which to replace elementsnewElement
- the element to place at each of the indices
Sequence.putAtAll(Collection,Object)
public void putAtAll(Iterable<? extends Integer> indices, E newElement)
putAtAll
in interface Sequence<E>
indices
- the indices at which to replace elementsnewElement
- the element to place at each of the indices
Sequence.putAtAll(Collection,Object)
public void putAtAll(E newElement)
newElement
in this sequence at each
index from 0
to this sequence's size minus 1 using
putAt
.
putAtAll
in interface Sequence<E>
newElement
- the element to place at each indexpublic void replace(int start, int stop, E replacement)
replace
in interface Sequence<E>
start
- beginning indexstop
- ending indexreplacement
- element with which to replace the elements between
start
and stop
, inclusivepublic void replaceRange(int start, int stop, ReadOnlySequence<? extends E> replacements)
replacements
is stored in this sequence at position
start
, the second at position start + 1
, etc. Any previously
stored elements at these positions are replaced.
replaceRange
in interface Sequence<E>
start
- beginning indexstop
- ending indexreplacements
- elements to replace in between start
and
stop
, inclusivepublic void replaceRange(int start, int stop, ReadOnlySequence<? extends E> replacements, int replacementStart)
replacementStart
in replacements
is stored in this sequence at position start
; the element at
replacementStart + 1
is stored at position start + 1
; etc.
Any previously stored elements at these positions are replaced.
replaceRange
in interface Sequence<E>
start
- beginning indexstop
- ending indexreplacements
- elements to replace in between start
and
stop
, inclusivereplacementStart
- index to start at in replacements
public void addAfter(E newElement, E target)
target
is
the traversal order defined by forEachDo
for
this collection.
newElement
- the element to addtarget
- the element after which to add newElement
NoSuchElementException
- if this collection does not include target
public void addAfterIndex(E newElement, int index)
newElement
is inserted at position index + 1
.
If index == -1
, newElement
becomes the first
element of this collection.
newElement
- the element to addindex
- the index after which to add newElement
IndexOutOfBoundsException
- if index < -1
or index >=
this
collection's size.public void addBefore(E newElement, E target)
target
is the
traversal order defined by forEachDo
for this
collection.
newElement
- the element to addtarget
- the element before which to add newElement
NoSuchElementException
- if this collection does not include target
public void addBeforeIndex(E newElement, int index)
index ==
this collection's size,
then newElement
will become the last element of
this collection.
newElement
- the element to addindex
- the before after which to add newElement
IndexOutOfBoundsException
- if index < 0
or index >
this
collection's size.public void addAllAfter(Collection<? extends E> newElements, E target)
newElements
are added to this collection in the traversal
order defined by forEachDo
for newElements
. An element immediately follows another if its index is one greater
than that of the other. The order used to determine which of this collection's
elements is the first to equal target
is the traversal order defined by
forEachDo
for this collection.
newElements
- the elements to addtarget
- the element after which to perform the additions
NullPointerException
- if newElements
is null
NoSuchElementException
- if this collection does not include target
public void addAllAfter(E[] newElements, E target)
newElements
- the elements to addtarget
- the element after which to perform the additions
NullPointerException
- if newElements
is null
NoSuchElementException
- if this collection does not include target
addAllAfter(Collection,Object)
public void addAllAfter(Iterable<? extends E> newElements, E target)
newElements
- the elements to addtarget
- the element after which to perform the additions
NullPointerException
- if newElements
is null
NoSuchElementException
- if this collection does not include target
addAllAfter(Collection,Object)
public void addAllAfterIndex(Collection<? extends E> newElements, int index)
newElements
are added to this collection in the traversal
order defined by forEachDo
for newElements
. newElements
are inserted immediately after the element in
this collection at position index
. If index == -1
,
newElements
are inserted at the beginning of this collection.
newElements
- the elements to addindex
- the index after which to add newElements
NullPointerException
- if newElements
is null
IndexOutOfBoundsException
- if index < -1
or index >=
this
collection's sizepublic void addAllAfterIndex(E[] newElements, int index)
newElements
- the elements to addindex
- the index after which to add newElements
NullPointerException
- if newElements
is null
IndexOutOfBoundsException
- if index < -1
or index >=
this
collection's sizeaddAllAfterIndex(Collection,int)
public void addAllAfterIndex(Iterable<? extends E> newElements, int index)
newElements
- the elements to addindex
- the index after which to add newElements
NullPointerException
- if newElements
is null
IndexOutOfBoundsException
- if index < -1
or index >=
this
collection's sizeaddAllAfterIndex(Collection,int)
public void addAllBefore(Collection<? extends E> newElements, E target)
newElements
are added to this collection in the traversal
order defined by forEachDo
for newElements
. An element immediately precedes another if its index is one
greater than that of the other. The order used to determine which of this
collection's elements is the first to equal target
is the traversal order
defined by forEachDo
for this collection.
newElements
- the elements to addtarget
- the element before which to perform the additions
NullPointerException
- if newElements
is null
NoSuchElementException
- if this collection does not include target
public void addAllBefore(E[] newElements, E target)
newElements
- the elements to addtarget
- the element before which to perform the additions
NullPointerException
- if newElements
is null
NoSuchElementException
- if this collection does not include target
addAllBefore(Collection,Object)
public void addAllBefore(Iterable<? extends E> newElements, E target)
newElements
- the elements to addtarget
- the element before which to perform the additions
NullPointerException
- if newElements
is null
NoSuchElementException
- if this collection does not include target
addAllBefore(Collection,Object)
public void addAllBeforeIndex(Collection<? extends E> newElements, int index)
newElements
are added to this collection in the traversal
order defined by forEachDo
for newElements
. newElements
are inserted immediately before the element in
this collection at position index
. If index ==
this collection's
size, newElements
are inserted at the end of this
collection.
newElements
- the elements to addindex
- the index after which to add newElements
NullPointerException
- if newElements
is null
IndexOutOfBoundsException
- if index < 0
or index >
this
collection's sizepublic void addAllBeforeIndex(E[] newElements, int index)
newElements
- the elements to addindex
- the index after which to add newElements
NullPointerException
- if newElements
is null
IndexOutOfBoundsException
- if index < 0
or index >
this
collection's sizeaddAllBeforeIndex(Collection,int)
public void addAllBeforeIndex(Iterable<? extends E> newElements, int index)
newElements
- the elements to addindex
- the index after which to add newElements
NullPointerException
- if newElements
is null
IndexOutOfBoundsException
- if index < 0
or index >
this
collection's sizeaddAllBeforeIndex(Collection,int)
public void addAllFirst(Collection<? extends E> newElements)
newElements
to this collection using addFirst
with the
element as the parameter, where newElements
are traversed in the order
specified by forEachInReverseDo
for
newElements
.
newElements
- the elements to add
NullPointerException
- if newElements
is null
public void addAllFirst(E... newElements)
newElements
- the elements to add
NullPointerException
- if newElements
is null
addAllFirst(Collection)
public void addAllFirst(Iterable<? extends E> newElements)
newElements
- the elements to add
NullPointerException
- if newElements
is null
addAllFirst(Collection)
public void addAllLast(Collection<? extends E> newElements)
newElements
to this collection using addLast
with the
element as the parameter, where newElements
are traversed in the order
specified by forEachDo
for newElements
.
newElements
- the elements to add
NullPointerException
- if newElements
is null
public void addAllLast(E... newElements)
newElements
- the elements to add
NullPointerException
- if newElements
is null
addAllLast(Collection)
public void addAllLast(Iterable<? extends E> newElements)
newElements
- the elements to add
NullPointerException
- if newElements
is null
addAllLast(Collection)
public void addFirst(E newElement)
newElement
becomes the first element in the
traversal order.
newElement
- the element to addpublic void addLast(E newElement)
newElement
becomes the last element in the traversal order.
newElement
- the element to addpublic boolean equals(Object that)
equals
in class Object
public int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |