<commit_before>package scala.meta.collections

import scala.collection.mutable

/**
  * @author mucianm 
  * @since 03.06.16.
  */

class TwoWayCache[T, U] {
  private lazy val t2u = mutable.Map[T, U]()
  private lazy val u2t = mutable.Map[U, T]()

  def apply(t: T)(implicit ev: OverloadHack1) = t2u(t)
  def get(t: T)(implicit ev: OverloadHack1) = t2u.get(t)
  def contains(t: T)(implicit ev: OverloadHack1) = t2u.contains(t)
  def update(t: T, u: U)(implicit ev: OverloadHack1) = { t2u(t) = u; u2t(u) = t }
  def getOrElseUpdate(t: T, op: => U)(implicit ev: OverloadHack1) = {
    val u = t2u.getOrElseUpdate(t, op)
    u2t(u) = t
    u
  }

  def apply(u: U)(implicit ev: OverloadHack2) = u2t(u)
  def get(u: U)(implicit ev: OverloadHack2) = u2t.get(u)
  def contains(u: U)(implicit ev: OverloadHack2) = u2t.contains(u)
  def update(u: U, t: T)(implicit ev: OverloadHack2) = { u2t(u) = t; t2u(t) = u; u2t(u) = t }
  def getOrElseUpdate(u: U, op: => T)(implicit ev: OverloadHack2) = {<commit_msg>metahost: use WeakHashMap in tree converter cache<commit_after>package scala.meta.collections

import scala.collection.mutable

/**
  * @author mucianm 
  * @since 03.06.16.
  */

class TwoWayCache[T, U] {
  private lazy val t2u = mutable.WeakHashMap[T, U]()
  private lazy val u2t = mutable.WeakHashMap[U, T]()

  def apply(t: T)(implicit ev: OverloadHack1) = t2u(t)
  def get(t: T)(implicit ev: OverloadHack1) = t2u.get(t)
  def contains(t: T)(implicit ev: OverloadHack1) = t2u.contains(t)
  def update(t: T, u: U)(implicit ev: OverloadHack1) = { t2u(t) = u; u2t(u) = t }
  def getOrElseUpdate(t: T, op: => U)(implicit ev: OverloadHack1) = {
    val u = t2u.getOrElseUpdate(t, op)
    u2t(u) = t
    u
  }

  def apply(u: U)(implicit ev: OverloadHack2) = u2t(u)
  def get(u: U)(implicit ev: OverloadHack2) = u2t.get(u)
  def contains(u: U)(implicit ev: OverloadHack2) = u2t.contains(u)
  def update(u: U, t: T)(implicit ev: OverloadHack2) = { u2t(u) = t; t2u(t) = u; u2t(u) = t }
  def getOrElseUpdate(u: U, op: => T)(implicit ev: OverloadHack2) = {
{'fraction_non_alphanumeric': 0.16439024390243903, 'fraction_numerical': 0.03024390243902439, 'mean_word_length': 3.9902676399026764, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2264084', 'n_tokens_mistral': 943, 'n_tokens_neox': 919, 'n_words': 214}