vigna / fastutil

fastutil extends the Java™ Collections Framework by providing type-specific maps, sets, lists and queues.
Apache License 2.0
1.8k stars 197 forks source link

Add identity() to UnaryOperator #210

Closed techsy730 closed 3 years ago

techsy730 commented 3 years ago

Adds the static method identity to UnaryOperator For numeric primitives, adds negation, performing arithmetic negation. For BooleanUnaryOperator, adds negation, performing logical negation.

For BooleanPredicate, it also adds those methods, as it also takes a boolean and returns a boolean, thus they make sense there too.

vigna commented 3 years ago

I'm a bit concerned by these semantic mixups. More than anything because each of these concepts has a different method naming. That's why IntUnaryOperator is not a Int2In2Function. I think we should keep the conceptual separation of the JDK unless there's some cogent reason.

techsy730 commented 3 years ago

Fair enough. How about I remove BooleanPredicate extending BooleanUnaryOperator, but keep the new identity and negation methods?

techsy730 commented 3 years ago

Ok done. BooleanPredicate no longer extends BooleanUnaryOperator

vigna commented 3 years ago

Thanks, I forgot the identity method.

At this point was could as well add numeric negation to all other types except for char...

techsy730 commented 3 years ago

Ok, added a negation for numeric types.