Package com.linkedin.venice.utils
Class SparseConcurrentListWithOffset<E>
java.lang.Object
java.util.concurrent.CopyOnWriteArrayList<E>
com.linkedin.venice.utils.SparseConcurrentList<E>
com.linkedin.venice.utils.SparseConcurrentListWithOffset<E>
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<E>
,Collection<E>
,List<E>
,RandomAccess
A very simple subclass of
SparseConcurrentList
which adds some immutable offset to all index.
Useful for cases where the list needs to contain negative indices.
A more fancy version where the offset adjusts dynamically based on the indices it needs to contain would be
interesting, but more complex. It would likely require starting from scratch, as the facilities provided by
CopyOnWriteArrayList
may be insufficient to achieve correct/efficient synchronization.- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
boolean
addAll
(int index, Collection<? extends E> c) boolean
get
(int index) int
hashCode()
int
int
lastIndexOf
(E e, int index) listIterator
(int index) remove
(int index) A function which behaves likeMap.remove(Object)
, rather thanList.remove(int)
, in the sense that it removes the item from the collection, returns the previous value (if any), but *does not* shift subsequent items to the left (as the regularList.remove(int)
would.A function which behaves likeMap.put(Object, Object)
, rather thanList.set(int, Object)
.subList
(int fromIndex, int toIndex) Methods inherited from class com.linkedin.venice.utils.SparseConcurrentList
add, addAll, addAllAbsent, clear, computeIfAbsent, forEach, isEmpty, nonNullSize, remove, removeAll, removeIf, replaceAll, retainAll, sort, values
Methods inherited from class java.util.concurrent.CopyOnWriteArrayList
addIfAbsent, clone, contains, containsAll, indexOf, iterator, lastIndexOf, listIterator, size, spliterator, toArray, toArray, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
-
Constructor Details
-
SparseConcurrentListWithOffset
public SparseConcurrentListWithOffset(int offset)
-
-
Method Details
-
add
-
addAll
-
get
-
indexOf
- Overrides:
indexOf
in classCopyOnWriteArrayList<E>
-
lastIndexOf
- Overrides:
lastIndexOf
in classCopyOnWriteArrayList<E>
-
listIterator
- Specified by:
listIterator
in interfaceList<E>
- Overrides:
listIterator
in classCopyOnWriteArrayList<E>
-
remove
Description copied from class:SparseConcurrentList
A function which behaves likeMap.remove(Object)
, rather thanList.remove(int)
, in the sense that it removes the item from the collection, returns the previous value (if any), but *does not* shift subsequent items to the left (as the regularList.remove(int)
would. -
set
Description copied from class:SparseConcurrentList
A function which behaves likeMap.put(Object, Object)
, rather thanList.set(int, Object)
. -
subList
-
equals
- Specified by:
equals
in interfaceCollection<E>
- Specified by:
equals
in interfaceList<E>
- Overrides:
equals
in classCopyOnWriteArrayList<E>
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceCollection<E>
- Specified by:
hashCode
in interfaceList<E>
- Overrides:
hashCode
in classCopyOnWriteArrayList<E>
-