@@ -0,0 +1,2210 @@
+package org.ccci.gto.android.common.support.v4.util;%0A%0Aimport android.support.v4.util.LruCache;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Apublic class MultiKeyLruCache%3CK, V%3E extends LruCache%3CK, V%3E %7B%0A    private final Map%3CV, Integer%3E mCopies = new HashMap%3C%3E();%0A    private int mSizeGap = 0;%0A%0A    public MultiKeyLruCache(final int maxSize) %7B%0A        super(maxSize);%0A    %7D%0A%0A    public V putMulti(final K key, final V value) %7B%0A        incCount(key, value);%0A        return this.put(key, value);%0A    %7D%0A%0A    @Override%0A    protected void entryRemoved(boolean evicted, K key, V oldValue, V newValue) %7B%0A        decCount(key, oldValue);%0A        super.entryRemoved(evicted, key, oldValue, newValue);%0A    %7D%0A%0A    @Override%0A    protected final V create(final K key) %7B%0A        final V value = this.createMulti(key);%0A        if (value != null) %7B%0A            incCount(key, value);%0A        %7D%0A        return value;%0A    %7D%0A%0A    protected V createMulti(final K key) %7B%0A        return null;%0A    %7D%0A%0A    @Override%0A    public void trimToSize(final int maxSize) %7B%0A        // we need to loop until size gap stabilizes%0A        int gap = -1;%0A        while(mSizeGap != gap) %7B%0A            gap = mSizeGap;%0A            super.trimToSize(maxSize + mSizeGap);%0A        %7D%0A    %7D%0A%0A    private void incCount(final K key, final V value) %7B%0A        synchronized (mCopies) %7B%0A            Integer count = mCopies.get(value);%0A            count = count != null ? count + 1 : 1;%0A            mCopies.put(value, count);%0A%0A            if (count %3E 1) %7B%0A                final int size = this.sizeOf(key, value);%0A                if (size %3E= 0) %7B%0A                    mSizeGap += size;%0A                %7D%0A            %7D%0A        %7D%0A    %7D%0A%0A    private void decCount(final K key, final V value) %7B%0A        synchronized (mCopies) %7B%0A            Integer count = mCopies.get(value);%0A            count = count != null ? count - 1 : 0;%0A            if (count %3C= 0) %7B%0A                mCopies.remove(value);%0A            %7D else %7B%0A                mCopies.put(value, count);%0A%0A                final int size = this.sizeOf(key, value);%0A                if (size %3E= 0) %7B%0A                    mSizeGap -= size %3C mSizeGap ? size : mSizeGap;%0A                %7D%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A

add MultiKeyLruCache to gto-support