KeyedItemHashMap<T> Class
- java.
lang. Object - com.
microsoft. cognitiveservices. speech. util. KeyedItemHashMap<T>
- com.
Type Parameters
- T
Implements
public final class KeyedItemHashMap
implements java.util.Map<java.lang.String,T>
Hash table based implementation of the Map
interface. This implementation provides all of the optional map operations, and permits null
values and the null
key. (The HashMap
class is roughly equivalent to Hashtable
, except that it is unsynchronized and permits nulls.) This class makes no guarantees as to the order of the map; in particular, it does not guarantee that the order will remain constant over time. Unlike a typical hash map, this implementation uses KeyedItem's as the value. A KeyedItem must implement the KeyedItem
interface and provide a unique ID to avoid collisions within the map. For more details see the HashMap
class.
Constructor Summary
Constructor | Description |
---|---|
KeyedItemHashMap() |
Constructs an empty Hash |
Method Summary
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all of the mappings from this map. |
boolean |
containsKey(Object key)
Returns |
boolean |
containsValue(Object keyedItem)
Returns |
java.util.Set<java.util.Map.Entry<java.lang.String,T>> |
entrySet()
Returns a |
T |
get(Object obj)
Returns the string representation of the |
boolean |
isEmpty()
Returns |
java.util.Set<java.lang.String> |
keySet()
Returns a |
T |
put(T keyedItem)
Associates the specified value with the keyed |
T |
put(String key, T keyedItem)
Associates the specified value with the keyed |
void |
putAll(Map<? extends String,? extends T> map)
Copies all of the mappings from the specified map to this map. |
T |
remove(Object keyedItem)
Removes the mapping for the specified keyed |
int |
size()
Returns the number of key-value mappings in this map. |
java.util.Collection<T> |
values()
Returns a |
Methods inherited from java.lang.Object
Constructor Details
KeyedItemHashMap
public KeyedItemHashMap()
Constructs an empty HashMap with the default initial capacity (16) and the default load factor (0.75).
Method Details
clear
public void clear()
Removes all of the mappings from this map. The map will be empty after this call returns.
containsKey
public boolean containsKey(Object key)
Returns true
if this map contains a mapping for the specified key.
Parameters:
Returns:
true
if this map contains a mapping for the specified key.containsValue
public boolean containsValue(Object keyedItem)
Returns true
if this map maps a key to the specified value.
Parameters:
Returns:
true
if this map maps the value to an id of an item.entrySet
public Set
Returns a Set
view of the mappings contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove
operation, or through the setValue
operation on a map entry returned by the iterator) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove
, Set.remove
, removeAll
, retainAll
and clear
operations. It does not support the add
or addAll
operations.
Returns:
get
public T get(Object obj)
Returns the string representation of the Object
argument.
Parameters:
Object
.
Returns:
null
, then a string equal to
"null"
; otherwise, the value of
obj.toString()
is returned.isEmpty
public boolean isEmpty()
Returns true
if this map contains no key-value mappings.
Returns:
true
if this map contains no key-value mappings.keySet
public Set
Returns a Set
view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove
operation), the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove
, Set.remove
, removeAll
, retainAll
, and clear
operations. It does not support the add
or addAll
operations.
Returns:
put
public T put(T keyedItem)
Associates the specified value with the keyedItem's ID in this map. If the map previously contained a mapping for the keyedItem's ID, the old value is replaced.
Parameters:
Returns:
keyedItem.getId()
, or
null
if there was no mapping for keyedItem.getId()
.
(A null
return can also indicate that the map
previously associated null
with keyedItem.getId()
.)put
public T put(String key, T keyedItem)
Associates the specified value with the keyedItem's ID in this map. If the map previously contained a mapping for the keyedItem's ID, the old value is replaced.
Parameters:
Returns:
keyedItem.getId()
, or
null
if there was no mapping for keyedItem.getId()
.
(A null
return can also indicate that the map
previously associated null
with keyedItem.getId()
.)putAll
public void putAll(Map map)
Copies all of the mappings from the specified map to this map. These mappings will replace any mappings that this map had for any of the keys currently in the specified map.
Parameters:
remove
public T remove(Object keyedItem)
Removes the mapping for the specified keyedItem's ID from this map if present.
Parameters:
Returns:
keyedItem.getId()
, or
null
if there was no mapping for keyedItem.getId()
.
(A null
return can also indicate that the map
previously associated null
with keyedItem.getId()
.)size
public int size()
Returns the number of key-value mappings in this map.
Returns:
values
public Collection
Returns a Collection
view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. If the map is modified while an iteration over the collection is in progress (except through the iterator's own remove
operation), the results of the iteration are undefined. The collection supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove
, Collection.remove
, removeAll
, retainAll
and clear
operations. It does not support the add
or addAll
operations.
Returns:
Applies to
Azure SDK for Java