Juha-P Lindfors wrote: >On Sun, 28 Apr 2002, marc fleury wrote: > >>Juha for example. By spec must we have >>Domain1:name1=value1;name2=value2 == Domain1:name2=value2;name1=value1 ??? >> >>I would imagine so, >> > > >yes and this is the problem for performance > >-- Juha > I've been following this discussion and I'd like to throw in my $.02: Can the implementation override its hashCode() method and compute it in a different way; and use the hashCode() as an initial part of the equals() method?
I'm thinking doing something simple like scanning the input string and resetting the hash computation counter ever time a ';' is seen. IOW, compute a unique hashcode for each name=value pair and simply XOR them together to get the final hashcode for the ObjectName. This way, a hash comparison can be done without sorting anything. It will at least reduce time when the two objects are not equal. The scanning can be done lazily: only when the equals() or hashCode() methods are called. Disadvantages: * Breaks spec since only the constuctor is supposed to check syntax. This can be fixed by doing the hashcode computation in the constructor. * Still O(n) where n is the length of the initial string. * Can't use this to search for a specific name=value pair. Advantages: * Should be faster than parsing the input into a hash table and then sorting in order to do a comparison. However, the sort comparison should still be done once a hashCode() match is found, unfortunately! * Reduces memory requirements by delaying the creation of a hashtable until it is actually required. _______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development
