コード例 #1
0
 @Test
 public void values() throws InterruptedException {
   HazelcastClient hClient = getHazelcastClient();
   MultiMap<String, String> multiMap = hClient.getMultiMap("entrySet");
   Map<String, List<String>> valueKeyListMap = new HashMap<String, List<String>>();
   int count = 100;
   for (int i = 0; i < count; i++) {
     for (int j = 0; j <= i; j++) {
       String key = String.valueOf(i);
       String value = String.valueOf(j);
       multiMap.put(key, value);
       if (valueKeyListMap.get(value) == null) {
         valueKeyListMap.put(value, new ArrayList<String>());
       }
       valueKeyListMap.get(value).add(key);
     }
   }
   assertEquals(count * (count + 1) / 2, multiMap.size());
   Collection<String> collection = multiMap.values();
   assertEquals(count * (count + 1) / 2, collection.size());
   Iterator<String> iterator = collection.iterator();
   System.out.println(iterator.getClass());
   for (; iterator.hasNext(); ) {
     String value = iterator.next();
     assertNotNull(valueKeyListMap.get(value).remove(0));
     if (valueKeyListMap.get(value).size() == 0) {
       valueKeyListMap.remove(value);
     }
   }
   assertTrue(valueKeyListMap.isEmpty());
 }