OrderedHashMap.java
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
3  * All rights reserved. This program is made available under the terms of the
4  * Eclipse Public License v1.0 which accompanies this distribution, and is
5  * available at http://www.eclipse.org/legal/epl-v10.html
6  * Contributors:
7  * General Robotix Inc.
8  * National Institute of Advanced Industrial Science and Technology (AIST)
9  */
10 package com.generalrobotix.ui.util;
11 import java.util.*;
12 
13 @SuppressWarnings({ "unchecked", "serial" })
14 public class OrderedHashMap extends HashMap {
15  private List<Object> keyList_;
16  private List<Object> valList_;
17 
18  public OrderedHashMap() {
19  keyList_ = new ArrayList<Object>();
20  valList_ = new ArrayList<Object>();
21  }
22 
23  public Object put(Object key,Object obj) {
24  if (!containsKey(key)) {
25  keyList_.add(key);
26  valList_.add(obj);
27  }
28  return super.put(key, obj);
29  }
30 
31  public Iterator keys() {
32  return keyList_.iterator();
33  }
34 
35  public Collection values() {
36  return valList_;
37  }
38 
39  public Object[] toArray() {
40  return keyList_.toArray();
41  }
42 
43  public Object[] toArray(Object[] array) {
44  return keyList_.toArray(array);
45  }
46 
47  public Object remove(Object key) {
48  keyList_.remove(key);
49  Object val = super.remove(key);
50  valList_.remove(val);
51  return val;
52  }
53 
54  public void clear(){
55  keyList_.clear();
56  valList_.clear();
57  super.clear();
58  }
59 }
int val
Definition: jpeglib.h:956
Object put(Object key, Object obj)


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Sep 8 2022 02:24:04