<commit_before>package org.yawni.util.cache;

/**
 * Cache based on {@link sun.misc.SoftCache}.
 */
public class SoftCache<K, V> implements Cache<K, V> {
  private static final long serialVersionUID = 1L;

  private final sun.misc.SoftCache backingMap;

  public SoftCache(final int initialCapacity) {
    this.backingMap = new sun.misc.SoftCache(initialCapacity) {
//      @Override
//      protected Object fill(Object key) {
//        return null;
//      }
    };
  }

  @Override
  @SuppressWarnings("unchecked")
  public synchronized V put(K key, V value) {
    return (V) backingMap.put(key, value);
  }

  @Override
  @SuppressWarnings("unchecked")
  public synchronized V get(K key) {
    return (V) backingMap.get(key);
  }

  @Override
  public synchronized void clear() {
    backingMap.clear();
  }
}<commit_msg>simplified internals, improved javadocs<commit_after>package org.yawni.util.cache;

import java.util.Map;

/**
 * Memory-sensitive {@code Cache} based on {@link sun.misc.SoftCache} which
 * is based on {@link java.lang.ref.SoftReference}s.
 */
public class SoftCache<K, V> implements Cache<K, V> {
  private static final long serialVersionUID = 1L;

  private final Map<K, V> backingMap;

  @SuppressWarnings("unchecked")
  public SoftCache(final int initialCapacity) {
    this.backingMap = (Map<K, V>) new sun.misc.SoftCache(initialCapacity);
  }

  @Override
  public synchronized V put(K key, V value) {
    return backingMap.put(key, value);
  }

  @Override
  public synchronized V get(K key) {
    return backingMap.get(key);
  }

  @Override
  public synchronized void clear() {
    backingMap.clear();
  }
}
{'fraction_non_alphanumeric': 0.1218769043266301, 'fraction_numerical': 0.001218769043266301, 'mean_word_length': 3.6123595505617976, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5321169', 'n_tokens_mistral': 536, 'n_tokens_neox': 521, 'n_words': 140}