eclipse / eclipse-collections

Eclipse Collections is a collections framework for Java with optimized data structures and a rich, functional and fluent API.
https://eclipse.dev/collections/
2.42k stars 604 forks source link

Reference Guide: Iteration patterns chapter has multiple issues in "Select and Reject patterns" section #1500

Open Chealer opened 1 year ago

Chealer commented 1 year ago

The Select and Reject patterns subsection of the chapter Iteration patterns of the reference guide contains a good number of issues. I've opted to report all of those I spotted in this ticket, but feel free to mark this as resolved once a first pass was done. If needed I will file individual tickets for those remaining.


The section opens with a quote:

Filter a collection to create a new collection: includes select, reject, and partition.

This quote's role is unclear, but it seems to be equally relevant to this subsection and the one which follows it.


The section continues:

Methods using the Select pattern return a new collection comprising those elements from the source collection that satisfy some logical condition. Reject is the inverse pattern, returning a new collection of elements that do not satisfy the condition. The condition is a boolean expression in the form of single-argument code block that implements the Predicate interface.

It would be more clear/exact to talk about a predicate than a "condition". In any case a predicate (or "condition") is not a boolean expression. While the predicate may be implemented using a boolean expression, a predicate is more generally an object. Moreover, such objects do not necessarily implement the Predicate interface (they can simply implement Predicate2). Finally, this is ambiguous since EC with a modern JDK provides 2 Predicate interfaces (org.eclipse.collections.api.block.predicate.Predicate and java.util.function.Predicate).


The second line of example #1 has spurious indentation (just like example #7). The third line would be more correct/clear as if <element> satisfies <condition>.


Example #3 does not indicate which Predicate class it refers to.


The section contains multiple examples using EC, but not all of them do. It would clarify to make each category distinguishable, perhaps by adding borders with different colors to their code blocks.


The section contains multiple examples, but there is no description of what any of them accomplishes. Either describing their effect or at least adding example values for collections would help. It should at least be possible to tell which are equivalent.


The order of examples seems counter-intuitive. Should #6 not come second?