Kalkwst / MicroLib

MIT License
3 stars 0 forks source link

:sparkles: Add Transformer Queue Decorator #33

Open Kalkwst opened 1 year ago

Kalkwst commented 1 year ago

A transformer queue decorator is an additional layer of functionality that can be applied to an existing queue data structure, allowing it to transform its elements in a specific way, without modifying the underlying queue data structure. The decorator allows the user to define a specific transformation for the queue, which will be used to change the elements in the queue, without changing the way the queue is implemented. This enables the user to add this functionality to an existing queue without having to change the way the queue is implemented.

From a more technical perspective, a transformer queue decorator is a design pattern that can be used to add a new layer of functionality to an existing data structure. It is used to apply a specific transformation to the elements in an existing queue without having to change its underlying implementation. The decorator pattern is implemented using inheritance and composition, where the decorator class inherits from the queue class and adds new methods and/or fields to the queue class. The decorator class wraps the existing queue object and adds the new transformation functionality by overriding the appropriate methods. The new methods of the decorator class use the transformation function to change the elements in the underlying queue object. This way, the decorator class can be easily added to any existing queue and can be easily removed if it's not needed anymore. The time complexity of the enqueue, dequeue and peek operations in a transformer queue decorator depends on the complexity of the transformation function and the size of the queue.