Code example for HashSet

Methods: addAll, isEmpty, iterator, removeAll, size

0
     * 
     * @param keysInUse The set of all keys that are in use in the photo store. 
     * @return The set of the keys in use that refer to non-existent entries. 
     */ 
    public Set<Long> cleanup(Set<Long> keysInUse) {
        Set<Long> keysToRemove = new HashSet<Long>();
        keysToRemove.addAll(mEntries.keySet());
        keysToRemove.removeAll(keysInUse);
        if (!keysToRemove.isEmpty()) {
            Log.d(TAG, "cleanup removing " + keysToRemove.size() + " entries");
            for (long key : keysToRemove) {
                remove(key);
            } 
        } 
 
        Set<Long> missingKeys = new HashSet<Long>();
        missingKeys.addAll(keysInUse);
        missingKeys.removeAll(mEntries.keySet());
        return missingKeys;
    }