Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: v_borchert@despammed.com (Volker Borchert) Newsgroups: comp.lang.java.programmer Subject: Re: Wanted: List of intervals Date: 18 Feb 2017 19:58:59 GMT Organization: Private site at Eddersheim, Germany Lines: 24 Distribution: world Message-ID: References: X-Trace: individual.net +GRLMYKdSdsn+Q2mdZLzUgAJqpTPe3xVTCYpVT8hauO1jEe8sf Cancel-Lock: sha1:xS7G7PkPQ3N1C4A5nYWXzPUCrgs= Xref: csiph.com comp.lang.java.programmer:36329 Martin Gregorie wrote: > On Sat, 18 Feb 2017 08:06:17 +0000, Volker Borchert wrote: > > > Martin Gregorie wrote: > >> No need of that: the TreeMap class is based on a red-black tree. > > > > At least I'd have to subclass it to reasonably implement the > > look-at-neighbors-during-addition and to avoid the additional object > > overhead for either the $Entry (if using TreeSet) or two Long (if > > using TreeMap). And even then, the $Entry will still have > > three references and one boolean extra. Given that insertion is O(log n) > > with nontrivial constants, > > > There's no reason why the key Long has to be separate: you can define > your own class to hold the long and a boolean and use the long's getter > method as the key reference. It'll still be an object separate from the TreeSet/TreeMap $Entry and have its own two word header and the reference from the $Entry. -- "I'm a doctor, not a mechanic." Dr Leonard McCoy "I'm a mechanic, not a doctor." Volker Borchert