This PR introduces a reactive SortedSet, which extends the capabilities of the Set to derive a perception of weight and order for its elements.
We expose the information through the following additional API endpoints:
// SortedSet is a reactive Set implementation that allows consumers to subscribe to its changes
// and that keeps a sorted perception of its elements.
type SortedSet[ElementType comparable] interface {
// Set imports the methods of the Set interface.
Set[ElementType]
// Ascending returns a slice of all elements of the set in ascending order.
Ascending() []ElementType
// Descending returns a slice of all elements of the set in descending order.
Descending() []ElementType
// HeaviestElement returns the element with the heaviest weight.
HeaviestElement() ReadableVariable[ElementType]
// LightestElement returns the element with the lightest weight.
LightestElement() ReadableVariable[ElementType]
}
Type of change
Enhancement (a non-breaking change which adds functionality)
Change checklist
[x] My code follows the contribution guidelines for this project
[x] I have performed a self-review of my own code
[x] I have commented my code, particularly in hard-to-understand areas
[x] I have made corresponding changes to the documentation
[x] I have added tests that prove my fix is effective or that my feature works
[x] New and existing unit tests pass locally with my changes
Description of change
This PR introduces a reactive SortedSet, which extends the capabilities of the Set to derive a perception of weight and order for its elements.
We expose the information through the following additional API endpoints:
Type of change
Change checklist