com.opera.core.systems.util
Class StackHashMap<K,V>
java.lang.Object
com.opera.core.systems.util.StackHashMap<K,V>
- Type Parameters:
K - V -
- All Implemented Interfaces:
- ConcurrentMap<K,V>, Map<K,V>
public class StackHashMap<K,V>
- extends Object
- implements ConcurrentMap<K,V>
A thread safe stack hash map for use in window manager The backing map is a
LinkedHashMap that provides predictable iteration order. All the
operations that require thread safety are protected by the lock of
synchronized map.
- Author:
- Deniz Turkoglu
| Nested classes/interfaces inherited from interface java.util.Map |
Map.Entry<K,V> |
|
Method Summary |
Map<K,V> |
asMap()
|
List<K> |
asStack()
|
void |
clear()
|
boolean |
containsKey(Object key)
|
boolean |
containsValue(Object value)
|
Set<Map.Entry<K,V>> |
entrySet()
|
V |
get(Object key)
|
boolean |
isEmpty()
|
Set<K> |
keySet()
|
V |
peek()
|
K |
peekKey()
|
V |
pop()
Removes the first value from the map |
V |
push(K k,
V v)
|
V |
put(K key,
V value)
|
void |
putAll(Map<? extends K,? extends V> t)
|
V |
putIfAbsent(K k,
V v)
Puts a key to top of the map if absent if the key is present in stack it is
removed |
V |
remove(Object key)
|
boolean |
remove(Object key,
Object value)
|
V |
replace(K key,
V value)
|
boolean |
replace(K key,
V oldValue,
V newValue)
|
int |
size()
|
Collection<V> |
values()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
StackHashMap
public StackHashMap()
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey in interface Map<K,V>
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValue in interface Map<K,V>
get
public V get(Object key)
- Specified by:
get in interface Map<K,V>
put
public V put(K key,
V value)
- Specified by:
put in interface Map<K,V>
putAll
public void putAll(Map<? extends K,? extends V> t)
- Specified by:
putAll in interface Map<K,V>
keySet
public Set<K> keySet()
- Specified by:
keySet in interface Map<K,V>
values
public Collection<V> values()
- Specified by:
values in interface Map<K,V>
entrySet
public Set<Map.Entry<K,V>> entrySet()
- Specified by:
entrySet in interface Map<K,V>
size
public int size()
- Specified by:
size in interface Map<K,V>
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty in interface Map<K,V>
remove
public V remove(Object key)
- Specified by:
remove in interface Map<K,V>
clear
public void clear()
- Specified by:
clear in interface Map<K,V>
pop
public V pop()
- Removes the first value from the map
- Returns:
- the value that was removed
push
public V push(K k,
V v)
peek
public V peek()
- Returns:
- the first value in the backing map
peekKey
public K peekKey()
- Returns:
- the first key in the backing linked list
asStack
public List<K> asStack()
- Returns:
- an unmodifiable copy of the backing linkedlist(used as a stack)
asMap
public Map<K,V> asMap()
- Returns:
- an unmodifiable copy of the backing map
putIfAbsent
public V putIfAbsent(K k,
V v)
- Puts a key to top of the map if absent if the key is present in stack it is
removed
- Specified by:
putIfAbsent in interface ConcurrentMap<K,V>
- Parameters:
k - v -
- Returns:
- the value if it is not contained, null otherwise
remove
public boolean remove(Object key,
Object value)
- Specified by:
remove in interface ConcurrentMap<K,V>
replace
public boolean replace(K key,
V oldValue,
V newValue)
- Specified by:
replace in interface ConcurrentMap<K,V>
replace
public V replace(K key,
V value)
- Specified by:
replace in interface ConcurrentMap<K,V>
Copyright © 2012. All Rights Reserved.