Today will be a short post, as I have been quite busy these past couple of days and need some sleep.
Phew! What an assignment this has turned out to be. I've been implementing a hashmap and both learned some interesting things, ran into some issues, and managed partial success.
Partial? Yes, unfortunately, I've managed hash functors for all but one of the specified key values. For some odd reason, the user-defined object classes give compiler errors when I try to make hash functors out of them. Pointers, integers, characters, and strings give no issue, but dare I use a Foo? The compiler sure doesn't think so.
I've also learned that due to allocation costs, it's actually quite permissible to store an iterator inside an iterator's implementation as a data member. Who knew? Especially since it's an iterator to a linked list.
This also leads to some odd implications that I don't get in the other containers but I do in this one. For iteration, the values are unordered and not necessarily next to each other, so I have to quickly look through each and every bucket and iterate through each list to manage it. Sounds like a bit of extra busywork, but it's the only way if the data's not even contiguous, let alone ordered. Luckily enough the hashing's lightning fast by comparison.
What's next? 1200 more lines of test code...
No comments:
Post a Comment