/** * Checks whether the map is currently empty. * * @return true if the map is currently size zero */ public boolean isEmpty() { return (size() == 0); }
public int size() { return parent.size(); }
public int size() { return parent.size(); }
public int size() { return parent.size(); }
/** * Checks whether the map is currently empty. * * @return true if the map is currently size zero */ public boolean isEmpty() { return (size() == 0); }
public int size() { return parent.size(); }
public int size() { return parent.size(); }
public int size() { return parent.size(); }
public Iterator iterator() { if (parent.delegateMap != null) { return parent.delegateMap.values().iterator(); } if (parent.size() == 0) { return EmptyIterator.INSTANCE; } return new ValuesIterator(parent); } }
public Iterator iterator() { if (parent.delegateMap != null) { return parent.delegateMap.entrySet().iterator(); } if (parent.size() == 0) { return EmptyIterator.INSTANCE; } return new EntrySetIterator(parent); } }
public Iterator iterator() { if (parent.delegateMap != null) { return parent.delegateMap.keySet().iterator(); } if (parent.size() == 0) { return EmptyIterator.INSTANCE; } return new KeySetIterator(parent); } }
public Iterator iterator() { if (parent.delegateMap != null) { return parent.delegateMap.keySet().iterator(); } if (parent.size() == 0) { return EmptyIterator.INSTANCE; } return new KeySetIterator(parent); } }
public Iterator iterator() { if (parent.delegateMap != null) { return parent.delegateMap.values().iterator(); } if (parent.size() == 0) { return EmptyIterator.INSTANCE; } return new ValuesIterator(parent); } }
/** * Write the map out using a custom routine. */ private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); out.writeInt(size()); for (MapIterator it = mapIterator(); it.hasNext();) { out.writeObject(it.next()); // key out.writeObject(it.getValue()); // value } }
public Iterator iterator() { if (parent.delegateMap != null) { return parent.delegateMap.entrySet().iterator(); } if (parent.size() == 0) { return EmptyIterator.INSTANCE; } return new EntrySetIterator(parent); } }
/** * Write the map out using a custom routine. */ private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); out.writeInt(size()); for (MapIterator it = mapIterator(); it.hasNext();) { out.writeObject(it.next()); // key out.writeObject(it.getValue()); // value } }
public void testSerialisation0() throws Exception { Flat3Map map = new Flat3Map(); ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(bout); out.writeObject(map); byte[] bytes = bout.toByteArray(); out.close(); ByteArrayInputStream bin = new ByteArrayInputStream(bytes); ObjectInputStream in = new ObjectInputStream(bin); Flat3Map ser = (Flat3Map) in.readObject(); in.close(); assertEquals(0, map.size()); assertEquals(0, ser.size()); }
public void testEntryIteratorSetValue3() throws Exception { final Flat3Map map = new Flat3Map(); map.put(ONE, TEN); map.put(TWO, TWENTY); map.put(THREE, THIRTY); final Iterator it = map.entrySet().iterator(); it.next(); it.next(); final Map.Entry entry = (Map.Entry) it.next(); entry.setValue("NewValue"); assertEquals(3, map.size()); assertEquals(true, map.containsKey(ONE)); assertEquals(true, map.containsKey(TWO)); assertEquals(true, map.containsKey(THREE)); assertEquals(TEN, map.get(ONE)); assertEquals(TWENTY, map.get(TWO)); assertEquals("NewValue", map.get(THREE)); }
public void testEntryIteratorSetValue2() throws Exception { final Flat3Map map = new Flat3Map(); map.put(ONE, TEN); map.put(TWO, TWENTY); map.put(THREE, THIRTY); final Iterator it = map.entrySet().iterator(); it.next(); final Map.Entry entry = (Map.Entry) it.next(); entry.setValue("NewValue"); assertEquals(3, map.size()); assertEquals(true, map.containsKey(ONE)); assertEquals(true, map.containsKey(TWO)); assertEquals(true, map.containsKey(THREE)); assertEquals(TEN, map.get(ONE)); assertEquals("NewValue", map.get(TWO)); assertEquals(THIRTY, map.get(THREE)); }
public void testEntryIteratorSetValue1() throws Exception { final Flat3Map map = new Flat3Map(); map.put(ONE, TEN); map.put(TWO, TWENTY); map.put(THREE, THIRTY); final Iterator it = map.entrySet().iterator(); final Map.Entry entry = (Map.Entry) it.next(); entry.setValue("NewValue"); assertEquals(3, map.size()); assertEquals(true, map.containsKey(ONE)); assertEquals(true, map.containsKey(TWO)); assertEquals(true, map.containsKey(THREE)); assertEquals("NewValue", map.get(ONE)); assertEquals(TWENTY, map.get(TWO)); assertEquals(THIRTY, map.get(THREE)); }