`
talentkep
  • 浏览: 98170 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

order map

阅读更多
/*
 * $Id: OrderedMap.java,v 1.1 2009/04/28 06:38:23 E000315 Exp $
 *
 *  Copyright (c) 2001, 2002 The Open For Business Project - www.ofbiz.org
 *
 *  Permission is hereby granted, free of charge, to any person obtaining a
 *  copy of this software and associated documentation files (the "Software"),
 *  to deal in the Software without restriction, including without limitation
 *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
 *  and/or sell copies of the Software, and to permit persons to whom the
 *  Software is furnished to do so, subject to the following conditions:
 *
 *  The above copyright notice and this permission notice shall be included
 *  in all copies or substantial portions of the Software.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 *  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 *  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
 *  OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
 *  THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
package com.peter.apps.util;

import java.util.*;

/**
 * OrderedMap - HashMap backed by a linked list.
 *
 * @author     <a href="mailto:jaz@jflow.net">Andy Zeneski</a>
 * @version    $Revision: 1.1 $
 * @since      2.0
 */
public class OrderedMap extends HashMap {

    private List orderedKeys = new LinkedList();

    /**
     * @see java.util.Map#keySet()
     */   
    public Set keySet() {
        return new OrderedSet(orderedKeys);
    }
 
    /**
     * @see java.util.Map#put(java.lang.Object, java.lang.Object)
     */
    public Object put(Object key, Object value) {
        if (!orderedKeys.contains(key))
            orderedKeys.add(key);
        return super.put(key, value);
    }

    /**
     * @see java.util.Map#clear()
     */   
    public void clear() {
        super.clear();
        orderedKeys.clear();
    }
   
    /**
     * @see java.util.Map#remove(java.lang.Object)
     */
    public Object remove(Object key) {
        if (orderedKeys.contains(key))
            orderedKeys.remove(key);
        return super.remove(key);
    }
}

 

分享到:
评论

相关推荐

    Etudes.for.ClojureScript.B0184

    Lists, vectors, and higher-order map, filter, and reduce functions Data mapping with ClojureScript Using different ClojureScript libraries to program with React Adding, subtracting, multiplying, and ...

    C++中的哈希容器unordered_map使用示例

    很久以来,STL中都只提供&lt;map&gt;作为存放对应关系的容器,内部通常用红黑树实现,据说原因是二叉平衡树(如红黑树)的各种操作,插入、删除、查找等,都是稳定的时间复杂度,即O(log n);但是对于hash表来说,由于无法...

    c++中hash_table以及std::map应用案例

    代码重点是hash_table,附加std::map与其做对比,实现的是一条sql语句:select c_nationkey, c_mktsegment, count(*), max(c_acctbal) from aaa_customer_1g group by c_nationkey, c_mktsegment order by c_...

    Hidden Markov Map Matching Through Noise and Sparseness.pdf

    additional measurement noise in order to assess how well our algorithm could deal with the inaccuracies of other location measurement systems, such as those based on WiFi and cell tower ...

    FAB-MAP 2.0算法对应论文

    1,000km experiment is more than an order of magnitude larger than any previously reported result. The scalability of the system is achieved by defining a sparse approximation to the FAB-MAP model ...

    MMATrans.rar_Grid map_The First_z map_z-map

    These are the rows of Z values of the grid, organized in row order. Each row has a constant Y coordinate. Grid row 1 corresponds to ylo and the last grid row corresponds to yhi. Within each row, the ...

    orderedmap:在 go 中使用的受保护和有序的地图

    有序映射提供以特定顺序存储其项目的映射,该顺序可以以受保护和并发的方式使用。 映射键必须是字符串,但数据可以是任何东西。用法您首先需要制作一张新地图并添加一些数据。 使用 New() 函数创建一个新映射,然后...

    newmap:spm 模块 newmap

    order 1 newmap module 安装 $ spm install newmap --save 使用 require('newmap'); //地图类实例化 var map = new NMap("map", { zoom: 1, center: new NXY(116, 39) }); //图层参数设置 var lyrOptionswmts =...

    Solving constrained combinatorial optimisation problems via MAP inference without high-order penalties

    Solving constrained combinatorial optimisation problems via MAP inference without high-order penalties

    27-Object-List-Map-Array 转成json数据

    在做web开发的时候总会用到jquery 的ajax 技术,然而通过ajax 技术从服务端获取的数据大多是json 格式的数据,所以将不同类型的数据转成json 格式是件很常见的技术,总结一下两种方法!

    使用pyton对OpenStreetMap地图数据进行清洗

    ORDER BY num DESC LIMIT 10; Rub21_nycbuildings|88077 robgeb|42555 lxbarth_nycbuildings|33760 ALE!|6709 Korzun|6100 celosia_nycbuildings|2511 tre1994|2105 zingbot_nycbuildings|1794 lxbarth|1396 ...

    自定义经纬度索引(非RTree、Morton Code[z order curve]、Geohash的方式)

    自定义经纬度索引(非RTree、Morton Code[z order curve]、Geohash的方式) HarvenSin 公式计算经纬度距离,给定2个经纬度坐标,计算距离。给定一个经纬度和半径距离,查找范围内的所有点。

    higher-order:一个用高阶函数装饰 ecmascript6 可迭代对象的库,例如 Array.prototype.map、filter 等

    目标为提供方法,例如map 、 reduce和filter 。 另一个目标是为受 C# 的 IEnumerable 接口之类的东西启发的可迭代对象提供其他方法,以便可以对大型或无限数据源执行常见的过滤、收集和映射操作。用法import higher ...

    unordered_map和unordered_set的模拟实现

    unordered_map和unordered_set的模拟实现 (一)哈希表的特性及概念 定义: 哈希表(Hash table,也叫散列表),是根据关键字值(key,value)直接进行访问的数据结构。也就是说,它通过把关键字映射到表中一个位置来...

    针对JPA的活动记录模式ActiveJPA.zip

    Map, Object&gt; attributes = new HashMap, Object&gt;(); attributes.put("billingAmount", 1000.0); order.updateAttributes(attributes); // Find order item by id within an order order....

    03_ListAndSet_java_order64n_源码

    使用java语言实现数据链表与哈希map的实现,加深理解

    LimitOrderBook:RGM 顾问订单簿编程问题

    每个OrderBook对象都使用两个主要数据结构, price_map和order_map 。 price_map是一个 Python 字典(散列图),它将价格映射到书那一侧该价格的总大小。 order_map是一个 Python 字典(哈希图),它将订单 ID映射...

    基于springcloud实现的网约车项目.zip

    地图 service-map Spring Cloud 组件 模块 项目名 注册中心 cloud-eureka 配置中心 cloud-config-server 网关 cloud-zuul 熔断监控 cloud-hystrix-dashboard 健康检查 cloud-admin 链路追踪 cloud-zipkin-ui 基础...

    hadoop_3hadoop_3

    FP把这样的函数称为”higher order function”(”High order function”被成为Function Programming的利器之一哦),也就是说,这些函数是编写来被与其它函数相结合(或者说被其它函数调用的)。如果说硬要比的化,...

    hadoop_2hadoop_2

    FP把这样的函数称为”higher order function”(”High order function”被成为Function Programming的利器之一哦),也就是说,这些函数是编写来被与其它函数相结合(或者说被其它函数调用的)。如果说硬要比的化,...

Global site tag (gtag.js) - Google Analytics