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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanaddAll(int index, Collection<? extends E> c) booleanget(int index) inthashCode()intintlastIndexOf(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, valuesMethods inherited from class java.util.concurrent.CopyOnWriteArrayList
addIfAbsent, clone, contains, containsAll, indexOf, iterator, lastIndexOf, listIterator, size, spliterator, toArray, toArray, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, stream, toArray
-
Constructor Details
-
SparseConcurrentListWithOffset
public SparseConcurrentListWithOffset(int offset)
-
-
Method Details
-
add
-
addAll
-
get
-
indexOf
- Overrides:
indexOfin classCopyOnWriteArrayList<E>
-
lastIndexOf
- Overrides:
lastIndexOfin classCopyOnWriteArrayList<E>
-
listIterator
- Specified by:
listIteratorin interfaceList<E>- Overrides:
listIteratorin classCopyOnWriteArrayList<E>
-
remove
Description copied from class:SparseConcurrentListA 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:SparseConcurrentListA function which behaves likeMap.put(Object, Object), rather thanList.set(int, Object). -
subList
-
equals
- Specified by:
equalsin interfaceCollection<E>- Specified by:
equalsin interfaceList<E>- Overrides:
equalsin classCopyOnWriteArrayList<E>
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<E>- Specified by:
hashCodein interfaceList<E>- Overrides:
hashCodein classCopyOnWriteArrayList<E>
-