public class BasicSparseEventList<E> extends AbstractEventList<E> implements SparseEventList<E>
SparseList.Span
publisher, readWriteLock, updates
Constructor and Description |
---|
BasicSparseEventList()
Creates a
BasicSparseEventList . |
BasicSparseEventList(int initialSize)
Creates an empty
BasicSparseEventList with the given initialSize . |
BasicSparseEventList(int initialSize,
ListEventPublisher publisher,
ReadWriteLock readWriteLock)
Creates a
BasicSparseEventList using the specified initialSize,
ListEventPublisher and ReadWriteLock . |
BasicSparseEventList(ListEventPublisher publisher,
ReadWriteLock readWriteLock)
|
BasicSparseEventList(ReadWriteLock readWriteLock)
Creates a
BasicSparseEventList that uses the specified ReadWriteLock for
concurrent access. |
Modifier and Type | Method and Description |
---|---|
boolean |
add(E element)
Appends the specified element to the end of this list (optional operation).
|
void |
add(int index,
E element)
Inserts the specified element at the specified position in this list (optional operation).
|
boolean |
addAll(Collection<? extends E> collection)
Appends all of the elements in the specified collection to the end of this list, in the order
that they are returned by the specified collection's iterator (optional operation).
|
boolean |
addAll(int index,
Collection<? extends E> collection)
Inserts all of the elements in the specified collection into this list at the specified
position (optional operation).
|
void |
addNulls(int index,
int length)
Add/insert a sequence of
null at the given index (in)to the list. |
void |
clear()
Removes all of the elements from this list (optional operation).
|
E |
clear(int index)
Clear the element at the given index.
|
void |
dispose()
Disposing an EventList will make it eligible for garbage collection.
|
boolean |
equals(Object object)
Compares the specified object with this list for equality.
|
E |
get(int index)
Returns the element at the specified position in this list.
|
E |
getNullElement(int index) |
int |
hashCode()
Returns the hash code value for this list.
|
int |
indexOf(Object object)
Returns the index in this list of the first occurrence of the specified element, or -1 if this
list does not contain this element.
|
E |
remove(int index)
Removes the element at the specified position in this list (optional operation).
|
boolean |
remove(Object element)
Removes the first occurrence in this list of the specified element (optional operation).
|
boolean |
removeAll(Collection<?> collection)
Removes from this list all the elements that are contained in the specified collection
(optional operation).
|
boolean |
retainAll(Collection<?> collection)
Retains only the elements in this list that are contained in the specified collection (optional
operation).
|
E |
set(int index,
E element)
Replaces the element at the specified position in this list with the specified element
(optional operation).
|
int |
size()
Returns the number of elements in this list.
|
Iterator<SparseList.Span> |
spanIterator()
Return an iterator over the populated
SparseList.Span s of this sparse list. |
Iterator<SparseList.Span> |
spanIterator(int min,
int max)
Return an iterator over the populated
SparseList.Span s of this sparse list. |
addListEventListener, contains, containsAll, getPublisher, getReadWriteLock, isEmpty, iterator, lastIndexOf, listIterator, listIterator, removeListEventListener, subList, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addListEventListener, getPublisher, getReadWriteLock, removeListEventListener
contains, containsAll, isEmpty, iterator, lastIndexOf, listIterator, listIterator, replaceAll, sort, spliterator, subList, toArray, toArray
parallelStream, removeIf, stream
public BasicSparseEventList()
BasicSparseEventList
.public BasicSparseEventList(ReadWriteLock readWriteLock)
BasicSparseEventList
that uses the specified ReadWriteLock
for
concurrent access.public BasicSparseEventList(int initialSize)
BasicSparseEventList
with the given initialSize
.public BasicSparseEventList(ListEventPublisher publisher, ReadWriteLock readWriteLock)
public BasicSparseEventList(int initialSize, ListEventPublisher publisher, ReadWriteLock readWriteLock)
BasicSparseEventList
using the specified initialSize,
ListEventPublisher
and ReadWriteLock
.public void dispose()
EventList
Warning: It is an error to call any method on an EventList
after it has been disposed.
public boolean add(E element)
Lists that support this operation may place limitations on what elements may be added to this list. In particular, some lists will refuse to add null elements, and others will impose restrictions on the type of elements that may be added. List classes should clearly specify in their documentation any restrictions on what elements may be added.
add
in interface Collection<E>
add
in interface List<E>
add
in class AbstractEventList<E>
element
- element to be appended to this list.true
(as per the general contract of the Collection.add
method).public void add(int index, E element)
public boolean addAll(Collection<? extends E> collection)
addAll
in interface Collection<E>
addAll
in interface List<E>
addAll
in class AbstractEventList<E>
collection
- collection whose elements are to be added to this list.true
if this list changed as a result of the call.AbstractEventList.add(Object)
public boolean addAll(int index, Collection<? extends E> collection)
public E remove(int index)
public boolean remove(Object element)
(o==null ? get(i)==null : o.equals(get(i)))
(if such
an element exists).remove
in interface Collection<E>
remove
in interface List<E>
remove
in class AbstractEventList<E>
element
- element to be removed from this list, if present.true
if this list contained the specified element.public void clear()
clear
in interface Collection<E>
clear
in interface List<E>
clear
in class AbstractEventList<E>
public E set(int index, E element)
public E get(int index)
getNullElement(int)
is returned instead.get
in interface List<E>
get
in class AbstractEventList<E>
index
- index of element to return.IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >=
size()).public int size()
Integer.MAX_VALUE
elements, returns Integer.MAX_VALUE
.size
in interface Collection<E>
size
in interface List<E>
size
in class AbstractEventList<E>
public boolean removeAll(Collection<?> collection)
removeAll
in interface Collection<E>
removeAll
in interface List<E>
removeAll
in class AbstractEventList<E>
collection
- collection that defines which elements will be removed from this list.true
if this list changed as a result of the call.AbstractEventList.remove(Object)
,
AbstractEventList.contains(Object)
public boolean retainAll(Collection<?> collection)
retainAll
in interface Collection<E>
retainAll
in interface List<E>
retainAll
in class AbstractEventList<E>
collection
- collection that defines which elements this set will retain.true
if this list changed as a result of the call.AbstractEventList.remove(Object)
,
AbstractEventList.contains(Object)
public Iterator<SparseList.Span> spanIterator()
SparseList
SparseList.Span
s of this sparse list. A span is a
consecutive range of non-null
entries in the list.spanIterator
in interface SparseList<E>
public Iterator<SparseList.Span> spanIterator(int min, int max)
SparseList
SparseList.Span
s of this sparse list. A span is a
consecutive range of non-null
entries in the list. Only entries within the range
[min..max]
are considered.spanIterator
in interface SparseList<E>
min
- the minimum index to considermax
- the maximum index to considerpublic void addNulls(int index, int length)
SparseList
null
at the given index (in)to the list.addNulls
in interface SparseList<E>
public int hashCode()
AbstractEventList
hashCode = 1; Iterator i = list.iterator(); while (i.hasNext()) { Object obj = i.next(); hashCode = 31 * hashCode + (obj == null ? 0 : obj.hashCode()); }This ensures that
list1.equals(list2)
implies that
list1.hashCode()==list2.hashCode()
for any two lists, list1
and
list2
, as required by the general contract of Object.hashCode
.hashCode
in interface Collection<E>
hashCode
in interface List<E>
hashCode
in class AbstractEventList<E>
Object.hashCode()
,
Object.equals(Object)
,
AbstractEventList.equals(Object)
public boolean equals(Object object)
AbstractEventList
true
if and only if
the specified object is also a list, both lists have the same size, and all corresponding pairs
of elements in the two lists are equal. (Two elements e1
and e2
are
equal if (e1==null ? e2==null :
e1.equals(e2))
.) In other words, two lists are defined to be equal if they contain the
same elements in the same order. This definition ensures that the equals method works properly
across different implementations of the List
interface.equals
in interface Collection<E>
equals
in interface List<E>
equals
in class AbstractEventList<E>
object
- the object to be compared for equality with this list.true
if the specified object is equal to this list.public E getNullElement(int index)
getNullElement
in interface SparseEventList<E>
null
-element).public int indexOf(Object object)
AbstractEventList
i
such
that (o==null ? get(i)==null : o.equals(get(i)))
, or -1 if there is no such index.public E clear(int index)
SparseList
List.remove(int)
, the indices of all
other elements are unaffected by this operation.clear
in interface SparseList<E>
Copyright © 2024 levigo holding gmbh. All rights reserved.