KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > refactoring > nls > OrderedMap


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.ui.refactoring.nls;
12
13 import java.util.HashMap JavaDoc;
14 import java.util.Stack JavaDoc;
15
16 public class OrderedMap {
17     
18     private Stack JavaDoc fStack= new Stack JavaDoc();
19     private HashMap JavaDoc fMap= new HashMap JavaDoc();
20     
21     public void push(Object JavaDoc key, Object JavaDoc value) {
22         remove(key);
23         fMap.put(key, value);
24         fStack.push(value);
25     }
26     
27     public Object JavaDoc peek() {
28         if (fStack.isEmpty())
29             return null;
30         return fStack.peek();
31     }
32
33     public void remove(Object JavaDoc key) {
34         Object JavaDoc value= fMap.remove(key);
35         if (value != null)
36             fStack.remove(value);
37     }
38 }
39
Popular Tags