o
    Q `                     @   sd   d Z ddlmZ ddlmZ ddlZddlmZ edZedZ	G dd	 d	eej
ee	f ZdS )
z#Least Recently Used cache mapping.
    )absolute_import)unicode_literalsN)OrderedDict_K_Vc                       s4   e Zd ZdZ fddZdd Z fddZ  ZS )LRUCachezA dictionary-like container that stores a given maximum items.

    If an additional item is added when the LRUCache is full, the least
    recently used key is discarded to make room for the new item.

    c                    s   || _ tt|   d S )N)
cache_sizesuperr   __init__)selfr   	__class__ -/usr/lib/python3/dist-packages/fs/lrucache.pyr
      s   zLRUCache.__init__c                 C   s4   || vrt | | jkr| jdd t| || dS )z@Store a new views, potentially discarding an old value.
        F)ZlastN)lenr   popitemr   __setitem__)r   keyvaluer   r   r   r      s   zLRUCache.__setitem__c                    s6   t ttt| }||}|| ||| |S )z5Get the item, but also makes it most recent.
        )typingcastr   r	   r   __getitem____delitem__r   )r   r   Z_superr   r   r   r   r   %   s
   

zLRUCache.__getitem__)__name__
__module____qualname____doc__r
   r   r   __classcell__r   r   r   r   r      s
    	r   )r   Z
__future__r   r   r   collectionsr   TypeVarr   r   ZGenericr   r   r   r   r   <module>   s    

 