%PDF- %PDF-
| Direktori : /lib/python3/dist-packages/pyrsistent/__pycache__/ | 
| Current File : //lib/python3/dist-packages/pyrsistent/__pycache__/_pdeque.cpython-312.pyc | 
�
    n�9e�/  �                   ��   � d dl mZmZ d dlmZmZ d dlmZ d dlm	Z	m
Z
 d dlmZ  e	dd��      Z
 G d	� d
e
e
   �      Z ej                  e�        ej                  e�       dd�Zd
� Zy)�    )�Sequence�Hashable)�islice�chain)�Integral)�TypeVar�Generic)�plist�T_coT)�	covariantc                   �*  � � e Zd ZdZdZd� fd�	Zed� �       Zed� �       Ze	d� �       Z
d� Zd� ZeZ
ed	� �       Zd d
�Zd d�Ze	d� �       Zd
� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Ze	d� �       Zd� Zd� Zd� Zd� Zd� Zd� Z e Z!d� Z"d� Z#d� Z$e%jL                  Z&� xZ'S )!�PDequea�  
    Persistent double ended queue (deque). Allows quick appends and pops in both ends. Implemented
    using two persistent lists.
    A maximum length can be specified to create a bounded queue.
    Fully supports the Sequence and Hashable protocols including indexing and slicing but
    if you need fast random access go for the PVector instead.
    Do not instantiate directly, instead use the factory functions :py:func:`dq` or :py:func:`pdeque` to
    create an instance.
    Some examples:
    >>> x = pdeque([1, 2, 3])
    >>> x.left
    1
    >>> x.right
    3
    >>> x[0] == x.left
    True
    >>> x[-1] == x.right
    True
    >>> x.pop()
    pdeque([1, 2])
    >>> x.pop() == x[:-1]
    True
    >>> x.popleft()
    pdeque([2, 3])
    >>> x.append(4)
    pdeque([1, 2, 3, 4])
    >>> x.appendleft(4)
    pdeque([4, 1, 2, 3])
    >>> y = pdeque([1, 2, 3], maxlen=3)
    >>> y.append(4)
    pdeque([2, 3, 4], maxlen=3)
    >>> y.appendleft(4)
    pdeque([4, 1, 2], maxlen=3)
    )�
_left_list�_right_list�_length�_maxlen�__weakref__c                 �   �� t         t        | �  | �      }||_        ||_        ||_        |�+t
        |t        �      st        d�      �|dk  rt        d�      �||_
        |S )Nz An integer is required as maxlenr   zmaxlen must be non-negative)�superr   �__new__r   r   r   �
isinstancer   �	TypeError�
ValueErrorr   )�cls�	left_list�
right_list�length�maxlen�instance�	__class__s         ��4/usr/lib/python3/dist-packages/pyrsistent/_pdeque.pyr   zPDeque.__new__5   sh   �� ����-�c�2��'���)���!������f�h�/�� B�C�C���z� �!>�?�?�!�����    c                 �V   � t         j                  | j                  | j                  �      S )z.
        Rightmost element in dqueue.
        )r   �_tip_from_listsr   r   ��selfs    r!   �rightzPDeque.rightE   s!   � �
 �%�%�d�&6�&6����H�Hr"