+
    &h                         R t ^ RIHtHt ^ RIHt ^ RIt ^RIHt ]! RR7      t	 ^RIHt . ROt ! R R4      t ! R R	]4      t ! R R
]4      t]tR#   ]
 d    ]! 4       t	 L?i ; i  ]
 d    ]t LGi ; i)a  Python comes with a many great data structures, from :class:`dict`
to :class:`collections.deque`, and no shortage of serviceable
algorithm implementations, from :func:`sorted` to :mod:`bisect`. But
priority queues are curiously relegated to an example documented in
:mod:`heapq`. Even there, the approach presented is not full-featured
and object-oriented. There is a built-in priority queue,
:class:`Queue.PriorityQueue`, but in addition to its austere API, it
carries the double-edged sword of threadsafety, making it fine for
multi-threaded, multi-consumer applications, but high-overhead for
cooperative/single-threaded use cases.

The ``queueutils`` module currently provides two Queue
implementations: :class:`HeapPriorityQueue`, based on a heap, and
:class:`SortedPriorityQueue`, based on a sorted list. Both use a
unified API based on :class:`BasePriorityQueue` to facilitate testing
the slightly different performance characteristics on various
application use cases.

>>> pq = PriorityQueue()
>>> pq.add('low priority task', 0)
>>> pq.add('high priority task', 2)
>>> pq.add('medium priority task 1', 1)
>>> pq.add('medium priority task 2', 1)
>>> len(pq)
4
>>> pq.pop()
'high priority task'
>>> pq.peek()
'medium priority task 1'
>>> len(pq)
3

)heappushheappopinsortN)make_sentinel_REMOVED)var_name)BListBasePriorityQueueHeapPriorityQueueSortedPriorityQueuec                      a  ] tR t^[t o Rt]! R 4      t]tR t	]R 4       t
]R 4       tRR ltR tRR	 lt]3R
 lt]3R ltR tRtV tR# )r
   a  The abstract base class for the other PriorityQueues in this
module. Override the ``_backend_type`` class attribute, as well as
the :meth:`_push_entry` and :meth:`_pop_entry` staticmethods for
custom subclass behavior. (Don't forget to use
:func:`staticmethod`).

Args:
    priority_key (callable): A function that takes *priority* as
        passed in by :meth:`add` and returns a real number
        representing the effective priority.

c                .    \        T ;'       g    ^ 4      ) #     )float)ps   &2lib/python3.14/site-packages/boltons/queueutils.py<lambda>BasePriorityQueue.<lambda>i   s    E!&&qM>    c                   V P                  4       V n        / V n        \        P                  ! 4       V n        VP                  R V P                  4      V n        V'       d!   \        RVP                  4       ,          4      hR# )priority_keyz unexpected keyword arguments: %rN)_backend_type_pq
_entry_map	itertoolscount_counterpop_default_priority_key_get_priority	TypeErrorkeys)selfkws   &,r   __init__BasePriorityQueue.__init__l   s_    %%'!)VVND4N4NO>JKK r   c                    R # N backendentrys   &&r   _push_entryBasePriorityQueue._push_entryt       r   c                    R # r)   r*   r,   s   &r   
_pop_entryBasePriorityQueue._pop_entryx   r0   r   Nc                    V P                  V4      pWP                  9   d   V P                  V4       \        V P                  4      pW#V.pW@P                  V&   V P                  V P                  V4       R# )a   
Add a task to the queue, or change the *task*'s priority if *task*
is already in the queue. *task* can be any hashable object,
and *priority* defaults to ``0``. Higher values representing
higher priority, but this behavior can be controlled by
setting *priority_key* in the constructor.
N)r!   r   removenextr   r.   r   )r$   taskpriorityr   r-   s   &&&  r   addBasePriorityQueue.add|   sb     %%h/??"KKT]]#$' %5)r   c                N    V P                   P                  V4      p\        VR&   R# )zWRemove a task from the priority queue. Raises :exc:`KeyError` if
the *task* is absent.
N)r   r   r   )r$   r8   r-   s   && r   r6   BasePriorityQueue.remove   s!     ##D)b	r   c                    V P                   '       d@   V P                   ^ ,          w  r#pV\        J d   V P                  V P                   4       KO  R# V'       d   \        R4      hR# )zBRemove entries marked as removed by previous :meth:`remove` calls.Nzempty priority queue)r   r   r3   
IndexError)r$   	raise_excr9   r   r8   s   &&   r   _cullBasePriorityQueue._cull   sO    hhh$(HHQK!HTx)344 r   c                     V P                  4        V P                  ^ ,          w   r#V#   \         d    T\        Jd   Tu # \        R4      hi ; i)zRead the next value in the queue without removing it. Returns
*default* on an empty queue, or raises :exc:`KeyError` if
*default* is not set.
zpeek on empty queue)rB   r   r@   r   r$   default_r8   s   &&  r   peekBasePriorityQueue.peek   sR    
	4JJL!JAq
 	  	4h&233	4s   &* AAc                     V P                  4        V P                  V P                  4      w   r#V P                  V V#   \         d    T\
        Jd   Tu # \	        R4      hi ; i)zRemove and return the next value in the queue. Returns *default* on
an empty queue, or raises :exc:`KeyError` if *default* is not
set.
zpop on empty queue)rB   r3   r   r   r@   r   rE   s   &&  r   r   BasePriorityQueue.pop   sc    
	3JJL2JAq%
 	  	3h&122	3s   ;? A$A$c                ,    \        V P                  4      # )z(Return the number of tasks in the queue.)lenr   )r$   s   &r   __len__BasePriorityQueue.__len__   s    4??##r   )r   r   r!   r   r)   )T)__name__
__module____qualname____firstlineno____doc__staticmethodr    listr   r&   r.   r3   r:   r6   rB   r   rH   r   rN   __static_attributes____classdictcell____classdict__s   @r   r
   r
   [   sx      ))ABML    * 	5 $  # $ $r   c                   D   a  ] tR t^t o Rt]R 4       t]R 4       tRtV t	R# )r   zA priority queue inherited from :class:`BasePriorityQueue`,
backed by a list and based on the :func:`heapq.heappop` and
:func:`heapq.heappush` functions in the built-in :mod:`heapq`
module.
c                    \        V 4      # r)   )r   r2   s   &r   r3   HeapPriorityQueue._pop_entry   s    wr   c                    \        W4       R # r)   )r   r+   s   &&r   r.   HeapPriorityQueue._push_entry   s
     r   r*   N)
rP   rQ   rR   rS   rT   rU   r3   r.   rW   rX   rY   s   @r   r   r      s2     
     ! !r   c                   H   a  ] tR t^t o Rt]t]R 4       t]R 4       t	Rt
V tR# )r   zA priority queue inherited from :class:`BasePriorityQueue`, based
on the :func:`bisect.insort` approach for in-order insertion into
a sorted list.
c                $    V P                  ^ 4      # r   )r   r2   s   &r   r3   SortedPriorityQueue._pop_entry   s    {{1~r   c                    \        W4       R # r)   r   r+   s   &&r   r.   SortedPriorityQueue._push_entry   s
    wr   r*   N)rP   rQ   rR   rS   rT   r	   r   rU   r3   r.   rW   rX   rY   s   @r   r   r      s7      M   r   )PriorityQueuer
   r   r   )rT   heapqr   r   bisectr   r   	typeutilsr   r   ImportErrorobject	listutilsr	   rV   __all__r
   r   r   re   r*   r   r   <module>rm      s   > F $  (j1H 7b$ b$J!) !+   $m  xH  Es"   A A( A%$A%(	A43A4