Code example for CopyOnWriteArrayList

Methods: add, contains

0
    } 
 
    // Warning: this is not thread-safe. Take necessary precaution when calling. 
    public void addDictionary(final Dictionary newDict) {
        if (null == newDict) return;
        if (mDictionaries.contains(newDict)) {
            Log.w(TAG, "This collection already contains this dictionary: " + newDict);
        } 
        mDictionaries.add(newDict);
    } 
 
    // Warning: this is not thread-safe. Take necessary precaution when calling. 
    public void removeDictionary(final Dictionary dict) {
        if (mDictionaries.contains(dict)) {
            mDictionaries.remove(dict);
        } else { 
            Log.w(TAG, "This collection does not contain this dictionary: " + dict);
        } 
    } 
}