private static void removeTimestamp(long userID, long itemID, FastByIDMap<FastByIDMap<Long>> timestamps) { FastByIDMap<Long> itemTimestamps = timestamps.get(userID); if (itemTimestamps != null) { itemTimestamps.remove(itemID); } }
private static void removeTimestamp(long userID, long itemID, FastByIDMap<FastByIDMap<Long>> timestamps) { FastByIDMap<Long> itemTimestamps = timestamps.get(userID); if (itemTimestamps != null) { itemTimestamps.remove(itemID); } }
private static void removeTimestamp(long userID, long itemID, FastByIDMap<FastByIDMap<Long>> timestamps) { FastByIDMap<Long> itemTimestamps = timestamps.get(userID); if (itemTimestamps != null) { itemTimestamps.remove(itemID); } }
@Test public void testVersusHashMap() { FastByIDMap<String> actual = new FastByIDMap<String>(); Map<Long, String> expected = Maps.newHashMapWithExpectedSize(1000000); Random r = RandomUtils.getRandom(); for (int i = 0; i < 1000000; i++) { double d = r.nextDouble(); Long key = (long) r.nextInt(100); if (d < 0.4) { assertEquals(expected.get(key), actual.get(key)); } else { if (d < 0.7) { assertEquals(expected.put(key, "bang"), actual.put(key, "bang")); } else { assertEquals(expected.remove(key), actual.remove(key)); } assertEquals(expected.size(), actual.size()); assertEquals(expected.isEmpty(), actual.isEmpty()); } } }
data.remove(userID); } else { PreferenceArray newPrefs = new GenericUserPreferenceArray(length - 1);
data.remove(userID); } else { PreferenceArray newPrefs = new GenericUserPreferenceArray(length - 1);
data.remove(userID); } else { PreferenceArray newPrefs = new GenericUserPreferenceArray(length - 1);
@Test public void testRehash() { FastByIDMap<String> map = buildTestFastMap(); map.remove(500000L); map.rehash(); assertNull(map.get(500000L)); assertEquals("bang", map.get(47L)); }
@Test public void testRemove() { FastByIDMap<Long> map = new FastByIDMap<Long>(); map.put(500000L, 2L); map.remove(500000L); assertEquals(0, map.size()); assertTrue(map.isEmpty()); assertNull(map.get(500000L)); }
@Test public void testSizeEmpty() { FastByIDMap<Long> map = new FastByIDMap<Long>(); assertEquals(0, map.size()); assertTrue(map.isEmpty()); map.put(500000L, 2L); assertEquals(1, map.size()); assertFalse(map.isEmpty()); map.remove(500000L); assertEquals(0, map.size()); assertTrue(map.isEmpty()); }