Skip to content

Commit 406b526

Browse files
committed
Update docs
1 parent a863de6 commit 406b526

File tree

4 files changed

+24
-26
lines changed

4 files changed

+24
-26
lines changed

CHANGES

+7-9
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@ Release Notes
44
1.4.0 (2024-02-14)
55
++++++++++++++++++
66

7-
What's changed:
8-
9-
* The deprecated module-level ``minpq`` and ``maxpq`` have been removed in favor of same-named classmethods introduced in v1.3.0 (#24)
10-
* Introduce a distinct ``Empty`` exception for operations that attempt to remove items from an empty pqdict, instead of raising a ``KeyError``. (Note that ``Empty`` is derived from ``KeyError`` for subclass compatibility with ``Mapping.popitem`` and ``Mapping.clear``.) (#24)
11-
* Make internal heap nodes immutable and fast copy as originally proposed by @palkeo in #14
12-
13-
Maintenance:
7+
* API changes:
8+
- The deprecated module-level ``minpq`` and ``maxpq`` have been removed in favor of same-named classmethods introduced in v1.3.0 (#24)
9+
- Introduce a distinct ``Empty`` exception for operations that attempt to remove items from an empty pqdict, instead of raising a ``KeyError``. (Note that ``Empty`` is derived from ``KeyError`` for subclass compatibility with ``Mapping.popitem`` and ``Mapping.clear``.) (#24)
10+
- Make internal heap nodes immutable and fast copy as originally proposed by @palkeo in #14
1411

15-
* Factored out indexed heap operations to reduce redundancy
16-
* Better docstrings and type annotations
12+
* Maintenance:
13+
- Factored out indexed heap operations to reduce redundancy
14+
- Better docstrings and type annotations
1715

1816
**Full Changelog**: https://github.com/nvictus/pqdict/compare/v1.3.0...v1.4.0
1917

README.rst

+4-5
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@ A priority queue dictionary maps hashable objects (keys) to priority-determining
1414
.. image:: https://img.shields.io/pypi/v/pqdict.svg
1515
:target: https://pypi.python.org/pypi/pqdict
1616

17-
The priority queue is implemented as a binary heap of (key, priority value)
18-
pairs, which supports:
17+
The priority queue itself is implemented as a binary heap of (key, priority value) elements, which supports:
1918

2019
- O(1) search for the item with highest priority
2120

2221
- O(log n) removal of the item with highest priority
2322

2423
- O(log n) insertion of a new item
2524

26-
Additionally, an index maps elements to their location in the heap and is kept
27-
up to date as the heap is manipulated. As a result, pqdict also supports:
25+
Additionally, an index maps each key to its element's location in the heap and is kept
26+
up to date as the heap is manipulated. As a result, ``pqdict`` also supports:
2827

2928
- O(1) lookup of any item by key
3029

@@ -36,7 +35,7 @@ up to date as the heap is manipulated. As a result, pqdict also supports:
3635
Documentation
3736
-------------
3837

39-
Documentation is available at http://pqdict.readthedocs.org/en/latest/.
38+
Documentation is available at http://pqdict.readthedocs.org/.
4039

4140

4241
License

docs/intro.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ Quickstart
44
What is an "indexed" priority queue?
55
------------------------------------
66

7-
A `priority queue <http://en.wikipedia.org/wiki/Priority_queue>`__ allows you to serve or retrieve items in a prioritized fashion. A priority queue supports inserting elements with priorities, and removing or peeking at the top priority element. The vanilla priority queue interface can be extended to support random access, insertion, removal and changing the priority of any element in the queue. An *indexed* priority queue does these latter operations efficiently.
7+
A `priority queue <http://en.wikipedia.org/wiki/Priority_queue>`__ allows you to serve or retrieve items in a prioritized fashion. A priority queue supports inserting elements with priorities, and removing or peeking at the top priority element. The vanilla priority queue interface can be extended to support **random access to any element** as well as **removing or changing the priority of any element** in the queue. An *indexed* priority queue does these latter operations efficiently.
88

9-
The priority queue is implemented as a binary heap of (key, priority value) pairs, which supports:
9+
``pqdict`` exposes an indexed priority queue as a mapping from keys to priority-determining values. The priority queue itself is implemented as a binary heap of (key, priority value) elements, which supports:
1010

1111
* O(1) search for the item with highest priority
1212

1313
* O(log n) removal of the item with highest priority
1414

1515
* O(log n) insertion of a new item
1616

17-
An internal index maps elements to their location in the heap and is kept up to date as the heap is manipulated. As a result, pqdict also supports:
17+
An internal index maps each key to its element's location in the heap and is kept up to date as the heap is manipulated. As a result, ``pqdict`` also supports:
1818

1919
* O(1) lookup of any item by key
2020

@@ -130,7 +130,7 @@ Views and regular iteration don't affect the heap, but the output is **unsorted*
130130
>>> pq.popitem()
131131
('d', 6.5)
132132
>>> pq.popitem() # ...and we're empty!
133-
KeyError
133+
Empty
134134
135135
136136
.. warning::
@@ -157,4 +157,4 @@ This module is released under the MIT license. The augmented heap implementation
157157
Documentation
158158
-------------
159159

160-
Documentation is available at http://pqdict.readthedocs.org/en/latest/.
160+
Documentation is available at http://pqdict.readthedocs.org/.

pqdict/__init__.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,27 @@
88
Raymond Hettinger.
99
1010
The priority queue is implemented as a binary heap of (key, priority value)
11-
pairs, which supports:
11+
elements, which supports:
1212
1313
- O(1) search for the item with highest priority
1414
1515
- O(log n) removal of the item with highest priority
1616
1717
- O(log n) insertion of a new item
1818
19-
Additionally, an index maps elements to their location in the heap and is kept
20-
up to date as the heap is manipulated. As a result, pqdict also supports:
19+
Additionally, an index maps each key to its element's location in the heap
20+
and is kept up to date as the heap is manipulated. As a result, pqdict also
21+
supports:
2122
2223
- O(1) lookup of any item by key
2324
2425
- O(log n) removal of any item
2526
2627
- O(log n) updating of any item's priority level
2728
28-
Documentation at <http://pqdict.readthedocs.org/en/latest>.
29+
Documentation at <http://pqdict.readthedocs.org/>.
2930
30-
:copyright: (c) 2012-2023 by Nezar Abdennur.
31+
:copyright: (c) 2012-2024 by Nezar Abdennur.
3132
:license: MIT, see LICENSE for more details.
3233
3334
"""
@@ -593,8 +594,8 @@ def popitems(self) -> Iterator[Tuple[Any, Any]]:
593594
def heapify(self, key: Any = __marker) -> None:
594595
"""Repair a broken heap.
595596
596-
If the state of an item's priority value changes you can re-sort the
597-
relevant item only by providing ``key``.
597+
If a change in a single, mutable value caused the break, you can
598+
provide ``key`` to repair the heap by relocating that item.
598599
"""
599600
if key is self.__marker:
600601
heapify(self._heap, self._position, self._precedes)

0 commit comments

Comments
 (0)