Bill Roper (billroper) wrote,
Bill Roper

Generically Yours

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... :)
Tags: computers, java, musings, tech, work

  • Tick, Tick, Tick

    OVFF is coming up quickly. I am gradually trying to finish up all the things that need to be finished up before it arrives on my doorstep -- wait!…

  • Running Behind

    I am running a bit behind on things, but I have hope of catching up. I have one more box of Wail Songs masters that need to be packed up to go to…

  • Did I Mention?

    I now have seven boxes of Quest CDs in my living room. Assuming that I'm at OVFF, they'll be there too. :) (*Some* of them. I am not bringing *all*…

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded