亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? referencemap.java

?? 這是一個有關common beanutils 的源碼
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.commons.collections;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import java.util.AbstractCollection;
import java.util.AbstractMap;
import java.util.AbstractSet;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;

import org.apache.commons.collections.keyvalue.DefaultMapEntry;

/**
 *  Hash-based {@link Map} implementation that allows
 *  mappings to be removed by the garbage collector.<p>
 *
 *  When you construct a <code>ReferenceMap</code>, you can 
 *  specify what kind of references are used to store the
 *  map's keys and values.  If non-hard references are 
 *  used, then the garbage collector can remove mappings
 *  if a key or value becomes unreachable, or if the 
 *  JVM's memory is running low.  For information on how
 *  the different reference types behave, see
 *  {@link Reference}.<p>
 *
 *  Different types of references can be specified for keys
 *  and values.  The keys can be configured to be weak but
 *  the values hard, in which case this class will behave
 *  like a <a href="http://java.sun.com/j2se/1.4/docs/api/java/util/WeakHashMap.html">
 *  <code>WeakHashMap</code></a>.  However, you
 *  can also specify hard keys and weak values, or any other
 *  combination.  The default constructor uses hard keys
 *  and soft values, providing a memory-sensitive cache.<p>
 *
 *  The algorithms used are basically the same as those
 *  in {@link java.util.HashMap}.  In particular, you 
 *  can specify a load factor and capacity to suit your
 *  needs.  All optional {@link Map} operations are 
 *  supported.<p>
 *
 *  However, this {@link Map} implementation does <I>not</I>
 *  allow null elements.  Attempting to add a null key or
 *  or a null value to the map will raise a 
 *  <code>NullPointerException</code>.<p>
 *
 *  As usual, this implementation is not synchronized.  You
 *  can use {@link java.util.Collections#synchronizedMap} to 
 *  provide synchronized access to a <code>ReferenceMap</code>.
 *
 * @see java.lang.ref.Reference
 * 
 * @deprecated Moved to map subpackage. Due to be removed in v4.0.
 * @since Commons Collections 2.1
 * @version $Revision: 438363 $ $Date: 2006-08-30 05:48:00 +0100 (Wed, 30 Aug 2006) $
 * 
 * @author Paul Jack
 */
public class ReferenceMap extends AbstractMap {

    /**
     *  For serialization.
     */
    final private static long serialVersionUID = -3370601314380922368L;


    /**
     *  Constant indicating that hard references should be used.
     */
    final public static int HARD = 0;


    /**
     *  Constant indicating that soft references should be used.
     */
    final public static int SOFT = 1;


    /**
     *  Constant indicating that weak references should be used.
     */
    final public static int WEAK = 2;


    // --- serialized instance variables:


    /**
     *  The reference type for keys.  Must be HARD, SOFT, WEAK.
     *  Note: I originally marked this field as final, but then this class
     *   didn't compile under JDK1.2.2.
     *  @serial
     */
    private int keyType;


    /**
     *  The reference type for values.  Must be HARD, SOFT, WEAK.
     *  Note: I originally marked this field as final, but then this class
     *   didn't compile under JDK1.2.2.
     *  @serial
     */
    private int valueType;


    /**
     *  The threshold variable is calculated by multiplying
     *  table.length and loadFactor.  
     *  Note: I originally marked this field as final, but then this class
     *   didn't compile under JDK1.2.2.
     *  @serial
     */
    private float loadFactor;
    
    /**
     * Should the value be automatically purged when the associated key has been collected?
     */
    private boolean purgeValues = false;


    // -- Non-serialized instance variables

    /**
     *  ReferenceQueue used to eliminate stale mappings.
     *  See purge.
     */
    private transient ReferenceQueue queue = new ReferenceQueue();


    /**
     *  The hash table.  Its length is always a power of two.  
     */
    private transient Entry[] table;


    /**
     *  Number of mappings in this map.
     */
    private transient int size;


    /**
     *  When size reaches threshold, the map is resized.  
     *  See resize().
     */
    private transient int threshold;


    /**
     *  Number of times this map has been modified.
     */
    private transient volatile int modCount;


    /**
     *  Cached key set.  May be null if key set is never accessed.
     */
    private transient Set keySet;


    /**
     *  Cached entry set.  May be null if entry set is never accessed.
     */
    private transient Set entrySet;


    /**
     *  Cached values.  May be null if values() is never accessed.
     */
    private transient Collection values;


    /**
     *  Constructs a new <code>ReferenceMap</code> that will
     *  use hard references to keys and soft references to values.
     */
    public ReferenceMap() {
        this(HARD, SOFT);
    }

    /**
     *  Constructs a new <code>ReferenceMap</code> that will
     *  use the specified types of references.
     *
     *  @param keyType  the type of reference to use for keys;
     *   must be {@link #HARD}, {@link #SOFT}, {@link #WEAK}
     *  @param valueType  the type of reference to use for values;
     *   must be {@link #HARD}, {@link #SOFT}, {@link #WEAK}
     *  @param purgeValues should the value be automatically purged when the 
     *   key is garbage collected 
     */
    public ReferenceMap(int keyType, int valueType, boolean purgeValues) {
        this(keyType, valueType);
        this.purgeValues = purgeValues;
    }

    /**
     *  Constructs a new <code>ReferenceMap</code> that will
     *  use the specified types of references.
     *
     *  @param keyType  the type of reference to use for keys;
     *   must be {@link #HARD}, {@link #SOFT}, {@link #WEAK}
     *  @param valueType  the type of reference to use for values;
     *   must be {@link #HARD}, {@link #SOFT}, {@link #WEAK}
     */
    public ReferenceMap(int keyType, int valueType) {
        this(keyType, valueType, 16, 0.75f);
    }

    /**
     *  Constructs a new <code>ReferenceMap</code> with the
     *  specified reference types, load factor and initial
     *  capacity.
     *
     *  @param keyType  the type of reference to use for keys;
     *   must be {@link #HARD}, {@link #SOFT}, {@link #WEAK}
     *  @param valueType  the type of reference to use for values;
     *   must be {@link #HARD}, {@link #SOFT}, {@link #WEAK}
     *  @param capacity  the initial capacity for the map
     *  @param loadFactor  the load factor for the map
     *  @param purgeValues should the value be automatically purged when the 
     *   key is garbage collected 
     */
    public ReferenceMap(
                        int keyType, 
                        int valueType, 
                        int capacity, 
                        float loadFactor, 
                        boolean purgeValues) {
        this(keyType, valueType, capacity, loadFactor);
        this.purgeValues = purgeValues;
    }

    /**
     *  Constructs a new <code>ReferenceMap</code> with the
     *  specified reference types, load factor and initial
     *  capacity.
     *
     *  @param keyType  the type of reference to use for keys;
     *   must be {@link #HARD}, {@link #SOFT}, {@link #WEAK}
     *  @param valueType  the type of reference to use for values;
     *   must be {@link #HARD}, {@link #SOFT}, {@link #WEAK}
     *  @param capacity  the initial capacity for the map
     *  @param loadFactor  the load factor for the map
     */
    public ReferenceMap(int keyType, int valueType, int capacity, float loadFactor) {
        super();

        verify("keyType", keyType);
        verify("valueType", valueType);

        if (capacity <= 0) {
            throw new IllegalArgumentException("capacity must be positive");
        }
        if ((loadFactor <= 0.0f) || (loadFactor >= 1.0f)) {
            throw new IllegalArgumentException("Load factor must be greater than 0 and less than 1.");
        }

        this.keyType = keyType;
        this.valueType = valueType;

        int v = 1;
        while (v < capacity) v *= 2;

        this.table = new Entry[v];
        this.loadFactor = loadFactor;
        this.threshold = (int)(v * loadFactor);
    }


    // used by constructor
    private static void verify(String name, int type) {
        if ((type < HARD) || (type > WEAK)) {
            throw new IllegalArgumentException(name + 
               " must be HARD, SOFT, WEAK.");
        }
    }


    /**
     *  Writes this object to the given output stream.
     *
     *  @param out  the output stream to write to
     *  @throws IOException  if the stream raises it
     */
    private void writeObject(ObjectOutputStream out) throws IOException {
        out.defaultWriteObject();
        out.writeInt(table.length);

        // Have to use null-terminated list because size might shrink
        // during iteration

        for (Iterator iter = entrySet().iterator(); iter.hasNext();) {
            Map.Entry entry = (Map.Entry)iter.next();
            out.writeObject(entry.getKey());
            out.writeObject(entry.getValue());
        }
        out.writeObject(null);
    }


    /**
     *  Reads the contents of this object from the given input stream.
     *
     *  @param inp  the input stream to read from
     *  @throws IOException  if the stream raises it
     *  @throws ClassNotFoundException  if the stream raises it
     */
    private void readObject(ObjectInputStream inp) throws IOException, ClassNotFoundException {
        inp.defaultReadObject();
        table = new Entry[inp.readInt()];
        threshold = (int)(table.length * loadFactor);
        queue = new ReferenceQueue();
        Object key = inp.readObject();
        while (key != null) {
            Object value = inp.readObject();
            put(key, value);
            key = inp.readObject();
        }
    }


    /**
     *  Constructs a reference of the given type to the given 
     *  referent.  The reference is registered with the queue
     *  for later purging.
     *
     *  @param type  HARD, SOFT or WEAK
     *  @param referent  the object to refer to
     *  @param hash  the hash code of the <I>key</I> of the mapping;
     *    this number might be different from referent.hashCode() if
     *    the referent represents a value and not a key
     */
    private Object toReference(int type, Object referent, int hash) {
        switch (type) {
            case HARD: return referent;
            case SOFT: return new SoftRef(hash, referent, queue);
            case WEAK: return new WeakRef(hash, referent, queue);
            default: throw new Error();
        }
    }


    /**
     *  Returns the entry associated with the given key.
     *
     *  @param key  the key of the entry to look up
     *  @return  the entry associated with that key, or null
     *    if the key is not in this map
     */
    private Entry getEntry(Object key) {
        if (key == null) return null;
        int hash = key.hashCode();
        int index = indexFor(hash);
        for (Entry entry = table[index]; entry != null; entry = entry.next) {
            if ((entry.hash == hash) && key.equals(entry.getKey())) {
                return entry;
            }
        }
        return null;
    }


    /**
     *  Converts the given hash code into an index into the
     *  hash table.
     */
    private int indexFor(int hash) {
        // mix the bits to avoid bucket collisions...
        hash += ~(hash << 15);
        hash ^= (hash >>> 10);
        hash += (hash << 3);
        hash ^= (hash >>> 6);
        hash += ~(hash << 11);
        hash ^= (hash >>> 16);
        return hash & (table.length - 1);
    }



    /**
     *  Resizes this hash table by doubling its capacity.
     *  This is an expensive operation, as entries must
     *  be copied from the old smaller table to the new 
     *  bigger table.
     */
    private void resize() {
        Entry[] old = table;
        table = new Entry[old.length * 2];

        for (int i = 0; i < old.length; i++) {
            Entry next = old[i];
            while (next != null) {
                Entry entry = next;
                next = next.next;
                int index = indexFor(entry.hash);
                entry.next = table[index];
                table[index] = entry;
            }
            old[i] = null;
        }
        threshold = (int)(table.length * loadFactor);
    }



    /**
     * Purges stale mappings from this map.
     * <p>
     * Ordinarily, stale mappings are only removed during
     * a write operation, although this method is called for both
     * read and write operations to maintain a consistent state.
     * <p>
     * Note that this method is not synchronized!  Special
     * care must be taken if, for instance, you want stale
     * mappings to be removed on a periodic basis by some
     * background thread.
     */
    private void purge() {
        Reference ref = queue.poll();
        while (ref != null) {
            purge(ref);
            ref = queue.poll();
        }
    }


    private void purge(Reference ref) {
        // The hashCode of the reference is the hashCode of the
        // mapping key, even if the reference refers to the 
        // mapping value...
        int hash = ref.hashCode();
        int index = indexFor(hash);
        Entry previous = null;
        Entry entry = table[index];
        while (entry != null) {
            if (entry.purge(ref)) {
                if (previous == null) table[index] = entry.next;
                else previous.next = entry.next;
                this.size--;
                return;
            }
            previous = entry;
            entry = entry.next;
        }

    }


    /**
     *  Returns the size of this map.
     *
     *  @return  the size of this map
     */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区三区精品在线观看| 久久亚洲综合色一区二区三区| 亚洲女爱视频在线| 在线观看日韩国产| 日韩—二三区免费观看av| 精品成a人在线观看| 国产一区二区三区在线观看免费视频| 日韩欧美色综合| 国产91富婆露脸刺激对白| 亚洲欧美另类久久久精品2019| 欧美性色欧美a在线播放| 日韩和欧美一区二区| 久久在线观看免费| 99热精品国产| 日韩二区在线观看| 国产人成亚洲第一网站在线播放| 91色视频在线| 美女被吸乳得到大胸91| 国产精品国产精品国产专区不蜜| 欧美日韩在线一区二区| 国内久久精品视频| 亚洲精品免费一二三区| 日韩精品一区二区三区视频 | 一区二区三区四区五区视频在线观看| 欧美午夜精品久久久久久孕妇| 免费成人美女在线观看| 亚洲欧美国产毛片在线| 日韩午夜精品电影| 99麻豆久久久国产精品免费优播| 日韩一区精品字幕| 中文字幕一区二区三区在线观看| 欧美精品久久久久久久多人混战 | 成人福利视频网站| 日韩成人精品在线观看| 国产精品第13页| 91精品黄色片免费大全| 不卡的电影网站| 韩国欧美国产一区| 亚洲午夜一二三区视频| 日本一区二区三区免费乱视频| 欧美人狂配大交3d怪物一区| 成人av网站免费| 毛片基地黄久久久久久天堂| 亚洲午夜精品网| 国产精品国产三级国产三级人妇 | 日韩影院精彩在线| 中文字幕日本不卡| 精品久久久久久最新网址| 欧美中文字幕一二三区视频| 成人看片黄a免费看在线| 99精品国产99久久久久久白柏| 久久综合狠狠综合| 在线看国产日韩| 成人午夜在线免费| 久久99国产精品成人| 午夜精品一区二区三区三上悠亚| 国产精品成人免费| 国产女人18水真多18精品一级做 | 欧美男男青年gay1069videost| 丁香婷婷综合网| 国产呦精品一区二区三区网站| 日韩在线a电影| 天天影视色香欲综合网老头| 亚洲最新视频在线观看| 亚洲日本在线观看| 国产精品第四页| 国产精品久久久久aaaa| 国产日韩欧美麻豆| 久久久亚洲午夜电影| 日韩片之四级片| 欧美一区二区免费| 67194成人在线观看| 欧美三级电影在线看| 欧美中文字幕不卡| 欧美三区在线观看| 欧美日韩亚洲综合| 在线不卡欧美精品一区二区三区| 欧美三级日本三级少妇99| 欧美日韩精品一区二区在线播放| 在线亚洲欧美专区二区| 色哟哟日韩精品| 欧美性videosxxxxx| 欧美日韩不卡在线| 欧美精品九九99久久| 欧美高清dvd| 日韩一区二区免费在线电影| 日韩久久免费av| 精品国产乱码久久久久久老虎| 精品精品国产高清a毛片牛牛 | 18涩涩午夜精品.www| 亚洲丝袜自拍清纯另类| 亚洲人成小说网站色在线| 亚洲精品视频自拍| 性欧美大战久久久久久久久| 免费成人在线网站| 国产久卡久卡久卡久卡视频精品| 国产成人一级电影| 91免费观看国产| 欧美日韩精品欧美日韩精品| 日韩一级片网站| 国产视频一区二区在线| 中文字幕日韩av资源站| 午夜精品一区二区三区电影天堂 | 三级欧美在线一区| 久久精品国产免费看久久精品| 国产精品69久久久久水密桃| 色欧美片视频在线观看在线视频| 欧美亚洲日本国产| 精品国产免费一区二区三区四区 | 成人免费高清视频| 色婷婷久久综合| 欧美一区二区三区视频在线观看 | 91久久精品一区二区| 欧美一区二区三区精品| 国产欧美中文在线| 亚洲国产视频一区| 国产一区二区福利| 91久久精品一区二区| 精品国产免费人成在线观看| 亚洲欧美精品午睡沙发| 日韩影院免费视频| 91丨九色丨尤物| 久久免费电影网| 视频精品一区二区| 93久久精品日日躁夜夜躁欧美| 91精品国产欧美一区二区成人| 国产欧美日产一区| 蜜桃一区二区三区四区| 91国产丝袜在线播放| 2欧美一区二区三区在线观看视频| 中文字幕一区二区在线播放| 欧美aⅴ一区二区三区视频| 99国产欧美另类久久久精品| 欧美电影免费观看高清完整版在线观看 | 国产福利一区二区| 欧美亚洲一区二区在线观看| 国产亲近乱来精品视频| 日韩不卡一区二区| 91丨九色丨蝌蚪丨老版| 日本一区二区三区dvd视频在线| 日韩国产欧美在线视频| 色婷婷亚洲精品| 欧美激情一区三区| 久久99国产精品成人| 在线播放91灌醉迷j高跟美女| 亚洲欧洲成人av每日更新| 国产乱子伦一区二区三区国色天香 | 日韩va欧美va亚洲va久久| 91福利视频在线| 亚洲欧洲三级电影| 国产成人精品亚洲日本在线桃色| 欧美一区二区二区| 午夜激情一区二区| 欧美日韩在线播放三区四区| 亚洲精品国产一区二区精华液| 国产精品91xxx| 久久久久久久久久看片| 久久成人羞羞网站| 欧美一级片免费看| 视频一区中文字幕国产| 欧美日韩在线直播| 亚洲第一成人在线| 欧美丝袜丝交足nylons| 亚洲激情中文1区| 色狠狠av一区二区三区| 亚洲色欲色欲www在线观看| 99久久综合精品| 国产精品无圣光一区二区| 国产成人在线免费观看| 国产精品美女久久久久aⅴ| 国产精品911| 中文字幕一区二区三区四区 | 国产一区二区三区在线观看精品| 精品日韩一区二区| 国内精品久久久久影院一蜜桃| 久久久蜜桃精品| 东方aⅴ免费观看久久av| 欧美高清一级片在线观看| 成人午夜视频在线| 17c精品麻豆一区二区免费| 91在线国内视频| 亚洲电影第三页| 日韩欧美aaaaaa| 福利电影一区二区| 亚洲品质自拍视频| 欧美喷水一区二区| 久久99久久99小草精品免视看| 精品日本一线二线三线不卡| 国产成人午夜精品影院观看视频| 亚洲国产精品精华液ab| 色屁屁一区二区| 日本视频一区二区| 国产网站一区二区| 91天堂素人约啪| 三级久久三级久久久| 久久久亚洲精品石原莉奈| 91免费精品国自产拍在线不卡| 性感美女极品91精品| 精品国产乱码久久久久久久| 95精品视频在线|