관리-도구
편집 파일: _pdeque.cpython-37.opt-1.pyc
B +�[�/ � @ sr d dl mZmZ ddlmZmZ ddlmZ ddlm Z G dd� de �Ze�e� e�e� dd d�Z dd � Zd S )� )�Sequence�Hashable� )�islice�chain)�Integral)�plistc s( e Zd ZdZdZd=� fdd� Zedd� �Zedd � �Ze d d� �Z dd � Zdd� ZeZ edd� �Zd>dd�Zd?dd�Ze dd� �Zdd� Zdd� Zdd� Zdd � Zd!d"� Zd#d$� Zd%d&� Zd'd(� Ze d)d*� �Zd+d,� Zd-d.� Zd/d0� Zd1d2� Zd3d4� Zd5d6� Z e Z!d7d8� Z"d9d:� Z#d;d<� Z$e%j&Z&� Z'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__Nc sV t t| ��| �}||_||_||_|d k rLt|t�s<td��|dk rLt d��||_ |S )Nz An integer is required as maxlenr zmaxlen must be non-negative)�superr �__new__r r r � isinstancer � TypeError� ValueErrorr )�clsZ left_listZ right_list�length�maxlen�instance)� __class__� �E/opt/alt/python37/lib64/python3.7/site-packages/pyrsistent/_pdeque.pyr 2 s zPDeque.__new__c C s t �| j| j�S )z. Rightmost element in dqueue. )r �_tip_from_listsr r )�selfr r r �rightB s zPDeque.rightc C s t �| j| j�S )z- Leftmost element in dqueue. )r r r r )r r r r �leftI s zPDeque.leftc C s"