관리-도구
편집 파일: py.cpython-36.opt-1.pyc
3 �Pf� � @ sL d dl mZmZmZ d dlmZ d dlmZ ddlm Z G dd� de �Z dS ) � )�absolute_import�division�unicode_literals)� text_type)�bisect_left� )�Triec @ sF e Zd Zdd� Zdd� Zdd� Zdd� Zd d � Zddd �Zdd� Z dS )r c C sJ t dd� |j� D ��std��|| _t|j� �| _d| _dt|�f| _d S )Nc s s | ]}t |t�V qd S )N)� isinstancer )�.0�x� r �/usr/lib/python3.6/py.py� <genexpr> s z Trie.__init__.<locals>.<genexpr>zAll keys must be strings� r ) �all�keys� TypeError�_data�sorted�_keys� _cachestr�len�_cachepoints)�self�datar r r �__init__ s z Trie.__init__c C s || j kS )N)r )r �keyr r r �__contains__ s zTrie.__contains__c C s t | j�S )N)r r )r r r r �__len__ s zTrie.__len__c C s t | j�S )N)�iterr )r r r r �__iter__ s z Trie.__iter__c C s | j | S )N)r )r r r r r �__getitem__ s zTrie.__getitem__Nc C s� |d ks|dks| j r"t| j �S |j| j�rN| j\}}t| j |||� }}nt| j |� }}t� }|t| j �krv|S x,| j | j|�r�|j| j | � |d7 }qxW || _||f| _|S )Nr r )r �set� startswithr r r r �add)r �prefix�lo�hi�start�ir r r r r s z Trie.keysc C sd || j krdS |j| j�r6| j\}}t| j|||�}nt| j|�}|t| j�krTdS | j| j|�S )NTF)r r# r r r r r )r r% r&