[PATCH] improve javadoc in TreeSet#add api documentation
kishor.gollapalliwar at gmail.com
Thu Dec 13 15:19:06 UTC 2018
Forgive me for delayed response.
I was not well for a week, due to which lot of work got queued up in
office. It took a while to sort it out.
Your guidance was really helpful.
And by end of this week I'll share first patch, containing document
enhancements for SortedSet class.
Hope I'm not too late.
On Fri 30 Nov, 2018, 10:22 Stuart Marks <stuart.marks at oracle.com wrote:
> On 11/1/18 8:12 PM, Kishor Gollapalliwar wrote:
> > Thank you for providing this opportunity. I'm up for this challenge and
> > love to take this task. The only huddle would be, how to proceed, ie
> > things step by step, as this is my first time. If you can help me with
> > planning, I'll do the rest and fix these issues.
> Hi, sorry for the delay. I had a couple conferences and then some vacation.
> This issue comes up periodically. Consider this Stack Overflow question
> and this
> answer in particular:
> It quotes the relevant part of the TreeSet spec (which is also in the
> > Note that the ordering maintained by a sorted set (whether or not an
> > comparator is provided) must be consistent with equals if the sorted set
> > to correctly implement the Set interface. (See the Comparable interface
> > Comparator interface for a precise definition of consistent with equals.)
> > This is so because the Set interface is defined in terms of the equals
> > operation, but a sorted set performs all element comparisons using its
> > compareTo (or compare) method, so two elements that are deemed equal by
> > method are, from the standpoint of the sorted set, equal. The behavior
> of a
> > sorted set is well-defined even if its ordering is inconsistent with
> > it just fails to obey the general contract of the Set interface.
> What's missing here are 1) a clear statement that membership in a
> SortedSet is
> determined by the comparison method, and 2) a crisp definition of
> Various places in the spec mention something like "the Comparator's
> method, if there is a comparator method, otherwise the compareTo() method
> if the
> set is using the elements' natural order...." The term "comparison method"
> should be defined early on so that it can be used in later parts of the
> avoiding the comparator/natural-order awkwardness.
> Then, it should be specified that the comparison method 1) determines
> in the set as well as 2) ordering of set iteration, subsetting, etc. This
> overlaps some with the first two paragraphs of the SortedSet class spec.
> Regarding membership, the Set interface says:
> > sets contain no pair of elements e1 and e2 such that e1.equals(e2)
> SortedSet should have something similar, e.g.,
> > SortedSets contain no pair of elements e1 and e2 such that e1 CMP e2 == 0
> where "CMP" is the "comparison method". (You don't have to use this
> but the idea is that there is no pair of elements in the set for which the
> comparison method returns zero.)
> Only at this point should the "consistent with equals" discussion be
> The problem with the existing text is that it introduces the "consistent
> equals" topic, and then only incidentally mentions that set membership is
> determined by "equality" according to the comparison method instead of
> That's the first step, which basically amounts to rewriting the first
> paragraphs of the SortedSet class specification. The subsequent steps are:
> 2) Reconcile class doc of SortedSet subtypes, e.g. NavigableSet, TreeSet,
> possibly ConcurrentSkipListSet.
> 3) Audit all method specs of all classes and reconcile them with the class
> specs. A starting point for methods to look at is in this bug:
> 4) 5) 6) Similar steps as above for the SortedMap family.
> I'd suggest just starting off with the first step instead of trying to do
> it all
> at once. Don't worry about posting webrevs or specdiffs yet; just send a
> or even plain text of the draft to the list and I'll start reviewing it.
More information about the core-libs-dev