<commit_before>//
//  LRUAnimationCache.swift
//  lottie-swift
//
//  Created by <NAME> on 2/5/19.
//

import Foundation

/**
 An Animation Cache that will store animations up to `cacheSize`.
 
 Once `cacheSize` is reached, the least recently used animation will be ejected.
 The default size of the cache is 100.
 */
public class LRUAnimationCache: AnimationCacheProvider {

  public init() { }
  
  /// Clears the Cache.
  public func clearCache() {
    cacheMap.removeAll()
    lruList.removeAll()
  }
  
  /// The global shared Cache.
  public static let sharedCache = LRUAnimationCache()
  
  /// The size of the cache.
  public var cacheSize: Int = 100
  
  public func animation(forKey: String) -> Animation? {
    guard let animation = cacheMap[forKey] else {
      return nil
    }
    if let index = lruList.index(of: forKey) {<commit_msg>.index is deprecated in favor of .firstIndex<commit_after>//
//  LRUAnimationCache.swift
//  lottie-swift
//
//  Created by <NAME> on 2/5/19.
//

import Foundation

/**
 An Animation Cache that will store animations up to `cacheSize`.
 
 Once `cacheSize` is reached, the least recently used animation will be ejected.
 The default size of the cache is 100.
 */
public class LRUAnimationCache: AnimationCacheProvider {

  public init() { }
  
  /// Clears the Cache.
  public func clearCache() {
    cacheMap.removeAll()
    lruList.removeAll()
  }
  
  /// The global shared Cache.
  public static let sharedCache = LRUAnimationCache()
  
  /// The size of the cache.
  public var cacheSize: Int = 100
  
  public func animation(forKey: String) -> Animation? {
    guard let animation = cacheMap[forKey] else {
      return nil
    }
    if let index = lruList.firstIndex(of: forKey) {
{'fraction_non_alphanumeric': 0.10034602076124567, 'fraction_numerical': 0.011534025374855825, 'mean_word_length': 2.8814317673378076, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5999226', 'n_tokens_mistral': 561, 'n_tokens_neox': 515, 'n_words': 186}