May. 13th, 2013

billroper: (Default)
I spent today immersed in Java generics, trying to figure out how to write an abstract base class using generics that would do everything that I wanted it to do. I've coded something up and sent it to one of the fellows in the shop who is a good bit further along with Java coding than I am (since I am at less than a week, that wouldn't be saying a lot, but apparently he's quite good) and we'll see what he has to say about my questions on the subject.

The thing that's causing me the problem is that I'm building a tree of items (in arbitrary order, so it doesn't look like there's anything in the Collection classes that quite does what I need) where each node in the tree has a unique key. Normally, that key is a String and needs to be searched for in a case-insensitive fashion. But in one of the cases where I want to use this generic tree class, the key is going to be a complex object, because when I'm storing time periods, you can't really compare any sort of reasonable human-readable String using a normal String comparison and get the right answer.

I'm trying to code a Find function and pass it my arbitrary generic Key and I'm having a real problem getting it to work. Maybe what I should be doing is actually storing the TreeItems in a Tree and putting a HashMap into the Tree to solve the Find problem. Except right now, I'm storing just one reference to the HashMap in the root object for the Tree.

Of course, if the generic Tree class extends the generic TreeItem class, I could probably get that trick to work... :)

Profile

billroper: (Default)
billroper

May 2025

S M T W T F S
     1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25262728293031

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated May. 26th, 2025 02:27 am
Powered by Dreamwidth Studios
OSZAR »