Data Structures¶
-
class
pyfoamalgo.OrderedSet(sequence=None)¶ A set which remembers the original insertion order.
-
class
pyfoamalgo.SimpleQueue(maxsize=0)¶ A thread-safe queue for passing data fast between threads.
It does not provide the functionality of coordination among threads as threading.Queue, but is way more faster.
-
__init__(maxsize=0)¶ Initialization.
- Parameters
maxsize (int) – if maxsize is <= 0, the queue size is infinite.
-
get()¶ Remove and return an item from the queue.
- Raises
Empty – if the queue is Empty.
-
put(item)¶ Put an item into the queue.
- Raises
Full – if the queue is already full.
-
qsize()¶ Return the number of elements in the queue.
-
empty()¶ Check whether the queue is empty.
-
full()¶ Check whether the queue is full.
-
clear()¶ Clear the queue.
-
-
class
pyfoamalgo.Stack¶ An LIFO (last-in first-out) stack.
-
__init__()¶ Initialization.
-
push(item)¶ Append a new element.
-
pop()¶ Return and remove the top element.
- Raises
IndexError – If the stack is empty.
-
top()¶ Return the first element.
- Raises
IndexError – If the stack is empty.
-
empty()¶ Check whether the stack is empty.
-