let's say i have a list with some elements and i want to choose all those who do not satisfy a certain condition. i was thinking about something like this:
public void choose(Condition c) {
choose all elements that satisfy c.CheckCondition(elem)
}
however, i think it's highly unelegant and it forces to user to implement a Condition
object with
a certain function that will check if an element satisfies a condition.
if it was c++ i would send a pointer to a function as a parameter but its not possible in java.
I thought about using Comparable
object but it's no good since i have to implement it in my class instead of getting it from the user.
any other elegant ideas for this problem?
thanks!