Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 901
  • Last Modified:

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!
0
ibo
Asked:
ibo
1 Solution
 
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
 
TimYatesCommented:
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
 
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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now