Code example for HashSet

Methods: contains, remove

0
    public boolean setBitmap(Bitmap bitmap, int index, int token) {
        // Ignore results from previous requests 
        if (token != mGeneration) {
            return false; 
        } 
        if (!mPending.contains(index)) {
            Log.e(TAG, "received unasked bitmap, index = " + index);
            return false; 
        } 
        if (bitmap == null) {
            Log.w(TAG, "receive null bitmap for index = " + index);
            // We keep this request in mPending, so we won't request it again. 
            return false; 
        } 
        mPending.remove(index);
        ThumbnailKey key = new ThumbnailKey(mMediaItem.getId(), index);
        sThumbnailCache.put(key, bitmap);
 
        invalidate();
        return true; 
    }