|
@@ -33,6 +33,7 @@ import java.util.Set;
|
33
|
33
|
/**
|
34
|
34
|
* An object that maps keys to values, and values back to keys. Currently
|
35
|
35
|
* does no checking for duplicates. Does not allow null values.
|
|
36
|
+ * <p>Note that this implementation is NOT thread safe.
|
36
|
37
|
*
|
37
|
38
|
* @param <A> The first type of data to be mapped
|
38
|
39
|
* @param <B> The second type of data to be mapped
|
|
@@ -103,18 +104,21 @@ public class DoubleMap<A,B> implements Map<A,B> {
|
103
|
104
|
|
104
|
105
|
/** {@inheritDoc} */
|
105
|
106
|
@Override
|
|
107
|
+ @SuppressWarnings("unchecked")
|
106
|
108
|
public boolean containsKey(final Object key) {
|
107
|
109
|
return keys.contains((A) key);
|
108
|
110
|
}
|
109
|
111
|
|
110
|
112
|
/** {@inheritDoc} */
|
111
|
113
|
@Override
|
|
114
|
+ @SuppressWarnings("unchecked")
|
112
|
115
|
public boolean containsValue(final Object value) {
|
113
|
116
|
return values.contains((B) value);
|
114
|
117
|
}
|
115
|
118
|
|
116
|
119
|
/** {@inheritDoc} */
|
117
|
120
|
@Override
|
|
121
|
+ @SuppressWarnings("unchecked")
|
118
|
122
|
public B get(final Object key) {
|
119
|
123
|
return getValue((A) key);
|
120
|
124
|
}
|
|
@@ -156,7 +160,7 @@ public class DoubleMap<A,B> implements Map<A,B> {
|
156
|
160
|
public Set<Entry<A, B>> entrySet() {
|
157
|
161
|
final HashSet<Entry<A, B>> set = new HashSet<Entry<A, B>>();
|
158
|
162
|
for (A key : keys) {
|
159
|
|
- set.add(new SimpleEntry(key, getValue(key)));
|
|
163
|
+ set.add(new SimpleEntry<A, B>(key, getValue(key)));
|
160
|
164
|
}
|
161
|
165
|
return set;
|
162
|
166
|
}
|