|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectkodkod.util.ints.AbstractSparseSequence<V>
kodkod.util.ints.ArraySequence<V>
public final class ArraySequence<V>
An implementation of a sparse sequence based on an array. This implementation can be used only when the indices of the sequence are known in advance. The indices with which an ArraySequence is construct remain fixed throughout. The put operation fails whenever its index argument is not one of the sequence's pre-set indices, and iteration is proportional to the number of the pre-set indices. This sequence does not allow null values.
indeces: set int |
entries: indeces -> lone (V - null) |
Constructor Summary | |
---|---|
ArraySequence(IntSet indices)
Constructs an array sequence that contains the given indeces. |
|
ArraySequence(SparseSequence<? extends V> s)
Constructs a new array sequence with the same index/value mappings as the given sequence. |
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. |
ArraySequence<V> |
clone()
Returns a copy of this sparse sequence. |
boolean |
containsIndex(int index)
Returns true if this sparse sequence has an entry for the given index; otherwise returns false. |
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. |
boolean |
isEmpty()
Returns true if this sequence is empty; otherwise returns false. |
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. |
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. |
Methods inherited from class kodkod.util.ints.AbstractSparseSequence |
---|
contains, equals, hashCode, indices, iterator, putAll, toString, values |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ArraySequence(IntSet indices)
java.lang.NullPointerException
- - indeces = nullthis.indeces' = indeces && no this.entries' |
public ArraySequence(SparseSequence<? extends V> s)
java.lang.NullPointerException
- - s = null || null in sthis.entries' = s.entries |
Method Detail |
---|
public int size()
size
in interface SparseSequence<V>
SparseSequence.size()
public boolean isEmpty()
isEmpty
in interface SparseSequence<V>
isEmpty
in class AbstractSparseSequence<V>
SparseSequence.isEmpty()
public void clear()
clear
in interface SparseSequence<V>
clear
in class AbstractSparseSequence<V>
SparseSequence.clear()
public V put(int index, V value)
put
in interface SparseSequence<V>
put
in class AbstractSparseSequence<V>
java.lang.IndexOutOfBoundsException
- - index !in this.indeces
java.lang.NullPointerException
- - value = nullSparseSequence.put(int, Object)
this.entries' = this.entries + index->value |
public V get(int index)
get
in interface SparseSequence<V>
SparseSequence.get(int)
public V remove(int index)
remove
in interface SparseSequence<V>
remove
in class AbstractSparseSequence<V>
SparseSequence.remove(int)
this.entries' = this.entries - index->E |
public boolean containsIndex(int index)
containsIndex
in interface SparseSequence<V>
containsIndex
in class AbstractSparseSequence<V>
SparseSequence.containsIndex(int)
public java.util.Iterator<IndexedEntry<V>> iterator(int from, int to)
iterator
in interface SparseSequence<V>
SparseSequence.iterator(int, int)
public IndexedEntry<V> first()
first
in interface SparseSequence<V>
first
in class AbstractSparseSequence<V>
SparseSequence.first()
public IndexedEntry<V> last()
last
in interface SparseSequence<V>
last
in class AbstractSparseSequence<V>
SparseSequence.last()
public IndexedEntry<V> ceil(int index)
ceil
in interface SparseSequence<V>
ceil
in class AbstractSparseSequence<V>
SparseSequence.ceil(int)
public IndexedEntry<V> floor(int index)
floor
in interface SparseSequence<V>
floor
in class AbstractSparseSequence<V>
SparseSequence.floor(int)
public ArraySequence<V> clone()
clone
in interface SparseSequence<V>
clone
in class AbstractSparseSequence<V>
SparseSequence.clone()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |