protected void trimToSize(int size) {
        Map.Entry<T, Y> last;
        while (currentSize > size) {
            last = cache.entrySet().iterator().next();
            final Y toRemove = last.getValue();
            currentSize -= getSize(toRemove);
            final T key = last.getKey();
            cache.remove(key);
            onItemEvicted(key, toRemove);
        }
    }
Removes the least recently used items from the cache until the current size is less than the given size.

@param size The size the cache should be less than.
core/src/main/java/com/bumptech/glide/util/LruCache.java