Format: application/x-python-code
1 o
2
3 .'hj � @ s� d Z ddlZddlmZmZ dee deedf fdd�Zd ed
4 edefdd�Zd
5 edeeef fdd�Zdedeedf de fdd�Z
6 dS )a
7 Given a list of integers, made up of (hopefully) a small number of long runs
8 of consecutive integers, compute a representation of the form
9 ((start1, end1), (start2, end2) ...). Then answer the question "was x present
10 in the original list?" in time O(log(# runs)).
11 � N)�List�Tuple�list_�return.c C s� t | �}g }d}tt|��D ]1}|d t|�k r%|| ||d d kr%q||d |d � }|�t|d |d d �� |}qt|�S )a Represent a list of integers as a sequence of ranges:
12 ((start_0, end_0), (start_1, end_1), ...), such that the original
13 integers are exactly those x such that start_i <= x < end_i for some i.
14
15 Ranges are encoded as single integers (start << 32 | end), not as tuples.
16 ������ r )�sorted�range�len�append�
17 _encode_range�tuple)r �sorted_list�ranges�
18 last_write�i�
19 current_range� r �DC:\Users\shubh\Videos\agent\nova\Lib\site-packages\idna/intranges.py�intranges_from_list s r �start�endc C s | d>