|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectkodkod.util.ints.AbstractSparseSequence<V>
public abstract class AbstractSparseSequence<V>
A skeletal implementation of the SparseSequence interface.
The class provides an implementation for the isEmpty
,
putAll
, contains
, indices
, equals
, hashCode
,
and toString
methods. All other methods must be
implemented by the subclasses.
entries: int -> lone V |
Method Summary | |
---|---|
IndexedEntry<V> |
ceil(int index)
Returns the entry whose index is the ceiling of the given index in this sequence. |
void |
clear()
Removes all entries from this sequences. |
SparseSequence<V> |
clone()
Returns the result of calling super.clone(). |
boolean |
contains(java.lang.Object value)
Iterates through all the entries in this sequence and returns true if one of the encountered entries has the given object as its value. |
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 first element in this sequence, if any. |
IndexedEntry<V> |
floor(int index)
Returns the entry whose index is the floor of the given index in this sequence. |
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 the size of this sequence is 0. |
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(). |
IndexedEntry<V> |
last()
Returns the last element in this sequence, if any. |
V |
put(int index,
V value)
Throws an UnsupportedOperationException. |
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. |
java.lang.String |
toString()
Returns a string representation of this sequence. |
java.util.Collection<V> |
values()
Returns a Collection view of the values stored in this sequence. |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface kodkod.util.ints.SparseSequence |
---|
get, iterator, size |
Method Detail |
---|
public boolean isEmpty()
isEmpty
in interface SparseSequence<V>
public java.util.Iterator<IndexedEntry<V>> iterator()
iterator
in interface java.lang.Iterable<IndexedEntry<V>>
iterator
in interface SparseSequence<V>
public IndexedEntry<V> first()
first
in interface SparseSequence<V>
SparseSequence.first()
public IndexedEntry<V> last()
last
in interface SparseSequence<V>
SparseSequence.last()
public IndexedEntry<V> ceil(int index)
ceil
in interface SparseSequence<V>
SparseSequence.ceil(int)
public IndexedEntry<V> floor(int index)
floor
in interface SparseSequence<V>
SparseSequence.floor(int)
public IntSet indices()
indices
in interface SparseSequence<V>
public java.util.Collection<V> values()
values
in interface SparseSequence<V>
SparseSequence.values()
public boolean containsIndex(int index)
containsIndex
in interface SparseSequence<V>
SparseSequence.containsIndex(int)
public boolean contains(java.lang.Object value)
contains
in interface SparseSequence<V>
SparseSequence.contains(java.lang.Object)
public SparseSequence<V> clone() throws java.lang.CloneNotSupportedException
clone
in interface SparseSequence<V>
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- - this is not cloneableObject.clone()
public V remove(int index)
remove
in interface SparseSequence<V>
SparseSequence.remove(int)
public void clear()
clear
in interface SparseSequence<V>
SparseSequence.clear()
public V put(int index, V value)
put
in interface SparseSequence<V>
java.lang.UnsupportedOperationException
public void putAll(SparseSequence<? extends V> s)
putAll
in interface SparseSequence<V>
this.entries' = this.entries ++ s.entries |
public boolean equals(java.lang.Object o)
This implementation first checks if the specified object is this sequence; if so it returns true. Then, it checks if the specified object is a sequence whose size is identical to the size of this set; if not, it returns false. If so, it iterates over this sequences's entries, and checks that the specified sequence contains each entry that this sequence contains. If the specified sequence fails to contain such an entry, false is returned. If the iteration completes, true is returned.
equals
in interface SparseSequence<V>
equals
in class java.lang.Object
public int hashCode()
hashCode
in interface SparseSequence<V>
hashCode
in class java.lang.Object
public java.lang.String toString()
This implementation creates an empty string buffer, appends a left bracket, and iterates over the map's entries, appending the string representation of each IndexedEntry in turn. After appending each entry except the last, the string ", " is appended. Finally a right bracket is appended. A string is obtained from the stringbuffer, and returned.
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |