LinkedHashMap equivalent for JDK 1.3

Im looking for alternative implementation for LinkedHashMap so that my code will work with JDK 1.3. (LinkedHashMap was introduced in 1.4). do u guys know if there are already made code for this (before i try to roll my own). Does the Trove Collection classes have the equivalent? Thanks!
LVL 3
iboAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
TimYatesConnect With a Mentor Commented:
You can download the Jakarta Commons Collections, and they have a similar class "LinkedMap" which will work with 1.3

http://jakarta.apache.org/commons/collections/
0
 
zzynxSoftware engineerCommented:
Can't you just copy/paste the code of LinkedHashMap?
0
 
iboAuthor Commented:
ive tried that. but it uses protected classes/attributes of HashMap, so i copy-pasted HashMap, then again HashMap requires another protected code from another class, which means i have to copy another class again. I think that would be my last resort if i didnt find any other alternative solution.
0
 
petmagdyCommented:
ok Use Vector, and for your object to be collected into this vector make sure u have implemented:

 public boolan equals(Object obj)

to be used in:

Vector.contains()
Vector.indexOf()
0
 
objectsCommented:
Or you could maintain both a list and a map, something like:

public class ListMap
{
   List list = new ArrayList();
   Map map =  new HasMap();

   void add(Object key, Object o)
   {
      map.put(key, o);
      list.add(key);
   }

   Object get(Object key)
   {
      return map.get(key);
   }

   Iterator iterator()
   {
     return list.iterator();
   }

   ..
}
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.