|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface SparseSequence<V>
Represents a sparse sequence -- a sequence whose indices are not necessarily contiguous. For example, a sparse sequence can have elements at indices 10, 2121, and 3000, without having any elements in between. This specification of sparse sequences also supports negative indeces. Formally, the following methods specify a partial function from integers to values of type V.
Sequence implementations are not required to support mutation. All mutating operations are optional and may throw an UnsupportedOperationException.
entries: int -> lone V |
Method Summary | |
---|---|
IndexedEntry<V> |
ceil(int index)
If an entry for the given index exists, it is returned. |
void |
clear()
Removes all entries from this sequences. |
SparseSequence<V> |
clone()
Returns a copy of this sparse sequence. |
boolean |
contains(java.lang.Object value)
Returns true if this sequence has an entry with the given value; otherwise returns false. |
boolean |
containsIndex(int index)
Returns true if this sparse sequence has an entry for the given index; otherwise returns false. |
boolean |
equals(java.lang.Object o)
Compares the specified object with this sequence for equality. |
IndexedEntry<V> |
first()
Returns the entry with the smallest index. |
IndexedEntry<V> |
floor(int index)
If an entry for the given index exists, it is returned. |
V |
get(int index)
Returns the value to which this sequence maps the given index. |
int |
hashCode()
Returns the hash code value for this sparse sequence. |
IntSet |
indices()
Returns the set of all indices mapped by this sparse sequence. |
boolean |
isEmpty()
Returns true if this sequence is empty; otherwise returns false. |
java.util.Iterator<IndexedEntry<V>> |
iterator()
Returns an iterator over the entries in this sequence in the ascending order of indeces, starting at this.first(). |
java.util.Iterator<IndexedEntry<V>> |
iterator(int from,
int to)
Returns an iterator over the entries in this sequence, whose indeces are between from and to. |
IndexedEntry<V> |
last()
Returns the entry with the largest index. |
V |
put(int index,
V value)
Puts the given value at the specified index. |
void |
putAll(SparseSequence<? extends V> s)
Copies all of the entries from the specified sparse sequence to this sequence. |
V |
remove(int index)
Removes the entry with the given index, if it exists, and returns the value previously stored at the index. |
int |
size()
Returns the number of entries in this sequence. |
java.util.Collection<V> |
values()
Returns a Collection view of the values stored in this sequence. |
Method Detail |
---|
int size()
boolean isEmpty()
void clear()
no this.entries' |
V put(int index, V value)
java.lang.IndexOutOfBoundsException
- - the given index
is not valid for this sequence.
java.lang.IllegalArgumentException
- - the given value cannot
be stored in this sequence.this.entries' = this.entries + index->value |
void putAll(SparseSequence<? extends V> s)
java.lang.IndexOutOfBoundsException
- - s contains indeces that are
not valid for this sequence.
java.lang.IllegalArgumentException
- - s contains a value that cannot
be stored in this sequence.this.entries' = this.entries ++ s.entries |
V get(int index)
V remove(int index)
this.entries' = this.entries - index->E |
boolean containsIndex(int index)
IntSet indices()
boolean contains(java.lang.Object value)
java.util.Collection<V> values()
java.util.Iterator<IndexedEntry<V>> iterator()
iterator
in interface java.lang.Iterable<IndexedEntry<V>>
java.util.Iterator<IndexedEntry<V>> iterator(int from, int to)
IndexedEntry<V> first()
IndexedEntry<V> last()
IndexedEntry<V> ceil(int index)
IndexedEntry<V> floor(int index)
boolean equals(java.lang.Object o)
equals
in class java.lang.Object
int hashCode()
hashCode
in class java.lang.Object
SparseSequence<V> clone() throws java.lang.CloneNotSupportedException
java.lang.CloneNotSupportedException
- - this is not cloneable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |