public class UtlLinkedLongMap<V> extends Object
UtlLinkedHashMap
but foregoes conformance
to Map
api to allow primitive long keys so that garbage needn't be created
converting primitive long keys to their Long
variants.
This class doesn't support Cloning or Serialization
This class IS NOT intended to be used by end users.
Modifier and Type | Class and Description |
---|---|
static class |
UtlLinkedLongMap.Entry<V>
This class represents a
UtlLinkedLongMap entry. |
class |
UtlLinkedLongMap.FastIterator
This inner class represents a reusable list iterator over
UtlLinkedLongMap entries. |
Constructor and Description |
---|
UtlLinkedLongMap()
Creates a
UtlLinkedLongMap with a capacity of 16 entries. |
UtlLinkedLongMap(int capacity)
Creates a
UtlLinkedLongMap with the specified capacity. |
Modifier and Type | Method and Description |
---|---|
int |
capacity()
Returns the capacity of this
UtlLinkedLongMap . |
void |
clear()
Removes all mappings from this
UtlLinkedLongMap . |
boolean |
containsKey(long key)
Indicates if this
UtlLinkedLongMap contains a mapping for the specified
key. |
boolean |
containsValue(Object value)
Indicates if this
UtlLinkedLongMap maps one or more keys to the
specified value. |
Set<UtlLinkedLongMap.Entry<V>> |
entrySet()
Returns a collection view of the mappings contained in this
UtlLinkedLongMap . |
UtlLinkedLongMap.FastIterator |
fastIterator()
Returns a reusable
UtlLinkedLongMap.FastIterator over this UtlLinkedLongMap entries
(unique instance per map). |
V |
get(long key)
Returns the value to which this
UtlLinkedLongMap maps the specified key. |
UtlLinkedLongMap.Entry<V> |
getEntry(long key)
Returns the entry with the specified key.
|
int |
hashCode()
Returns the hash code value for this
UtlLinkedLongMap . |
boolean |
isEmpty()
Indicates if this
UtlLinkedLongMap contains no key-value mappings. |
V |
put(long key,
V value)
Associates the specified value with the specified key in this
UtlLinkedLongMap . |
V |
remove(long key)
Removes the mapping for this key from this
UtlLinkedLongMap if present. |
void |
setCapacity(int newCapacity)
Changes the current capacity of this
UtlLinkedLongMap . |
int |
size()
Returns the number of key-value mappings in this
UtlLinkedLongMap . |
String |
toString()
Returns a
String representation of this UtlLinkedLongMap . |
Collection<V> |
values()
Returns a collection view of the values contained in this
UtlLinkedLongMap . |
public UtlLinkedLongMap()
UtlLinkedLongMap
with a capacity of 16
entries.public UtlLinkedLongMap(int capacity)
UtlLinkedLongMap
with the specified capacity. Unless the
capacity is exceeded, operations on this map do not allocate entries.
For optimum performance, the capacity should be of the same order
of magnitude or larger than the expected map's size.capacity
- the number of buckets in the hash table; it also
defines the number of pre-allocated entries.public int size()
UtlLinkedLongMap
.public int capacity()
UtlLinkedLongMap
. The capacity defines
the number of buckets in the hash table, as well as the maximum number
of entries the map may contain without allocating memory.public boolean isEmpty()
UtlLinkedLongMap
contains no key-value mappings.true
if this map contains no key-value mappings;
false
otherwise.public boolean containsKey(long key)
UtlLinkedLongMap
contains a mapping for the specified
key.key
- the key whose presence in this map is to be tested.true
if this map contains a mapping for the
specified key; false
otherwise.NullPointerException
- if the key is null
.public boolean containsValue(Object value)
UtlLinkedLongMap
maps one or more keys to the
specified value.value
- the value whose presence in this map is to be tested.true
if this map maps one or more keys to the
specified value.NullPointerException
- if the key is null
.public V get(long key)
UtlLinkedLongMap
maps the specified key.key
- the key whose associated value is to be returned.null
if there is no mapping for the key.NullPointerException
- if key is null
.public UtlLinkedLongMap.Entry<V> getEntry(long key)
key
- the key whose associated entry is to be returned.null
if none.public V put(long key, V value)
UtlLinkedLongMap
. If the UtlLinkedLongMap
previously contained a mapping
for this key, the old value is replaced.key
- the key with which the specified value is to be associated.value
- the value to be associated with the specified key.null
if there was no mapping for key.
A null
return can also indicate that the map
previously associated null
with the specified key.NullPointerException
- if the key is null
.public UtlLinkedLongMap.FastIterator fastIterator()
UtlLinkedLongMap.FastIterator
over this UtlLinkedLongMap
entries
(unique instance per map). For example:// Iteration without memory allocation! for (FastIterator i=map.fastIterator().toFirst(); i.hasNext();) { Entry entry = i.nextEntry(); ... }
UtlLinkedLongMap.FastIterator
public V remove(long key)
UtlLinkedLongMap
if present.key
- the key whose mapping is to be removed from the map.null
if there was no mapping for key.
A null
return can also indicate that the map
previously associated null
with the specified key.NullPointerException
- if the key is null
.public void clear()
UtlLinkedLongMap
.public void setCapacity(int newCapacity)
UtlLinkedLongMap
. If the capacity
is increased, new entries are allocated and added to the pool.
If the capacity is decreased, entries from the pool are deallocated
(and are garbage collected eventually). The capacity also determined
the number of buckets for the hash table.newCapacity
- the new capacity of this map.public int hashCode()
UtlLinkedLongMap
.public String toString()
String
representation of this UtlLinkedLongMap
.public Collection<V> values()
UtlLinkedLongMap
. The collection is backed by the map, so changes to
the map are reflected in the collection, and vice-versa.
The collection supports element removal, which removes the corresponding
mapping from this map, via the
Iterator.remove
, Collection.remove
,
removeAll
, retainAll
,
and clear
operations. It does not support the
add
or addAll
operations.public Set<UtlLinkedLongMap.Entry<V>> entrySet()
UtlLinkedLongMap
. Each element in the returned collection is a
Map.Entry
. The collection is backed by the map,
so changes to the map are reflected in the collection, and vice-versa.
The collection supports element removal, which removes the corresponding
mapping from this map, via the
Iterator.remove
, Collection.remove
,
removeAll
, retainAll
,
and clear
operations. It does not support the
add
or addAll
operations.Copyright © 2019 Neeve Research, LLC. All Rights Reserved.