@Immutable public class KeyedObjectMap<T> extends AbstractLong2ObjectSortedMap<T> implements java.io.Serializable, java.lang.Iterable<T>
A map that allows objects with long keys to be looked up by key. This structure works on objects that have an associated key, such as recommendation results or ratings (keyed by user or item ID). The key is extracted from an object by means of a KeyExtractor. This allows the objects to be stored directly, without separate storage for keys. This map stores objects in a list sorted by key, and looks them up with binary search. Therefore, the key extractor should generally be fast (e.g. just calling a getter), in order for this class to be performant.
AbstractLong2ObjectSortedMap.KeySetIterator<V>, AbstractLong2ObjectSortedMap.ValuesCollection, AbstractLong2ObjectSortedMap.ValuesIterator<V>AbstractLong2ObjectMap.BasicEntry<V>Long2ObjectSortedMap.FastSortedEntrySet<V>Long2ObjectMap.Entry<V>, Long2ObjectMap.FastEntrySet<V>defRetValue| Constructor and Description |
|---|
KeyedObjectMap(java.lang.Iterable<? extends T> objs,
KeyExtractor<? super T> ex)
Create a new keyed object map from a collection of data.
|
| Modifier and Type | Method and Description |
|---|---|
LongComparator |
comparator() |
boolean |
containsKey(long k) |
boolean |
containsValue(java.lang.Object v) |
static <T extends KeyedObject> |
create(java.util.Collection<? extends T> objs)
Create a new keyed object map.
|
static <T> KeyedObjectMap<T> |
create(java.lang.Iterable<? extends T> objs,
KeyExtractor<? super T> ex)
Create a new keyed object map.
|
long |
firstLongKey() |
T |
get(long k) |
KeyedObjectMap<T> |
headMap(long l) |
ObjectBidirectionalIterator<T> |
iterator() |
LongSortedSet |
keySet() |
long |
lastLongKey() |
ObjectSortedSet<Long2ObjectMap.Entry<T>> |
long2ObjectEntrySet() |
static <T extends KeyedObject> |
newBuilder()
Create a new builder for a keyed object map over a self-keying type.
|
static <T> KeyedObjectMapBuilder<T> |
newBuilder(KeyExtractor<? super T> ex)
Create a new builder for a keyed object map.
|
int |
size() |
KeyedObjectMap<T> |
subMap(long from,
long to) |
KeyedObjectMap<T> |
tailMap(long l) |
ObjectCollection<T> |
values() |
equals, hashCode, isEmpty, putAll, toStringdefaultReturnValue, defaultReturnValueclone, finalize, getClass, notify, notifyAll, wait, wait, waitentrySet, firstKey, headMap, lastKey, subMap, tailMapclear, compute, compute, computeIfAbsent, computeIfAbsent, computeIfAbsentPartial, computeIfPresent, computeIfPresent, containsKey, defaultReturnValue, defaultReturnValue, get, getOrDefault, getOrDefault, merge, merge, put, putIfAbsent, putIfAbsent, remove, remove, remove, replace, replace, replace, replaceapply, put, removepublic KeyedObjectMap(java.lang.Iterable<? extends T> objs, KeyExtractor<? super T> ex)
Create a new keyed object map from a collection of data.
objs - The input data.public static <T> KeyedObjectMapBuilder<T> newBuilder(KeyExtractor<? super T> ex)
Create a new builder for a keyed object map.
ex - The key extractor.T - The keyed object type.public static <T extends KeyedObject> KeyedObjectMapBuilder<T> newBuilder()
Create a new builder for a keyed object map over a self-keying type.
T - The keyed object type.public static <T extends KeyedObject> KeyedObjectMap<T> create(java.util.Collection<? extends T> objs)
Create a new keyed object map.
objs - A collection of objects to put in the map.T - The keyed object type.objs.public static <T> KeyedObjectMap<T> create(java.lang.Iterable<? extends T> objs, KeyExtractor<? super T> ex)
Create a new keyed object map.
objs - A collection of objects to put in the map.ex - The key extractor.T - The keyed object type.objs.public ObjectSortedSet<Long2ObjectMap.Entry<T>> long2ObjectEntrySet()
long2ObjectEntrySet in interface Long2ObjectMap<T>long2ObjectEntrySet in interface Long2ObjectSortedMap<T>public LongSortedSet keySet()
keySet in interface Long2ObjectMap<T>keySet in interface Long2ObjectSortedMap<T>keySet in interface java.util.Map<java.lang.Long,T>keySet in interface java.util.SortedMap<java.lang.Long,T>keySet in class AbstractLong2ObjectSortedMap<T>public ObjectCollection<T> values()
values in interface Long2ObjectMap<T>values in interface Long2ObjectSortedMap<T>values in interface java.util.Map<java.lang.Long,T>values in interface java.util.SortedMap<java.lang.Long,T>values in class AbstractLong2ObjectSortedMap<T>public ObjectBidirectionalIterator<T> iterator()
iterator in interface java.lang.Iterable<T>public LongComparator comparator()
comparator in interface Long2ObjectSortedMap<T>comparator in interface java.util.SortedMap<java.lang.Long,T>public KeyedObjectMap<T> subMap(long from, long to)
subMap in interface Long2ObjectSortedMap<T>public KeyedObjectMap<T> headMap(long l)
headMap in interface Long2ObjectSortedMap<T>public KeyedObjectMap<T> tailMap(long l)
tailMap in interface Long2ObjectSortedMap<T>public long firstLongKey()
firstLongKey in interface Long2ObjectSortedMap<T>public long lastLongKey()
lastLongKey in interface Long2ObjectSortedMap<T>public T get(long k)
get in interface Long2ObjectFunction<T>public boolean containsKey(long k)
containsKey in interface Long2ObjectFunction<T>containsKey in interface Long2ObjectMap<T>containsKey in class AbstractLong2ObjectMap<T>public boolean containsValue(java.lang.Object v)
containsValue in interface java.util.Map<java.lang.Long,T>containsValue in class AbstractLong2ObjectMap<T>public int size()
size in interface Long2ObjectMap<T>size in interface java.util.Map<java.lang.Long,T>