Kalkwst / MicroLib

MIT License
3 stars 0 forks source link

:sparkles: Add Predicated List Decorator #26

Open Kalkwst opened 1 year ago

Kalkwst commented 1 year ago

A predicated list decorator is an additional layer of functionality that can be applied to an existing list data structure to enable it to use a specific rule or condition, known as a predicate, to organize its elements. The decorator allows the user to define a specific predicate for the list, which will be used to organize the elements in the list in a specific way, without modifying the underlying list data structure. This enables the user to add this functionality to an existing list without having to change the way the list is implemented.

From a more technical perspective, a predicated list 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 add a predicate-based organization to an existing list without having to change its underlying implementation. The decorator pattern is implemented using inheritance and composition, where the decorator class inherits from the list class and adds new methods and/or fields to the list class. The decorator class wraps the existing list object and adds the new predicate-based functionality by overriding the appropriate methods. The new methods of the decorator class use the predicate to organize the elements in the underlying list object. This way, the decorator class can be easily added to any existing list and can be easily removed if it's not needed anymore. The time complexity of the search, insertion and deletion operations in a predicated list decorator depends on the complexity of the predicate and the size of the list.