plastid.util.unique_fifo module¶
- class plastid.util.unique_fifo.UniqueFIFO(size)[source]¶
Bases:
object
FIFO of unique objects. In other words, if an element already present in the FIFO is appended to the FIFO, it is moved to the right end and no element is removed from the FIFO. Elements are only removed when a element not present in the FIFO is appended to the right end, and when the number of elements in the FIFO exceeds self.max_size.
- Parameters
- idxint
Index of item to fetch
- Returns
- object
Nth item in the
UniqueFIFO
- Attributes
- max_sizeint
Maximum size of
UniqueFIFO
Methods
append
(el)Append an item to the
UniqueFIFO
.- append(el)[source]¶
Append an item to the
UniqueFIFO
. If the item is already present in theUniqueFIFO
, it is moved to the right end of the FIFO, and the length of theUniqueFIFO
is unchanged. Otherwise, the element is appended to the right end. If the length of theUniqueFIFO
then exceeds self.max_size, the fist element is popped.- Parameters
- elhashable
Any hashable object