pythonic-fp-queues 5.1.0__tar.gz → 5.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pythonic_fp_queues-5.1.0 → pythonic_fp_queues-5.1.1}/CHANGELOG.rst +5 -0
- {pythonic_fp_queues-5.1.0 → pythonic_fp_queues-5.1.1}/PKG-INFO +7 -7
- {pythonic_fp_queues-5.1.0 → pythonic_fp_queues-5.1.1}/README.rst +2 -2
- {pythonic_fp_queues-5.1.0 → pythonic_fp_queues-5.1.1}/pyproject.toml +5 -5
- {pythonic_fp_queues-5.1.0 → pythonic_fp_queues-5.1.1}/src/pythonic_fp/queues/__init__.py +8 -2
- {pythonic_fp_queues-5.1.0 → pythonic_fp_queues-5.1.1}/src/pythonic_fp/queues/de.py +12 -0
- pythonic_fp_queues-5.1.1/src/pythonic_fp/queues/de.pyi +31 -0
- {pythonic_fp_queues-5.1.0 → pythonic_fp_queues-5.1.1}/src/pythonic_fp/queues/fifo.py +9 -0
- pythonic_fp_queues-5.1.1/src/pythonic_fp/queues/fifo.pyi +24 -0
- {pythonic_fp_queues-5.1.0 → pythonic_fp_queues-5.1.1}/src/pythonic_fp/queues/lifo.py +8 -0
- pythonic_fp_queues-5.1.1/src/pythonic_fp/queues/lifo.pyi +23 -0
- pythonic_fp_queues-5.1.1/src/pythonic_fp/queues/py.typed +0 -0
- {pythonic_fp_queues-5.1.0 → pythonic_fp_queues-5.1.1}/.gitignore +0 -0
- {pythonic_fp_queues-5.1.0 → pythonic_fp_queues-5.1.1}/LICENSE +0 -0
- /pythonic_fp_queues-5.1.0/src/pythonic_fp/queues/py.typed → /pythonic_fp_queues-5.1.1/src/pythonic_fp/queues/__init__.pyi +0 -0
- {pythonic_fp_queues-5.1.0 → pythonic_fp_queues-5.1.1}/tests/test_queues.py +0 -0
|
@@ -17,6 +17,11 @@ See `Semantic Versioning 2.0.0 <https://semver.org>`_.
|
|
|
17
17
|
Releases and Important Milestones
|
|
18
18
|
---------------------------------
|
|
19
19
|
|
|
20
|
+
PyPI 5.1.1 - 2026-01-15
|
|
21
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
22
|
+
|
|
23
|
+
Docstring improvements for updated Sphinx documentation.
|
|
24
|
+
|
|
20
25
|
PyPI 5.1.0 - 2025-09-25
|
|
21
26
|
~~~~~~~~~~~~~~~~~~~~~~~
|
|
22
27
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pythonic-fp-queues
|
|
3
|
-
Version: 5.1.
|
|
3
|
+
Version: 5.1.1
|
|
4
4
|
Summary: Queues
|
|
5
5
|
Keywords: queue,fifo,lifo,dqueue
|
|
6
6
|
Author-email: "Geoffrey R. Scheller" <geoffrey@scheller.com>
|
|
@@ -14,12 +14,12 @@ Classifier: Operating System :: OS Independent
|
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.13
|
|
15
15
|
Classifier: Typing :: Typed
|
|
16
16
|
License-File: LICENSE
|
|
17
|
-
Requires-Dist: pythonic-fp-circulararray>=6.0.
|
|
18
|
-
Requires-Dist: pythonic-fp-fptools>=5.
|
|
17
|
+
Requires-Dist: pythonic-fp-circulararray>=6.0.1
|
|
18
|
+
Requires-Dist: pythonic-fp-fptools>=5.2.0
|
|
19
19
|
Requires-Dist: pytest>=8.4.1 ; extra == "test"
|
|
20
20
|
Project-URL: Changelog, https://github.com/grscheller/pythonic-fp-queues/blob/main/CHANGELOG.rst
|
|
21
|
-
Project-URL: Documentation, https://grscheller.github.io/pythonic-fp/queues/development/build/html/
|
|
22
|
-
Project-URL: Homepage, https://github.
|
|
21
|
+
Project-URL: Documentation, https://grscheller.github.io/pythonic-fp/queues/development/build/html/
|
|
22
|
+
Project-URL: Homepage, https://grscheller.github.io/pythonic-fp/homepage/build/html/
|
|
23
23
|
Project-URL: Source, https://github.com/grscheller/pythonic-fp-queues
|
|
24
24
|
Provides-Extra: test
|
|
25
25
|
|
|
@@ -42,7 +42,7 @@ PyPI project
|
|
|
42
42
|
|
|
43
43
|
Part of the
|
|
44
44
|
`pythonic-fp
|
|
45
|
-
<https://grscheller.github.io/pythonic-fp
|
|
45
|
+
<https://grscheller.github.io/pythonic-fp>`_
|
|
46
46
|
PyPI projects.
|
|
47
47
|
|
|
48
48
|
Documentation
|
|
@@ -50,7 +50,7 @@ Documentation
|
|
|
50
50
|
|
|
51
51
|
Documentation for this project is hosted on
|
|
52
52
|
`GitHub Pages
|
|
53
|
-
<https://grscheller.github.io/pythonic-fp/queues
|
|
53
|
+
<https://grscheller.github.io/pythonic-fp/queues>`_.
|
|
54
54
|
|
|
55
55
|
Copyright and License
|
|
56
56
|
---------------------
|
|
@@ -17,7 +17,7 @@ PyPI project
|
|
|
17
17
|
|
|
18
18
|
Part of the
|
|
19
19
|
`pythonic-fp
|
|
20
|
-
<https://grscheller.github.io/pythonic-fp
|
|
20
|
+
<https://grscheller.github.io/pythonic-fp>`_
|
|
21
21
|
PyPI projects.
|
|
22
22
|
|
|
23
23
|
Documentation
|
|
@@ -25,7 +25,7 @@ Documentation
|
|
|
25
25
|
|
|
26
26
|
Documentation for this project is hosted on
|
|
27
27
|
`GitHub Pages
|
|
28
|
-
<https://grscheller.github.io/pythonic-fp/queues
|
|
28
|
+
<https://grscheller.github.io/pythonic-fp/queues>`_.
|
|
29
29
|
|
|
30
30
|
Copyright and License
|
|
31
31
|
---------------------
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "pythonic-fp-queues"
|
|
3
|
-
version = "5.1.
|
|
3
|
+
version = "5.1.1"
|
|
4
4
|
readme = "README.rst"
|
|
5
5
|
requires-python = ">=3.12"
|
|
6
6
|
license = { file = "LICENSE" }
|
|
@@ -16,15 +16,15 @@ classifiers = [
|
|
|
16
16
|
"Typing :: Typed",
|
|
17
17
|
]
|
|
18
18
|
dependencies = [
|
|
19
|
-
"pythonic-fp-circulararray>=6.0.
|
|
20
|
-
"pythonic-fp-fptools>=5.
|
|
19
|
+
"pythonic-fp-circulararray>=6.0.1",
|
|
20
|
+
"pythonic-fp-fptools>=5.2.0",
|
|
21
21
|
]
|
|
22
22
|
dynamic = ["description"]
|
|
23
23
|
|
|
24
24
|
[project.urls]
|
|
25
25
|
Changelog = "https://github.com/grscheller/pythonic-fp-queues/blob/main/CHANGELOG.rst"
|
|
26
|
-
Documentation = "https://grscheller.github.io/pythonic-fp/queues/development/build/html/
|
|
27
|
-
Homepage = "https://github.
|
|
26
|
+
Documentation = "https://grscheller.github.io/pythonic-fp/queues/development/build/html/"
|
|
27
|
+
Homepage = "https://grscheller.github.io/pythonic-fp/homepage/build/html/"
|
|
28
28
|
Source = "https://github.com/grscheller/pythonic-fp-queues"
|
|
29
29
|
|
|
30
30
|
[project.optional-dependencies]
|
|
@@ -14,7 +14,13 @@
|
|
|
14
14
|
|
|
15
15
|
"""
|
|
16
16
|
Queues
|
|
17
|
-
|
|
17
|
+
------
|
|
18
|
+
|
|
19
|
+
.. admonition:: Stateful Queues based on a circular array.
|
|
20
|
+
|
|
21
|
+
Geared to specific algorithms by limiting what can be done with the
|
|
22
|
+
queues. Sometimes the power of a data structure is not what it
|
|
23
|
+
empowers you to do, but what it prevents you from doing to yourself.
|
|
18
24
|
|
|
19
25
|
+-------------------------+-----------+--------------------------+
|
|
20
26
|
| module | class | name |
|
|
@@ -29,5 +35,5 @@ Queues
|
|
|
29
35
|
"""
|
|
30
36
|
|
|
31
37
|
__author__ = 'Geoffrey R. Scheller'
|
|
32
|
-
__copyright__ = 'Copyright (c) 2023-
|
|
38
|
+
__copyright__ = 'Copyright (c) 2023-2026 Geoffrey R. Scheller'
|
|
33
39
|
__license__ = 'Apache License 2.0'
|
|
@@ -39,6 +39,7 @@ class DEQueue[D]:
|
|
|
39
39
|
:param dss: "Optionally" takes a single iterable to initialize data in FIFO order.
|
|
40
40
|
:raises TypeError: When ``dss[0]`` not Iterable.
|
|
41
41
|
:raises ValueError: If more than 1 iterable is given.
|
|
42
|
+
|
|
42
43
|
"""
|
|
43
44
|
if (size := len(dss)) > 1:
|
|
44
45
|
msg = f'DEQueue expects at most 1 argument, got {size}'
|
|
@@ -74,6 +75,7 @@ class DEQueue[D]:
|
|
|
74
75
|
"""Shallow copy.
|
|
75
76
|
|
|
76
77
|
:returns: Shallow copy of the DEQueue.
|
|
78
|
+
|
|
77
79
|
"""
|
|
78
80
|
return DEQueue(self._ca)
|
|
79
81
|
|
|
@@ -81,6 +83,7 @@ class DEQueue[D]:
|
|
|
81
83
|
"""Push data onto left side of DEQueue.
|
|
82
84
|
|
|
83
85
|
:param ds: Items to be pushed onto DEQueue from the left.
|
|
86
|
+
|
|
84
87
|
"""
|
|
85
88
|
self._ca.pushl(*ds)
|
|
86
89
|
|
|
@@ -88,6 +91,7 @@ class DEQueue[D]:
|
|
|
88
91
|
"""Push data onto right side of DEQueue.
|
|
89
92
|
|
|
90
93
|
:param ds: Items to be pushed onto DEQueue from the right.
|
|
94
|
+
|
|
91
95
|
"""
|
|
92
96
|
self._ca.pushr(*ds)
|
|
93
97
|
|
|
@@ -95,6 +99,7 @@ class DEQueue[D]:
|
|
|
95
99
|
"""Pop next item from left side DEQueue, if it exists.
|
|
96
100
|
|
|
97
101
|
:returns: MayBe of popped item if queue was not empty, empty MayBe otherwise.
|
|
102
|
+
|
|
98
103
|
"""
|
|
99
104
|
if self._ca:
|
|
100
105
|
return MayBe(self._ca.popl())
|
|
@@ -104,6 +109,7 @@ class DEQueue[D]:
|
|
|
104
109
|
"""Pop next item off right side DEQueue, if it exists.
|
|
105
110
|
|
|
106
111
|
:returns: MayBe of popped item if queue was not empty, empty MayBe otherwise.
|
|
112
|
+
|
|
107
113
|
"""
|
|
108
114
|
if self._ca:
|
|
109
115
|
return MayBe(self._ca.popr())
|
|
@@ -113,6 +119,7 @@ class DEQueue[D]:
|
|
|
113
119
|
"""Peak left side of DEQueue. Does not consume item.
|
|
114
120
|
|
|
115
121
|
:returns: MayBe of leftmost item if queue not empty, empty MayBe otherwise.
|
|
122
|
+
|
|
116
123
|
"""
|
|
117
124
|
if self._ca:
|
|
118
125
|
return MayBe(self._ca[0])
|
|
@@ -122,6 +129,7 @@ class DEQueue[D]:
|
|
|
122
129
|
"""Peak right side of DEQueue. Does not consume item.
|
|
123
130
|
|
|
124
131
|
:returns: MayBe of rightmost item if queue not empty, empty MayBe otherwise.
|
|
132
|
+
|
|
125
133
|
"""
|
|
126
134
|
if self._ca:
|
|
127
135
|
return MayBe(self._ca[-1])
|
|
@@ -138,6 +146,7 @@ class DEQueue[D]:
|
|
|
138
146
|
:param f: Reducing function, first argument is for accumulator.
|
|
139
147
|
:param start: Optional starting value.
|
|
140
148
|
:returns: MayBe of reduced value with f, empty MayBe if queue empty and no starting value given.
|
|
149
|
+
|
|
141
150
|
"""
|
|
142
151
|
if start is None:
|
|
143
152
|
if not self._ca:
|
|
@@ -156,6 +165,7 @@ class DEQueue[D]:
|
|
|
156
165
|
:param f: Reducing function, second argument is for accumulator.
|
|
157
166
|
:param start: Optional starting value.
|
|
158
167
|
:returns: MayBe of reduced value with f, empty MayBe if queue empty and no starting value given.
|
|
168
|
+
|
|
159
169
|
"""
|
|
160
170
|
if start is None:
|
|
161
171
|
if not self._ca:
|
|
@@ -172,6 +182,7 @@ class DEQueue[D]:
|
|
|
172
182
|
|
|
173
183
|
:param f: Function to map over queue.
|
|
174
184
|
:returns: New DEQueue instance, retain original order.
|
|
185
|
+
|
|
175
186
|
"""
|
|
176
187
|
return DEQueue(map(f, self._ca))
|
|
177
188
|
|
|
@@ -181,5 +192,6 @@ def de_queue[D](*ds: D) -> DEQueue[D]:
|
|
|
181
192
|
|
|
182
193
|
:param ds: Initial items as if pushed on from right to left.
|
|
183
194
|
:returns: DEQueue with items initialized in FIFO order.
|
|
195
|
+
|
|
184
196
|
"""
|
|
185
197
|
return DEQueue(ds)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from collections.abc import Callable, Iterable, Iterator
|
|
2
|
+
from pythonic_fp.fptools.maybe import MayBe
|
|
3
|
+
from typing import overload
|
|
4
|
+
|
|
5
|
+
__all__ = ['DEQueue', 'de_queue']
|
|
6
|
+
|
|
7
|
+
class DEQueue[D]:
|
|
8
|
+
def __init__(self, *dss: Iterable[D]) -> None: ...
|
|
9
|
+
def __bool__(self) -> bool: ...
|
|
10
|
+
def __len__(self) -> int: ...
|
|
11
|
+
def __eq__(self, other: object) -> bool: ...
|
|
12
|
+
def __iter__(self) -> Iterator[D]: ...
|
|
13
|
+
def __reversed__(self) -> Iterator[D]: ...
|
|
14
|
+
def copy(self) -> DEQueue[D]: ...
|
|
15
|
+
def pushl(self, *ds: D) -> None: ...
|
|
16
|
+
def pushr(self, *ds: D) -> None: ...
|
|
17
|
+
def popl(self) -> MayBe[D]: ...
|
|
18
|
+
def popr(self) -> MayBe[D]: ...
|
|
19
|
+
def peakl(self) -> MayBe[D]: ...
|
|
20
|
+
def peakr(self) -> MayBe[D]: ...
|
|
21
|
+
@overload
|
|
22
|
+
def foldl[L](self, f: Callable[[D, D], D]) -> MayBe[D]: ...
|
|
23
|
+
@overload
|
|
24
|
+
def foldl[L](self, f: Callable[[L, D], L], start: L) -> MayBe[L]: ...
|
|
25
|
+
@overload
|
|
26
|
+
def foldr[R](self, f: Callable[[D, D], D]) -> MayBe[D]: ...
|
|
27
|
+
@overload
|
|
28
|
+
def foldr[R](self, f: Callable[[D, R], R], start: R) -> MayBe[R]: ...
|
|
29
|
+
def map[U](self, f: Callable[[D], U]) -> DEQueue[U]: ...
|
|
30
|
+
|
|
31
|
+
def de_queue[D](*ds: D) -> DEQueue[D]: ...
|
|
@@ -38,6 +38,7 @@ class FIFOQueue[D]:
|
|
|
38
38
|
"""
|
|
39
39
|
:param dss: Takes 1 or 0 iterables, initializes items in natural FIFO order.
|
|
40
40
|
:raises ValueError: If more than 1 iterable is given.
|
|
41
|
+
|
|
41
42
|
"""
|
|
42
43
|
if (size := len(dss)) > 1:
|
|
43
44
|
msg = f'FIFOQueue expects at most 1 iterable argument, got {size}'
|
|
@@ -70,6 +71,7 @@ class FIFOQueue[D]:
|
|
|
70
71
|
"""Shallow copy.
|
|
71
72
|
|
|
72
73
|
:returns: Shallow copy of the FIFOQueue.
|
|
74
|
+
|
|
73
75
|
"""
|
|
74
76
|
return FIFOQueue(self._ca)
|
|
75
77
|
|
|
@@ -77,6 +79,7 @@ class FIFOQueue[D]:
|
|
|
77
79
|
"""Push items onto FIFOQueue.
|
|
78
80
|
|
|
79
81
|
:param ds: Items to be pushed onto FIFOQueue.
|
|
82
|
+
|
|
80
83
|
"""
|
|
81
84
|
self._ca.pushr(*ds)
|
|
82
85
|
|
|
@@ -84,6 +87,7 @@ class FIFOQueue[D]:
|
|
|
84
87
|
"""Pop oldest data item off of FIFOQueue.
|
|
85
88
|
|
|
86
89
|
:returns: MayBe of popped data item if queue was not empty, empty MayBe otherwise.
|
|
90
|
+
|
|
87
91
|
"""
|
|
88
92
|
if self._ca:
|
|
89
93
|
return MayBe(self._ca.popl())
|
|
@@ -93,6 +97,7 @@ class FIFOQueue[D]:
|
|
|
93
97
|
"""Peak at newest item on queue.
|
|
94
98
|
|
|
95
99
|
:returns: MayBe of newest item on queue, empty MayBe if queue empty.
|
|
100
|
+
|
|
96
101
|
"""
|
|
97
102
|
if self._ca:
|
|
98
103
|
return MayBe(self._ca[-1])
|
|
@@ -102,6 +107,7 @@ class FIFOQueue[D]:
|
|
|
102
107
|
"""Peak at oldest data item on queue.
|
|
103
108
|
|
|
104
109
|
:returns: MayBe of oldest item on queue, empty MayBe if queue empty.
|
|
110
|
+
|
|
105
111
|
"""
|
|
106
112
|
if self._ca:
|
|
107
113
|
return MayBe(self._ca[0])
|
|
@@ -118,6 +124,7 @@ class FIFOQueue[D]:
|
|
|
118
124
|
:param f: Reducing function, first argument is for accumulator.
|
|
119
125
|
:param start: Optional starting value.
|
|
120
126
|
:returns: MayBe of reduced value, empty MayBe if queue empty and no starting value given.
|
|
127
|
+
|
|
121
128
|
"""
|
|
122
129
|
if start is None:
|
|
123
130
|
if not self._ca:
|
|
@@ -130,6 +137,7 @@ class FIFOQueue[D]:
|
|
|
130
137
|
|
|
131
138
|
:param f: Function to map over queue.
|
|
132
139
|
:returns: New FIFOQueue instance.
|
|
140
|
+
|
|
133
141
|
"""
|
|
134
142
|
return FIFOQueue(map(f, self._ca))
|
|
135
143
|
|
|
@@ -139,5 +147,6 @@ def fifo_queue[D](*ds: D) -> FIFOQueue[D]:
|
|
|
139
147
|
|
|
140
148
|
:param ds: Initial items pushed on in FIFO order.
|
|
141
149
|
:returns: FIFOQueue with initialized items from ``ds``.
|
|
150
|
+
|
|
142
151
|
"""
|
|
143
152
|
return FIFOQueue(ds)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from collections.abc import Callable, Iterable, Iterator
|
|
2
|
+
from pythonic_fp.fptools.maybe import MayBe
|
|
3
|
+
from typing import overload
|
|
4
|
+
|
|
5
|
+
__all__ = ['FIFOQueue', 'fifo_queue']
|
|
6
|
+
|
|
7
|
+
class FIFOQueue[D]:
|
|
8
|
+
def __init__(self, *dss: Iterable[D]) -> None: ...
|
|
9
|
+
def __bool__(self) -> bool: ...
|
|
10
|
+
def __len__(self) -> int: ...
|
|
11
|
+
def __eq__(self, other: object) -> bool: ...
|
|
12
|
+
def __iter__(self) -> Iterator[D]: ...
|
|
13
|
+
def copy(self) -> FIFOQueue[D]: ...
|
|
14
|
+
def push(self, *ds: D) -> None: ...
|
|
15
|
+
def pop(self) -> MayBe[D]: ...
|
|
16
|
+
def peak_last_in(self) -> MayBe[D]: ...
|
|
17
|
+
def peak_next_out(self) -> MayBe[D]: ...
|
|
18
|
+
@overload
|
|
19
|
+
def fold[T](self, f: Callable[[D, D], D]) -> MayBe[D]: ...
|
|
20
|
+
@overload
|
|
21
|
+
def fold[T](self, f: Callable[[T, D], T], start: T) -> MayBe[T]: ...
|
|
22
|
+
def map[U](self, f: Callable[[D], U]) -> FIFOQueue[U]: ...
|
|
23
|
+
|
|
24
|
+
def fifo_queue[D](*ds: D) -> FIFOQueue[D]: ...
|
|
@@ -38,6 +38,7 @@ class LIFOQueue[D]:
|
|
|
38
38
|
"""
|
|
39
39
|
:param dss: Takes 1 or 0 iterables, initializes data in natural LIFO order.
|
|
40
40
|
:raises ValueError: If more than 1 iterable is given.
|
|
41
|
+
|
|
41
42
|
"""
|
|
42
43
|
if (size := len(dss)) > 1:
|
|
43
44
|
msg = f'LIFOQueue expects at most 1 iterable argument, got {size}'
|
|
@@ -70,6 +71,7 @@ class LIFOQueue[D]:
|
|
|
70
71
|
"""Shallow copy.
|
|
71
72
|
|
|
72
73
|
:returns: Shallow copy of the LIFOQueue.
|
|
74
|
+
|
|
73
75
|
"""
|
|
74
76
|
return LIFOQueue(reversed(self._ca))
|
|
75
77
|
|
|
@@ -77,6 +79,7 @@ class LIFOQueue[D]:
|
|
|
77
79
|
"""Push items onto LIFOQueue.
|
|
78
80
|
|
|
79
81
|
:param ds: Items to be pushed onto LIFOQueue.
|
|
82
|
+
|
|
80
83
|
"""
|
|
81
84
|
self._ca.pushr(*ds)
|
|
82
85
|
|
|
@@ -84,6 +87,7 @@ class LIFOQueue[D]:
|
|
|
84
87
|
"""Pop newest data item off of LIFOQueue.
|
|
85
88
|
|
|
86
89
|
:returns: MayBe of popped item if queue was not empty, empty MayBe otherwise.
|
|
90
|
+
|
|
87
91
|
"""
|
|
88
92
|
if self._ca:
|
|
89
93
|
return MayBe(self._ca.popr())
|
|
@@ -93,6 +97,7 @@ class LIFOQueue[D]:
|
|
|
93
97
|
"""Peak at newest item on queue.
|
|
94
98
|
|
|
95
99
|
:returns: MayBe of newest item on queue, empty MayBe if queue empty.
|
|
100
|
+
|
|
96
101
|
"""
|
|
97
102
|
if self._ca:
|
|
98
103
|
return MayBe(self._ca[-1])
|
|
@@ -109,6 +114,7 @@ class LIFOQueue[D]:
|
|
|
109
114
|
:param f: Reducing function, first argument is for accumulator.
|
|
110
115
|
:param start: Optional starting value.
|
|
111
116
|
:returns: MayBe of reduced value, empty MayBe if queue empty and no starting value given.
|
|
117
|
+
|
|
112
118
|
"""
|
|
113
119
|
if start is None:
|
|
114
120
|
if not self._ca:
|
|
@@ -121,6 +127,7 @@ class LIFOQueue[D]:
|
|
|
121
127
|
|
|
122
128
|
:param f: Function to map over queue.
|
|
123
129
|
:returns: New LIFOQueue instance.
|
|
130
|
+
|
|
124
131
|
"""
|
|
125
132
|
return LIFOQueue(reversed(CA(map(f, reversed(self._ca)))))
|
|
126
133
|
|
|
@@ -130,5 +137,6 @@ def lifo_queue[D](*ds: D) -> LIFOQueue[D]:
|
|
|
130
137
|
|
|
131
138
|
:param ds: Initial items pushed on in LIFO order.
|
|
132
139
|
:returns: LIFOQueue with initialized items from ``ds``.
|
|
140
|
+
|
|
133
141
|
"""
|
|
134
142
|
return LIFOQueue(ds)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from collections.abc import Callable, Iterable, Iterator
|
|
2
|
+
from pythonic_fp.fptools.maybe import MayBe
|
|
3
|
+
from typing import overload
|
|
4
|
+
|
|
5
|
+
__all__ = ['LIFOQueue', 'lifo_queue']
|
|
6
|
+
|
|
7
|
+
class LIFOQueue[D]:
|
|
8
|
+
def __init__(self, *dss: Iterable[D]) -> None: ...
|
|
9
|
+
def __bool__(self) -> bool: ...
|
|
10
|
+
def __len__(self) -> int: ...
|
|
11
|
+
def __eq__(self, other: object) -> bool: ...
|
|
12
|
+
def __iter__(self) -> Iterator[D]: ...
|
|
13
|
+
def copy(self) -> LIFOQueue[D]: ...
|
|
14
|
+
def push(self, *ds: D) -> None: ...
|
|
15
|
+
def pop(self) -> MayBe[D]: ...
|
|
16
|
+
def peak(self) -> MayBe[D]: ...
|
|
17
|
+
@overload
|
|
18
|
+
def fold[T](self, f: Callable[[D, D], D]) -> MayBe[D]: ...
|
|
19
|
+
@overload
|
|
20
|
+
def fold[T](self, f: Callable[[T, D], T], start: T) -> MayBe[T]: ...
|
|
21
|
+
def map[U](self, f: Callable[[D], U]) -> LIFOQueue[U]: ...
|
|
22
|
+
|
|
23
|
+
def lifo_queue[D](*ds: D) -> LIFOQueue[D]: ...
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|