这个类是apache第三方jar包吗?struts是不是用到了?这个类主要用来做什么的呢?谁能说下谢谢了

解决方案 »

  1.   

    是commons-collections包
    struts好像是用到了。
    从该类名称看是快速的HashMap,用其查询元素要比HashMap快很多
      

  2.   


    从类名来看,该类应该类似HashMap,但是其查询元素即get(key)要比HashMap快很多
      

  3.   

    这是FastHashMap的英文解释
    A customized implementation of java.util.HashMap designed to operate in a multithreaded environment where the large majority of method calls are read-only, instead of structural changes. When operating in "fast" mode, read calls are non-synchronized and write calls perform the following steps:1.Clone the existing collection
    2.Perform the modification on the clone
    3.Replace the existing collection with the (modified) cloneWhen first created, objects of this class default to "slow" mode, where all accesses of any type are synchronized but no cloning takes place. This is appropriate for initially populating the collection, followed by a switch to "fast" mode (by calling setFast(true)) after initialization is complete.大哥,程序员做事情不是靠猜和想当然,真汗了。
      

  4.   

    http://commons.apache.org/collections/apidocs/index.html可以看出FastHashMap继承了HashMap
      

  5.   

    5楼的同志,你那句其查询元素即get(key)要比HashMap快很多的理论依据在哪里?就凭这个类多了个Fast?
      

  6.   

    官方英文的解释很明白,FastHashMap是一个具备线程安全特征的HashMap,通过调用setFast方法来设定当前的Map是否是线程安全的,默认是线程安全的。
    但是我通篇没看到get(key)要比HashMap快很多的说法。
      

  7.   


    好好看看API说明,如果还不相信,可以写个比较程序试试
      

  8.   

    这东西还用写测试看API?源代码我都不知道看了多少遍了
    FastHashMap就是对HashMap的线程安全的包装。
    import java.util.Collection;
    import java.util.ConcurrentModificationException;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.Map;
    import java.util.Set;
    这是它import的类    protected HashMap map = null;
        protected boolean fast = false;
    这是它的成员变量    public Object get(Object key) {
            if (fast) {
                return (map.get(key));
            } else {
                synchronized (map) {
                    return (map.get(key));
                }
            }
        }
    这个是它的get方法快在哪里?请楼上的指教,我没看出来。