Originally Posted by
javapenguin
Constant time? I thought it was more like logarithmic time. If you used hashing or an AVL tree, then you'd have about logarithmic time. It would probably get a bit closer to linear with hashing, though even with the best hash functions, it's not quite constant time. At least that's what I heard.
Anyway, I thought my approach would work, however inefficient it was.
If implemented correctly and with minimum number of collisions, SOME of a Map's methods are constant (or approximately constant) time. Regardless of 'what you heard', why not prove it to yourself? A Map is far from a tree, and it is far from a linked list.
I am trying to point in the correct direction...if you want to piece together a hacked linked list that ostensibly has key value pairs, please be advised it is not a true hash lookup Map or table (and I would even hesitate to call it a Map). If you want to implement a Map/HashTable correctly, then I recommend reading about what it entails.
Wikipedia has a good overview. But, as history has proven, I don't have much confidence you will listen to my advice (which makes me question why I am giving it in the first place)