All Packages Class Hierarchy This Package Previous Next Index
Interface collections.UpdatableSeq
- public interface interface UpdatableSeq
- extends UpdatableCollection, Seq
UpdatableSeqs are Seqs possessing standard modification methods
-
appendElements(Enumeration)
- Append all elements of enumeration e, preserving their order.
-
insertAt(int, Object)
- Insert element at indicated index.
-
insertElementsAt(int, Enumeration)
- Insert all elements of enumeration e at a given index, preserving
their order.
-
insertFirst(Object)
- Insert element at front of the sequence.
-
insertLast(Object)
- insert element at end of the sequence
Behaviorally equivalent to insertAt(size(), element)
-
prependElements(Enumeration)
- Prepend all elements of enumeration e, preserving their order.
-
removeAt(int)
- Remove element at indicated index.
-
removeFirst()
- Remove the leftmost element.
-
removeFromTo(int, int)
- Remove the elements from fromIndex to toIndex, inclusive.
-
removeLast()
- Remove the rightmost element.
-
replaceAt(int, Object)
- replace element at indicated index with new value
-
replaceFirst(Object)
- replace element at front of the sequence with new value.
-
replaceLast(Object)
- replace element at end of the sequence with new value
Behaviorally equivalent to replaceAt(size()-1, element);
insertAt
public abstract void insertAt(int index,
Object element) throws IllegalElementException, NoSuchElementException
- Insert element at indicated index. The index can range from
0..size() (i.e., one past the current last index). If the index is
equal to size(), the element is appended as the new last element.
- Parameters:
- index - the index to add at
- element - the element to add
- Returns:
- condition:
size() == PREV(this).size()+1 &&
at(index).equals(element) &&
foreach (int i in 0 .. index-1) at(i).equals(PREV(this).at(i))
foreach (int i in index+1..size()-1) at(i).equals(PREV(this).at(i-1))
Version change: always
- Throws: NoSuchElementException
- if index is not in range 0..size()
- Throws: IllegalElementException
- if !canInclude(element)
replaceAt
public abstract void replaceAt(int index,
Object element) throws IllegalElementException, NoSuchElementException
- replace element at indicated index with new value
- Parameters:
- index - the index at which to replace value
- element - the new value
- Returns:
- condition:
size() == PREV(this).size() &&
at(index).equals(element) &&
no spurious effects
Version change <-- !element.equals(PREV(this).at(index)
(but MAY change even if equal).
- Throws: NoSuchElementException
- if index is not in range 0..size()-1
- Throws: IllegalElementException
- if !canInclude(element)
removeAt
public abstract void removeAt(int index) throws NoSuchElementException
- Remove element at indicated index. All elements to the right
have their indices decremented by one.
- Parameters:
- index - the index of the element to remove
- Returns:
- condition:
size() = PREV(this).size()-1 &&
foreach (int i in 0..index-1) at(i).equals(PREV(this).at(i)); &&
foreach (int i in index..size()-1) at(i).equals(PREV(this).at(i+1));
Version change: always
- Throws: NoSuchElementException
- if index is not in range 0..size()-1
insertFirst
public abstract void insertFirst(Object element) throws IllegalElementException
- Insert element at front of the sequence.
Behaviorally equivalent to insertAt(0, element)
- Parameters:
- element - the element to add
- Throws: IllegalElementException
- if !canInclude(element)
replaceFirst
public abstract void replaceFirst(Object element) throws IllegalElementException, NoSuchElementException
- replace element at front of the sequence with new value.
Behaviorally equivalent to replaceAt(0, element);
removeFirst
public abstract void removeFirst() throws NoSuchElementException
- Remove the leftmost element.
Behaviorally equivalent to removeAt(0);
insertLast
public abstract void insertLast(Object element) throws IllegalElementException
- insert element at end of the sequence
Behaviorally equivalent to insertAt(size(), element)
- Parameters:
- element - the element to add
- Throws: IllegalElementException
- if !canInclude(element)
replaceLast
public abstract void replaceLast(Object element) throws IllegalElementException, NoSuchElementException
- replace element at end of the sequence with new value
Behaviorally equivalent to replaceAt(size()-1, element);
removeLast
public abstract void removeLast() throws NoSuchElementException
- Remove the rightmost element.
Behaviorally equivalent to removeAt(size()-1);
- Throws: NoSuchElementException
- if isEmpty
removeFromTo
public abstract void removeFromTo(int fromIndex,
int toIndex) throws NoSuchElementException
- Remove the elements from fromIndex to toIndex, inclusive.
No effect if fromIndex > toIndex.
Behaviorally equivalent to
for (int i = fromIndex; i <= toIndex; ++i) removeAt(fromIndex);
- Parameters:
- index - the index of the first element to remove
- index - the index of the last element to remove
- Returns:
- condition:
let n = max(0, toIndex - fromIndex + 1 in
size() == PREV(this).size() - 1 &&
for (int i in 0 .. fromIndex - 1) at(i).equals(PREV(this).at(i)) &&
for (int i in fromIndex .. size()- 1) at(i).equals(PREV(this).at(i+n)
Version change iff n > 0
- Throws: NoSuchElementException
- if fromIndex or toIndex is not in
range 0..size()-1
insertElementsAt
public abstract void insertElementsAt(int index,
Enumeration e) throws IllegalElementException, CorruptedEnumerationException, NoSuchElementException
- Insert all elements of enumeration e at a given index, preserving
their order. The index can range from
0..size() (i.e., one past the current last index). If the index is
equal to size(), the elements are appended.
- Parameters:
- index - the index to start adding at
- e - the elements to add
- Returns:
- condition:
foreach (int i in 0 .. index-1) at(i).equals(PREV(this)at(i)); &&
All existing elements at indices at or greater than index have their
indices incremented by the number of elements
traversable via e.nextElement() &&
The new elements are at indices index + their order in
the enumeration's nextElement traversal.
!(e.hasMoreElements()) &&
(version() != PREV(this).version()) == PREV(e).hasMoreElements()
- Throws: IllegalElementException
- if !canInclude some element of e;
this may or may not nullify the effect of insertions of other elements.
- Throws: NoSuchElementException
- if index is not in range 0..size()
- Throws: CorruptedEnumerationException
- is propagated if raised; this
may or may not nullify the effects of insertions of other elements.
prependElements
public abstract void prependElements(Enumeration e) throws IllegalElementException, CorruptedEnumerationException
- Prepend all elements of enumeration e, preserving their order.
Behaviorally equivalent to addElementsAt(0, e)
- Parameters:
- e - the elements to add
appendElements
public abstract void appendElements(Enumeration e) throws IllegalElementException, CorruptedEnumerationException
- Append all elements of enumeration e, preserving their order.
Behaviorally equivalent to addElementsAt(size(), e)
- Parameters:
- e - the elements to add
All Packages Class Hierarchy This Package Previous Next Index