Prev: Daylight Saving Shift
Next: The Nike Shox shoes were the product of a sixteen years of research in the Nike Labs. In the fall of 2000, the Nike Shox system was revealed to the world. Nike unveiled this top secret line of shoes to the world in 3 models, the Nike Shox R4 (runn
From: Eric Sosman on 4 Nov 2009 10:01 Wojtek wrote: > Eric Sosman wrote : >> Wojtek wrote: >>> Lew wrote : >>>> Lew wrote : >>>>>>> Map <TimeZone, String> map = >>>>>>> new TreeMap <TimeZone, String> ( new Comparator <TimeZone> () >>>>>>> { .... } ); >>>>> >>>> >>>> Wojtek wrote: >>>>>> No arguments that this does work. >>>>> >>>>>> However I was replying to your statement "'TimeZone' can easily be >>>>>> a map >>>>>> key, yes, even for a 'TreeMap'. " which appears to say that you do >>>>>> not >>>>>> need a custom Comparator: >>>>> >>>> >>>> Even though I had explicitly mentioned a custom Comparator in the post >>>> to which you were replying? Come on, now. Your explanation is >>>> disingenuous at best. >>> >>> To me a 'key' is the part which goes into the 'K' part of Map<K,V>. >> >> Yes, that's right. >> >>> For a Comparator, the signature is Comparator<T> where the 'T' refers >>> to a 'Type': >>> http://www.j2ee.me/javase/6/docs/api/java/util/Comparator.html >> >> ... which means only that the K in Map<K,V> is the same as >> the T in Comparator<T>, or is a subclass/subinterface of T. You >> shouldn't read too much into the particular letters chosen to name >> type parameters; the names are as arbitrary as those of method >> parameters, and carry no deeper meaning. >> >> Does Map<String,String> bother you, because String == String >> but K != V? If not, K != T shouldn't bother you, either, even if >> you have a Map<Book,Date> and a Comparator<Book> with Book == Book. > > Semantics! > > We work in a precise field. An extra semi-colon can make a world of > difference (brought down a phone system a few years ago). > > So yes, the labelling DOES make a difference. Whereas a Book is a Book, > where it is used does change its meaning. So in Map<Book,Date>, Book is > a key and in Comparator<Book>, Book is a Type. > > Otherwise the Javadoc author would not have made that distinction. > > It is used differently. As a key, it must provide its own comparison > methodology. As a type, the Comparator makes the comparison, possibly > using an external conversion such as I18N. I can only guess that your definition of "key" is unlike any I've encountered before. And, as mentioned before, that you attach entirely too much significance to the choice of a letter to name a formal parameter. <Shrug.> The rest of us will (when appropriate) use Comparators to key our SortedMaps on non-Comparables, or to key them using something other than their "natural order." You, I guess, will bemoan the impossibility of what the rest of us are doing ... -- Eric.Sosman(a)sun.com
From: Dr J R Stockton on 4 Nov 2009 16:58 In comp.lang.java.programmer message <mn.13c97d9bb78aa66e.70216(a)a.com>, Mon, 2 Nov 2009 16:09:42, Wojtek <nowhere(a)a.com> posted: >How would you sort timezones? > >I am trying to sort them according to their offset from UTC. I cannot >use a TreeMap because there are many timezones with the same offset, >which of course over-writes the previously put timezone. There are only about 30 Time Zones, since by definition a Time Zone consists of all places where the local Winter Time has the same difference from GMT - see a Dictionary, such as <http://en.wiktionary.org/wiki/time_zone> <http://www.chambersharrap.co.uk/chambers/features/chref/chref.py/main?t itle=21st&query=time+zone> <http://www.merriam-webster.com/dictionary/time+zone>. Time Zoning is not affected by Summer Time, except in the opinion of the semi-literates who write operating systems and suchlike. -- (c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05. Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc.
First
|
Prev
|
Pages: 1 2 3 4 5 6 Prev: Daylight Saving Shift Next: The Nike Shox shoes were the product of a sixteen years of research in the Nike Labs. In the fall of 2000, the Nike Shox system was revealed to the world. Nike unveiled this top secret line of shoes to the world in 3 models, the Nike Shox R4 (runn |