Code example for Map

Methods: containsKey, remove

0
 
    @Implementation 
    public void cancel(String tag, int id) {
        // I can't make sense of this method signature. I'm guessing that the id is optional and if it's bogus you are supposed to use the tag instead, but that references to both should be gone. PG 
        Integer tagId = idForTag.remove(tag);
        if (notifications.containsKey(id)) {
            notifications.remove(id);
        } else { 
            notifications.remove(tagId);
        } 
    } 
 
    @Implementation 
    public void cancelAll() { 
        notifications.clear();
        idForTag.clear();
    } 
 
    public int size() { 
        return notifications.size();
    }