1286 |
|
// must pack elements using exportable SimpleEntry |
1287 |
|
Collection<Map.Entry<K,V>> c = new ArrayList<Map.Entry<K,V>>(size()); |
1288 |
|
for (Iterator<Map.Entry<K,V>> i = iterator(); i.hasNext(); ) |
1289 |
< |
c.add(new SimpleEntry<K,V>(i.next())); |
1289 |
> |
c.add(new AbstractMap.SimpleEntry<K,V>(i.next())); |
1290 |
|
return c.toArray(); |
1291 |
|
} |
1292 |
|
public <T> T[] toArray(T[] a) { |
1293 |
|
Collection<Map.Entry<K,V>> c = new ArrayList<Map.Entry<K,V>>(size()); |
1294 |
|
for (Iterator<Map.Entry<K,V>> i = iterator(); i.hasNext(); ) |
1295 |
< |
c.add(new SimpleEntry<K,V>(i.next())); |
1295 |
> |
c.add(new AbstractMap.SimpleEntry<K,V>(i.next())); |
1296 |
|
return c.toArray(a); |
1297 |
|
} |
1298 |
|
|
1299 |
|
} |
1300 |
|
|
1301 |
– |
/** |
1302 |
– |
* This duplicates java.util.AbstractMap.SimpleEntry until this class |
1303 |
– |
* is made accessible. |
1304 |
– |
*/ |
1305 |
– |
static final class SimpleEntry<K,V> implements Entry<K,V> { |
1306 |
– |
K key; |
1307 |
– |
V value; |
1308 |
– |
|
1309 |
– |
public SimpleEntry(K key, V value) { |
1310 |
– |
this.key = key; |
1311 |
– |
this.value = value; |
1312 |
– |
} |
1313 |
– |
|
1314 |
– |
public SimpleEntry(Entry<K,V> e) { |
1315 |
– |
this.key = e.getKey(); |
1316 |
– |
this.value = e.getValue(); |
1317 |
– |
} |
1318 |
– |
|
1319 |
– |
public K getKey() { |
1320 |
– |
return key; |
1321 |
– |
} |
1322 |
– |
|
1323 |
– |
public V getValue() { |
1324 |
– |
return value; |
1325 |
– |
} |
1326 |
– |
|
1327 |
– |
public V setValue(V value) { |
1328 |
– |
V oldValue = this.value; |
1329 |
– |
this.value = value; |
1330 |
– |
return oldValue; |
1331 |
– |
} |
1332 |
– |
|
1333 |
– |
public boolean equals(Object o) { |
1334 |
– |
if (!(o instanceof Map.Entry)) |
1335 |
– |
return false; |
1336 |
– |
Map.Entry e = (Map.Entry)o; |
1337 |
– |
return eq(key, e.getKey()) && eq(value, e.getValue()); |
1338 |
– |
} |
1339 |
– |
|
1340 |
– |
public int hashCode() { |
1341 |
– |
return ((key == null) ? 0 : key.hashCode()) ^ |
1342 |
– |
((value == null) ? 0 : value.hashCode()); |
1343 |
– |
} |
1344 |
– |
|
1345 |
– |
public String toString() { |
1346 |
– |
return key + "=" + value; |
1347 |
– |
} |
1348 |
– |
|
1349 |
– |
static boolean eq(Object o1, Object o2) { |
1350 |
– |
return (o1 == null ? o2 == null : o1.equals(o2)); |
1351 |
– |
} |
1352 |
– |
} |
1353 |
– |
|
1301 |
|
/* ---------------- Serialization Support -------------- */ |
1302 |
|
|
1303 |
|
/** |