OrderedHashMap.java
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
00003  * All rights reserved. This program is made available under the terms of the
00004  * Eclipse Public License v1.0 which accompanies this distribution, and is
00005  * available at http://www.eclipse.org/legal/epl-v10.html
00006  * Contributors:
00007  * General Robotix Inc.
00008  * National Institute of Advanced Industrial Science and Technology (AIST) 
00009  */
00010 package com.generalrobotix.ui.util;
00011 import java.util.*;
00012 
00013 @SuppressWarnings({ "unchecked", "serial" })
00014 public class OrderedHashMap extends HashMap {
00015     private List<Object> keyList_;
00016     private List<Object> valList_;
00017     
00018     public OrderedHashMap() {
00019         keyList_ = new ArrayList<Object>();
00020         valList_ = new ArrayList<Object>();
00021     }
00022 
00023     public Object put(Object key,Object obj) {
00024         if (!containsKey(key)) {
00025             keyList_.add(key);
00026             valList_.add(obj);
00027         }
00028         return super.put(key, obj);
00029     }
00030 
00031     public Iterator keys() {
00032         return keyList_.iterator();
00033     }
00034 
00035     public Collection values() {
00036         return valList_;
00037     }
00038 
00039     public Object[] toArray() {
00040         return keyList_.toArray();
00041     }
00042 
00043     public Object[] toArray(Object[] array) {
00044         return keyList_.toArray(array);
00045     }
00046     
00047     public Object remove(Object key) {
00048         keyList_.remove(key);
00049         Object val = super.remove(key);
00050         valList_.remove(val);
00051         return val;
00052     }
00053 
00054     public void clear(){
00055         keyList_.clear();
00056         valList_.clear();
00057         super.clear();
00058     }
00059 }


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Apr 11 2019 03:30:18