About Searching Methods #40
cmglezpdev
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
First, I want to add several methods to the
Search
class like:Search:
Returns the position of the first occurrence of an element in the collection.Lower bound:
Returns the lower limit of the collection.Upper bound:
Returns the upper limit of the collection.Count:
returns all positions when the element has an occurrenceThese methods would be implemented by all the subclasses that define the different
search strategies
.I would also like to implement some methods like in
javascript
, where the search method receives not an item, but a condition function and be able to evaluate the elements of the collection based on the condition function.Examples to this are the methods:
some:
Return True if at least one item satisfaces the conditionfilter:
Return all the items that satisfaces the conditioncount:
the same count method above, but with a function's conditionI don't now if it's a good idea, but for that is that i created this discussion. I need your opinions
UPD: Also, if you have some ideas on how to implement binary search based on a condition function, that would be great. I think that it would be nice to abstract the search for a specific item to a search of one or multiple items based in a function. It would be very useful
Beta Was this translation helpful? Give feedback.
All reactions