<commit_before>package com.stanfy.images;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map.Entry;

import android.graphics.Bitmap;

/**
 * Images memory cache.
 * @author <NAME> (Stanfy - http://www.stanfy.com)
 */
public class StaticSizeImageMemoryCache implements ImageMemoryCache {

  /** Default clean factor. */
  private static final float DEFAULT_CLEAN_FACTOR = 0.9f;
  /** Cache map. */
  private final LinkedHashMap<String, CacheRecord> cacheMap;

  /** Current size. */
  private int currentSize = 0;

  /** Maximum size. */
  private int maxSize;
  /** Clean factor. */
  private float cleanFactor = DEFAULT_CLEAN_FACTOR;

  /**
   * Constructor.
   * @param maxSize maximum amount of memory
   */
  public StaticSizeImageMemoryCache() {
    final int capacity = 50;
    this.cacheMap = new LinkedHashMap<String, CacheRecord>(capacity);
    final long maxMemory = Runtime.getRuntime().maxMemory();
    maxSize = (int)(maxMemory / 3);
  }

  /** @param maxSize the maxSize to set */
  public void setMaxSize(final int maxSize) { this.maxSize = maxSize; }

  private void cleanup(final int requiredSize) {
    int currentSize = this.currentSize;
    final Iterator<Entry<String, CacheRecord>> iterator = cacheMap.entrySet().iterator();
    while (currentSize > requiredSize && iterator.hasNext()) {
      final CacheRecord record = iterator.next().getValue();
      iterator.remove();
      currentSize -= record.size;
    }
    this.currentSize = currentSize;
  }

  /**
   * @param url URL
   * @param image image instance
   * @param imageUrl image URL
   */
  @Override
  public void putElement(final String url, final Bitmap image) {
    synchronized (cacheMap) {<commit_msg>change max size for mem cache<commit_after>package com.stanfy.images;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map.Entry;

import android.graphics.Bitmap;

/**
 * Images memory cache.
 * @author <NAME> (Stanfy - http://www.stanfy.com)
 */
public class StaticSizeImageMemoryCache implements ImageMemoryCache {

  /** Default clean factor. */
  private static final float DEFAULT_CLEAN_FACTOR = 0.9f;
  /** Default max size. */
  private static final int DEFAULT_MAX_SIZE = 5 * 1024 * 1024;
  /** Cache map. */
  private final LinkedHashMap<String, CacheRecord> cacheMap;

  /** Current size. */
  private int currentSize = 0;

  /** Maximum size. */
  private int maxSize = DEFAULT_MAX_SIZE;
  /** Clean factor. */
  private float cleanFactor = DEFAULT_CLEAN_FACTOR;

  /**
   * Constructor.
   * @param maxSize maximum amount of memory
   */
  public StaticSizeImageMemoryCache() {
    final int capacity = 50;
    this.cacheMap = new LinkedHashMap<String, CacheRecord>(capacity);
  }

  /** @param maxSize the maxSize to set */
  public void setMaxSize(final int maxSize) { this.maxSize = maxSize; }

  private void cleanup(final int requiredSize) {
    int currentSize = this.currentSize;
    final Iterator<Entry<String, CacheRecord>> iterator = cacheMap.entrySet().iterator();
    while (currentSize > requiredSize && iterator.hasNext()) {
      final CacheRecord record = iterator.next().getValue();
      iterator.remove();
      currentSize -= record.size;
    }
    this.currentSize = currentSize;
  }

  /**
   * @param url URL
   * @param image image instance
   * @param imageUrl image URL
   */
  @Override
  public void putElement(final String url, final Bitmap image) {
    synchronized (cacheMap) {
{'fraction_non_alphanumeric': 0.11412103746397695, 'fraction_numerical': 0.005763688760806916, 'mean_word_length': 3.4961139896373057, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6000981', 'n_tokens_mistral': 1028, 'n_tokens_neox': 995, 'n_words': 290}