Code example for Set

Methods: iterator

0
        // for a java Map. It only works with equality (you need the exact key object to retrieve 
        // the value) I recommend we switch to using ByteBuffer or something similar: 
        // http://stackoverflow.com/questions/1058149/using-a-byte-array-as-hashmap-key-java 
        Map<byte[],byte[]> map = fmap.get();
        Set<byte[]> mapKeys = map.keySet();
        Iterator<byte[]> iterMap = mapKeys.iterator();
        byte[] firstMapKey = iterMap.next();
        byte[] secondMapKey = iterMap.next();
        assertFalse(iterMap.hasNext());
        verifyHasBothValues(firstMapKey, secondMapKey, "f1".getBytes(), "f22".getBytes());
        byte[] firstMapValue = map.get(firstMapKey);
        byte[] secondMapValue = map.get(secondMapKey);
        verifyHasBothValues(firstMapValue, secondMapValue, "v111".getBytes(), "v2222".getBytes());
 
        assertNotNull(fkeys.get());
        Iterator<byte[]> iter = fkeys.get().iterator();
        byte[] firstKey = iter.next();
        byte[] secondKey = iter.next();
        assertFalse(iter.hasNext());
        verifyHasBothValues(firstKey, secondKey, "f1".getBytes(), "f22".getBytes());