public abstract class AbstractUserHistory<E extends Event> extends AbstractList<E> implements UserHistory<E>
An abstract implementation of UserHistory
to provide default implementations of convenience methods.
modCount
Constructor and Description |
---|
AbstractUserHistory() |
Modifier and Type | Method and Description |
---|---|
LongSet |
itemSet()
Get the set of items touched by events in this history.
|
<T> T |
memoize(Function<? super UserHistory<E>,? extends T> func)
Apply a function to this history, memoizing its return value.
|
add, add, addAll, clear, equals, get, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, size, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
filter, filter, getUserId
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray
parallelStream, removeIf, stream
public LongSet itemSet()
UserHistory
Get the set of items touched by events in this history. Only nonnegative item IDs are considered.
itemSet
in interface UserHistory<E extends Event>
public <T> T memoize(Function<? super UserHistory<E>,? extends T> func)
UserHistory
Apply a function to this history, memoizing its return value. Used for caching things like summaries. The function should appropriately define its Function.equals(Object)
and Object.hashCode()
methods in order for memoization to work well.
This method is not guaranteed to be synchronized. It is safe to memoize distinct functions in parallel, but potentially-parallel use of the same function must be synchronized by client code or the function may be called twice. The implementation in AbstractUserHistory
uses a ConcurrentHashMap
. Multiple calls are therefore safe, but may result in extra work. All implementations must maintain this safety guarantee, although they may do so by synchronizing this method.
memoize
in interface UserHistory<E extends Event>
func
- The function to call and memoize.