filo¶
- class pythonic_fp.queues.fifo.FIFOQueue¶
Bases:
GenericFIFOQueue
Stateful First-In-First-Out (FIFO) Queue data structure.
O(1) pops
O(1) amortized pushes
O(1) length determination
in a Boolean context, truthy if not empty, falsy if empty
will automatically increase storage capacity when needed
neither indexable nor sliceable by design
- __init__(*ds: Iterable) None¶
Initializer
Initialize
FIFOQueuewith 0 or 1 iterables to populate the queue in natural FIFO order.- Parameters:
ds – Takes 0 or 1 iterable parameters.
- Raises:
ValueError – When more than one parameter is provided.
TypeError – When passed a non-iterable parameter.
- __bool__() bool¶
Truthiness
FIFOQueuetruthy when non-empty, falsy when empty.
- __len__() int¶
Get length
Return the number of data elements in the
FIFOQueue.
- __eq__(other: object) bool¶
Equality comparison
If
otheris aFIFOQueueand the corresponding elements ofselfandothercompare as equal, then returnTrue. Otherwise returnFalse.- Returns:
self == other
- __iter__() Iterator¶
Iteration
Iterate over current state in natural FIFO order.
- Returns:
An iterator of the data.
- __repr__() str¶
String representation
Construct string ‘FIFOQueue(d₁, d₂, … dₙ)’ where
d₁, d₂, … dₙ are the contents displayed with
repr()
- Returns:
A string to reproduce the
FIFOQueue.
- __str__() str¶
User string
Construct string ‘<< d₁ < d₂ < … < dₙ <<’ where
d₁, d₂, …, dₙ are the contents displayed with
str()
- Returns:
A string meaningful to an end user.
- copy() FIFOQueue[D]¶
Copy
Shallow copy the
FIFOQueue.- Returns:
New
FIFOQueueinstance containing the same references.
- push(*ds: D) None¶
Push
Push data items onto
FIFOQueue.- Parameters:
ds – Items to be pushed onto ‘’FIFOQueue’’.
- pop() MayBe¶
Pop
Pop oldest data item off of
FIFOQueue.- Returns:
MayBeof popped data item ifFIFOQueuewas not empty, emptyMayBeotherwise.
- peak_last_in() MayBe¶
Peak last
Peak at newest item on
FIFOQueue.- Returns:
MayBeof newest item onFIFOQueue, emptyMayBeifFIFOQueueempty.
- peak_next_out() MayBe¶
-
- Returns:
MayBeof oldest item onFIFOQueue, emptyMayBeifFIFOueueempty.
- fold(f: Callable[[D, D], D]) MayBe[D]¶
- fold(f: Callable[[T, D], T], start: T) MayBe[T]
Fold
Reduces
FIFOQueuein natural FIFO Order, oldest to newest.- Parameters:
f – Reducing function, first argument is for accumulator.
start – Optional starting value.
- Returns:
MayBeof reduced value withf, emptyMayBeifFIFOQueueempty and no starting value given.