public abstract class AbstractSparseSequence<V> extends Object implements SparseSequence<V>
isEmpty
,
putAll
, contains
, indices
, equals
, hashCode
,
and toString
methods. All other methods must be
implemented by the subclasses.entries: int -> lone V
Modifier and Type | Method and Description |
---|---|
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(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(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.
|
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.
|
String |
toString()
Returns a string representation of this sequence.
|
Collection<V> |
values()
Returns a Collection view of the values stored in this sequence.
|
get, iterator, size
forEach, spliterator
public IndexedEntry<V> ceil(int index)
ceil
in interface SparseSequence<V>
SparseSequence.ceil(int)
public void clear()
clear
in interface SparseSequence<V>
no this.entries'
SparseSequence.clear()
public SparseSequence<V> clone() throws CloneNotSupportedException
clone
in interface SparseSequence<V>
clone
in class Object
CloneNotSupportedException
- this is not cloneableObject.clone()
public boolean contains(Object value)
contains
in interface SparseSequence<V>
SparseSequence.contains(java.lang.Object)
public boolean containsIndex(int index)
containsIndex
in interface SparseSequence<V>
SparseSequence.containsIndex(int)
public boolean equals(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 Object
public IndexedEntry<V> first()
first
in interface SparseSequence<V>
SparseSequence.first()
public IndexedEntry<V> floor(int index)
floor
in interface SparseSequence<V>
SparseSequence.floor(int)
public int hashCode()
hashCode
in interface SparseSequence<V>
hashCode
in class Object
public IntSet indices()
indices
in interface SparseSequence<V>
public boolean isEmpty()
isEmpty
in interface SparseSequence<V>
public Iterator<IndexedEntry<V>> iterator()
iterator
in interface Iterable<IndexedEntry<V>>
iterator
in interface SparseSequence<V>
public IndexedEntry<V> last()
last
in interface SparseSequence<V>
SparseSequence.last()
public V put(int index, V value)
put
in interface SparseSequence<V>
this.entries' = this.entries + index->value
UnsupportedOperationException
public void putAll(SparseSequence<? extends V> s)
putAll
in interface SparseSequence<V>
this.entries' = this.entries ++ s.entries
public V remove(int index)
remove
in interface SparseSequence<V>
this.entries' = this.entries - index->E
SparseSequence.remove(int)
public 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.
public Collection<V> values()
values
in interface SparseSequence<V>
SparseSequence.values()
© Emina Torlak 2005-present