Code example for LinkedList

0
	/** 
	 * Contains strong references to stored objects. Each next object is added last. If hard cache size will exceed 
	 * limit then first object is deleted (but it continue exist at {@link #softMap} and can be collected by GC at any 
	 * time) 
	 */ 
	private final List<V> hardCache = Collections.synchronizedList(new LinkedList<V>());
 
	/** @param sizeLimit Maximum size for cache (in bytes) */ 
	public LimitedMemoryCache(int sizeLimit) {
		this.sizeLimit = sizeLimit;
		cacheSize = new AtomicInteger();
		if (sizeLimit > MAX_NORMAL_CACHE_SIZE) {
			L.w("You set too large memory cache size (more than %1$d Mb)", MAX_NORMAL_CACHE_SIZE_IN_MB);
		} 
	} 
 
	@Override 
	public boolean put(K key, V value) {
		boolean putSuccessfully = false;
		// Try to add value to hard cache