[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

LinkedHashMap equivalent for JDK 1.3

Posted on 2004-11-02
5
Medium Priority
?
879 Views
Last Modified: 2008-02-01
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
Comment
Question by:ibo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 37

Expert Comment

by:zzynx
ID: 12472226
Can't you just copy/paste the code of LinkedHashMap?
0
 
LVL 3

Author Comment

by:ibo
ID: 12472245
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
 
LVL 13

Expert Comment

by:petmagdy
ID: 12472257
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
 
LVL 35

Accepted Solution

by:
TimYates earned 200 total points
ID: 12472310
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
 
LVL 92

Expert Comment

by:objects
ID: 12478768
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question