Is it different from headMap(key, true).size() / tailMap(key, true).size() ?
https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/util/NavigableMap.html#headMap(K,boolean) https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/util/NavigableMap.html#tailMap(K,boolean) cheers, Rémi ----- Mail original ----- > De: "mayank bansal" <mayankbansal...@gmail.com> > À: "core-libs-dev" <core-libs-dev@openjdk.java.net> > Envoyé: Dimanche 8 Novembre 2020 11:22:01 > Objet: Class TreeMap<K,V> | Lower and Upper Count Support > Hi Everyone, > > I would like to propose and work on a feature request of supporting the > lower and higher count in java class TreeMap. > "lower count" is the number of elements that are strictly less than the > given value. > "upper count" is the number of elements that are strictly greater than the > given value. > > *Method definitions-* > int getLowerCount(K key); > int getHigherCount(K key); > > *Follow-up feature -* > Class TreeSet<E> constructor initializes the TreeMap<K,V> in the TreeSet > constructor. > It puts the dummy value as *new Object()* whenever we add the entry in > TreeSet. > I would like to work on the feature to provide the *Duplicate count* in > case of the same Key and the same Value. > > I will be happy to work on both and raise a PR. I need some guidance if the > proposed feature looks good and I can start working on it and also would > like to know about the process whether I can directly raise the PR. > > Thanks > -- > Regards, > Mayank Bansal