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

  • One of Those Days

    Overall, it might have been better to stay in bed today, but that wasn't really an option. I am still slogging through a problem at work. I'm going…

  • Comcast At Work

    So we went to watch some TV that we'd recorded on our Comcast X1 DVR and discovered that -- overnight! -- we had gone from less than 50% full to over…

  • Tired

    I hit the wall late this afternoon. Sleep will follow soon now, but I needed to finish going through the APBA cards for next season. In other news,…

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded