
    h	                    ^    S SK Jr  S SKJrJrJr  \(       a  S SKJr  S SKJ	r	   " S S5      r
g)    )annotations)TYPE_CHECKINGAnyCallable)Iterable)	BaseQueuec                  h    \ rS rSrSr S     SS jjrSSS jjrSS jrSS jrSS jr	SS jr
S	rg
)PriorityQueue   a  A priority queue implemented using multiple internal queues (typically,
FIFO queues). The internal queue must implement the following methods:

    * push(obj)
    * pop()
    * peek()
    * close()
    * __len__()

The constructor receives a qfactory argument, which is a callable used to
instantiate a new (internal) queue when a new priority is allocated. The
qfactory function is called with the priority number as first and only
argument.

Only integer priorities should be used. Lower numbers are higher
priorities.

startprios is a sequence of priorities to start with. If the queue was
previously closed leaving some priority buckets non-empty, those priorities
should be passed in startprios.

c                    0 U l         Xl        U H!  nU R                  U5      U R                   U'   M#     U(       a  [        U5      U l        g S U l        g N)queuesqfactorymincurprio)selfr   
startpriosps       V/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/queuelib/pqueue.py__init__PriorityQueue.__init__#   sC      A!]]1-DKKN *4s:$    c                    X R                   ;  a  U R                  U5      U R                   U'   U R                   U   nUR                  U5        U R                  b  X R                  :  a  X l        g g r   )r   r   pushr   )r   objpriorityqs       r   r   PriorityQueue.push,   sY    ;;&$(MM($;DKK!KK!	s<<8ll#:#L $;r   c                   U R                   c  g U R                  U R                      nUR                  5       n[        U5      S:X  a  U R                  U R                   	 UR	                  5         U R                  R                  5        VVs/ s H  u  p1[        U5      S:  d  M  UPM     nnnU(       a  [        U5      OS U l         U$ s  snnf )Nr   )r   r   poplencloseitemsr   )r   r   mr   prioss        r   r    PriorityQueue.pop4   s    <<KK%EEGq6Q;DLL)GGI#';;#4#4#6E#641#a&1*Q#6EE).3u:DDL Fs   C$Cc                l    U R                   c  g U R                  U R                      R                  5       $ r   )r   r   peekr   s    r   r(   PriorityQueue.peek@   s+    <<{{4<<(--//r   c                    / nU R                   R                  5        H6  u  p#[        U5      (       a  UR                  U5        UR	                  5         M8     U$ r   )r   r#   r!   appendr"   )r   activer   r   s       r   r"   PriorityQueue.closeE   sE    KK%%'DA1vva GGI ( r   c                |    U R                   (       a*  [        S U R                   R                  5        5       5      $ S$ )Nc              3  8   #    U  H  n[        U5      v   M     g 7fr   )r!   ).0xs     r   	<genexpr>(PriorityQueue.__len__.<locals>.<genexpr>N   s     8#7a3q66#7s   r   )r   sumvaluesr)   s    r   __len__PriorityQueue.__len__M   s+    <@KKs84;;#5#5#788NQNr   )r   r   r   N) )r   zCallable[[int], BaseQueue]r   zIterable[int]returnNone)r   )r   r   r   intr:   r;   )r:   z
Any | None)r:   z	list[int])r:   r<   )__name__
__module____qualname____firstlineno____doc__r   r   r    r(   r"   r7   __static_attributes__r9   r   r   r
   r
      sE    0 QS?2?@M?	?$
0
Or   r
   N)
__future__r   typingr   r   r   collections.abcr   queuelib.queuer   r
   r9   r   r   <module>rG      s%    " / /((CO COr   