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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? treemap.java

?? 純java操作系統(tǒng)jnode,安裝簡單和操作簡單的個人使用的Java操作系統(tǒng)
?? JAVA
?? 第 1 頁 / 共 4 頁
字號:
/* TreeMap.java -- a class providing a basic Red-Black Tree data structure,
   mapping Object --> Object
   Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.

This file is part of GNU Classpath.

GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING.  If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.

Linking this library statically or dynamically with other modules is
making a combined work based on this library.  Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.

As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module.  An independent module is a module which is not derived from
or based on this library.  If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so.  If you do not wish to do so, delete this
exception statement from your version. */

package java.util;

import java.io.Serializable;
import java.io.ObjectOutputStream;
import java.io.ObjectInputStream;
import java.io.IOException;

/**
 * This class provides a red-black tree implementation of the SortedMap
 * interface.  Elements in the Map will be sorted by either a user-provided
 * Comparator object, or by the natural ordering of the keys.
 *
 * The algorithms are adopted from Corman, Leiserson, and Rivest's
 * <i>Introduction to Algorithms.</i>  TreeMap guarantees O(log n)
 * insertion and deletion of elements.  That being said, there is a large
 * enough constant coefficient in front of that "log n" (overhead involved
 * in keeping the tree balanced), that TreeMap may not be the best choice
 * for small collections. If something is already sorted, you may want to
 * just use a LinkedHashMap to maintain the order while providing O(1) access.
 *
 * TreeMap is a part of the JDK1.2 Collections API.  Null keys are allowed
 * only if a Comparator is used which can deal with them; natural ordering
 * cannot cope with null.  Null values are always allowed. Note that the
 * ordering must be <i>consistent with equals</i> to correctly implement
 * the Map interface. If this condition is violated, the map is still
 * well-behaved, but you may have suprising results when comparing it to
 * other maps.<p>
 *
 * This implementation is not synchronized. If you need to share this between
 * multiple threads, do something like:<br>
 * <code>SortedMap m
 *       = Collections.synchronizedSortedMap(new TreeMap(...));</code><p>
 *
 * The iterators are <i>fail-fast</i>, meaning that any structural
 * modification, except for <code>remove()</code> called on the iterator
 * itself, cause the iterator to throw a
 * <code>ConcurrentModificationException</code> rather than exhibit
 * non-deterministic behavior.
 *
 * @author Jon Zeppieri
 * @author Bryce McKinlay
 * @author Eric Blake <ebb9@email.byu.edu>
 * @see Map
 * @see HashMap
 * @see Hashtable
 * @see LinkedHashMap
 * @see Comparable
 * @see Comparator
 * @see Collection
 * @see Collections#synchronizedSortedMap(SortedMap)
 * @since 1.2
 * @status updated to 1.4
 */
public class TreeMap extends AbstractMap implements SortedMap, Cloneable, Serializable {
	
	// Implementation note:
	// A red-black tree is a binary search tree with the additional properties
	// that all paths to a leaf node visit the same number of black nodes,
	// and no red node has red children. To avoid some null-pointer checks,
	// we use the special node nil which is always black, has no relatives,
	// and has key and value of null (but is not equal to a mapping of null).

	/**
	 * Compatible with JDK 1.2.
	 */
	private static final long serialVersionUID = 919286545866124006L;

	/**
	 * Color status of a node. Package visible for use by nested classes.
	 */
	static final int RED = -1, BLACK = 1;

	/**
	 * Sentinal node, used to avoid null checks for corner cases and make the
	 * delete rebalance code simpler. The rebalance code must never assign
	 * the parent, left, or right of nil, but may safely reassign the color
	 * to be black. This object must never be used as a key in a TreeMap, or
	 * it will break bounds checking of a SubMap.
	 */
	static Node hiddenNil;
	static Node getNil() {
		if (hiddenNil == null) {
			Node n = new Node(BLACK);
			// Nil is self-referential, so we must initialize it after creation.
			n.parent = n;
			n.left = n;
			n.right = n;
			hiddenNil = n;
		}
		return hiddenNil;
	}

	/**
	 * The root node of this TreeMap.
	 */
	private transient Node root = getNil();

	/**
	 * The size of this TreeMap. Package visible for use by nested classes.
	 */
	transient int size;

	/**
	 * The cache for {@link #entrySet()}.
	 */
	private transient Set entries;

	/**
	 * Counts the number of modifications this TreeMap has undergone, used
	 * by Iterators to know when to throw ConcurrentModificationExceptions.
	 * Package visible for use by nested classes.
	 */
	transient int modCount;

	/**
	 * This TreeMap's comparator, or null for natural ordering.
	 * Package visible for use by nested classes.
	 * @serial the comparator ordering this tree, or null
	 */
	final Comparator comparator;

	/**
	 * Class to represent an entry in the tree. Holds a single key-value pair,
	 * plus pointers to parent and child nodes.
	 *
	 * @author Eric Blake <ebb9@email.byu.edu>
	 */
	private static final class Node extends AbstractMap.BasicMapEntry {
		// All fields package visible for use by nested classes.
		/** The color of this node. */
		int color;

		/** The left child node. */
		Node left;
		/** The right child node. */
		Node right;
		/** The parent node. */
		Node parent;

		/**
		 * Simple constructor.
		 * @param key the key
		 * @param value the value
		 */
		Node(Object key, Object value, int color) {
			super(key, value);
			this.color = color;
			Node nil = getNil();
			this.left = nil;
			this.right = nil;
			this.parent = nil;
		}
		
		/**
		 * Special constructor for use in getNil() to avoid endless recursion
		 * @param color
		 */
		Node(int color) {
			super(null, null);
			this.color = color;
		}
	}

	/**
	 * Instantiate a new TreeMap with no elements, using the keys' natural
	 * ordering to sort. All entries in the map must have a key which implements
	 * Comparable, and which are <i>mutually comparable</i>, otherwise map
	 * operations may throw a {@link ClassCastException}. Attempts to use
	 * a null key will throw a {@link NullPointerException}.
	 *
	 * @see Comparable
	 */
	public TreeMap() {
		this((Comparator) null);
	}

	/**
	 * Instantiate a new TreeMap with no elements, using the provided comparator
	 * to sort. All entries in the map must have keys which are mutually
	 * comparable by the Comparator, otherwise map operations may throw a
	 * {@link ClassCastException}.
	 *
	 * @param comparator the sort order for the keys of this map, or null
	 *        for the natural order
	 */
	public TreeMap(Comparator c) {
		comparator = c;
	}

	/**
	 * Instantiate a new TreeMap, initializing it with all of the elements in
	 * the provided Map.  The elements will be sorted using the natural
	 * ordering of the keys. This algorithm runs in n*log(n) time. All entries
	 * in the map must have keys which implement Comparable and are mutually
	 * comparable, otherwise map operations may throw a
	 * {@link ClassCastException}.
	 *
	 * @param map a Map, whose entries will be put into this TreeMap
	 * @throws ClassCastException if the keys in the provided Map are not
	 *         comparable
	 * @throws NullPointerException if map is null
	 * @see Comparable
	 */
	public TreeMap(Map map) {
		this((Comparator) null);
		putAll(map);
	}

	/**
	 * Instantiate a new TreeMap, initializing it with all of the elements in
	 * the provided SortedMap.  The elements will be sorted using the same
	 * comparator as in the provided SortedMap. This runs in linear time.
	 *
	 * @param sm a SortedMap, whose entries will be put into this TreeMap
	 * @throws NullPointerException if sm is null
	 */
	public TreeMap(SortedMap sm) {
		this(sm.comparator());
		int pos = sm.size();
		Iterator itr = sm.entrySet().iterator();

		fabricateTree(pos);
		Node node = firstNode();

		while (--pos >= 0) {
			Map.Entry me = (Map.Entry) itr.next();
			node.key = me.getKey();
			node.value = me.getValue();
			node = successor(node);
		}
	}

	/**
	 * Clears the Map so it has no keys. This is O(1).
	 */
	public void clear() {
		if (size > 0) {
			modCount++;
			root = getNil();
			size = 0;
		}
	}

	/**
	 * Returns a shallow clone of this TreeMap. The Map itself is cloned,
	 * but its contents are not.
	 *
	 * @return the clone
	 */
	public Object clone() {
		TreeMap copy = null;
		try {
			copy = (TreeMap) super.clone();
		} catch (CloneNotSupportedException x) {
		}
		copy.entries = null;
		copy.fabricateTree(size);

		Node node = firstNode();
		Node cnode = copy.firstNode();

		while (node != getNil()) {
			cnode.key = node.key;
			cnode.value = node.value;
			node = successor(node);
			cnode = copy.successor(cnode);
		}
		return copy;
	}

	/**
	 * Return the comparator used to sort this map, or null if it is by
	 * natural order.
	 *
	 * @return the map's comparator
	 */
	public Comparator comparator() {
		return comparator;
	}

	/**
	 * Returns true if the map contains a mapping for the given key.
	 *
	 * @param key the key to look for
	 * @return true if the key has a mapping
	 * @throws ClassCastException if key is not comparable to map elements
	 * @throws NullPointerException if key is null and the comparator is not
	 *         tolerant of nulls
	 */
	public boolean containsKey(Object key) {
		return getNode(key) != getNil();
	}

	/**
	 * Returns true if the map contains at least one mapping to the given value.
	 * This requires linear time.
	 *
	 * @param value the value to look for
	 * @return true if the value appears in a mapping
	 */
	public boolean containsValue(Object value) {
		Node node = firstNode();
		while (node != getNil()) {
			if (equals(value, node.value))
				return true;
			node = successor(node);
		}
		return false;
	}

	/**
	 * Returns a "set view" of this TreeMap's entries. The set is backed by
	 * the TreeMap, so changes in one show up in the other.  The set supports
	 * element removal, but not element addition.<p>
	 *
	 * Note that the iterators for all three views, from keySet(), entrySet(),
	 * and values(), traverse the TreeMap in sorted sequence.
	 *
	 * @return a set view of the entries
	 * @see #keySet()
	 * @see #values()
	 * @see Map.Entry
	 */
	public Set entrySet() {
		if (entries == null)
			// Create an AbstractSet with custom implementations of those methods
			// that can be overriden easily and efficiently.
			entries = new AbstractSet() {
			public int size() {
				return size;
			}

			public Iterator iterator() {
				return new TreeIterator(ENTRIES);
			}

			public void clear() {
				TreeMap.this.clear();
			}

			public boolean contains(Object o) {
				if (!(o instanceof Map.Entry))
					return false;
				Map.Entry me = (Map.Entry) o;
				Node n = getNode(me.getKey());
				return n != getNil() && AbstractSet.equals(me.getValue(), n.value);
			}

			public boolean remove(Object o) {
				if (!(o instanceof Map.Entry))
					return false;
				Map.Entry me = (Map.Entry) o;
				Node n = getNode(me.getKey());
				if (n != getNil() && AbstractSet.equals(me.getValue(), n.value)) {
					removeNode(n);
					return true;
				}
				return false;
			}
		};
		return entries;
	}

	/**
	 * Returns the first (lowest) key in the map.
	 *
	 * @return the first key

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91精品国产乱| 美女视频网站黄色亚洲| 国产精品夜夜嗨| 欧美狂野另类xxxxoooo| 亚洲欧美乱综合| 成人福利电影精品一区二区在线观看| 精品久久久影院| 亚洲成a人v欧美综合天堂下载| 粉嫩蜜臀av国产精品网站| 日韩欧美中文字幕公布| 亚洲v日本v欧美v久久精品| 91丨九色丨国产丨porny| 国产精品三级视频| 国产99久久久久久免费看农村| 精品国产免费一区二区三区香蕉| 日韩福利视频导航| 在线不卡的av| 亚洲国产乱码最新视频| 91久久精品日日躁夜夜躁欧美| 国产午夜精品一区二区三区四区| 九色porny丨国产精品| 欧美白人最猛性xxxxx69交| 激情六月婷婷久久| 精品久久久久久久久久久院品网| 麻豆精品久久精品色综合| 欧美变态凌虐bdsm| 国产成人精品亚洲午夜麻豆| 欧美激情综合五月色丁香 | 国产不卡免费视频| 国产精品激情偷乱一区二区∴| 懂色av一区二区三区免费看| 久久综合色8888| 粉嫩aⅴ一区二区三区四区| 中文字幕制服丝袜成人av| 91一区二区在线| 亚洲综合免费观看高清完整版在线 | 日韩精品乱码免费| 久久色.com| 丁香六月综合激情| 亚洲精品一二三四区| 欧美三日本三级三级在线播放| 日韩精品成人一区二区在线| 欧美大胆人体bbbb| 精品一区二区三区欧美| 亚洲国产精品成人综合| 91久久精品日日躁夜夜躁欧美| 午夜影院在线观看欧美| 精品国产亚洲一区二区三区在线观看| 国产激情一区二区三区桃花岛亚洲| 中文成人av在线| 欧美在线视频日韩| 日韩国产在线一| 国产亚洲精品aa午夜观看| 91黄色小视频| 国模娜娜一区二区三区| 亚洲精品伦理在线| 欧美成人a视频| 91在线观看美女| 蜜臀a∨国产成人精品| 一区二区中文字幕在线| 欧美日韩一级视频| 美日韩黄色大片| 中文字幕亚洲一区二区va在线| 欧美精品自拍偷拍| av高清不卡在线| 美女视频免费一区| 一区二区三区四区在线| 久久综合色8888| 欧美日韩成人激情| aaa亚洲精品一二三区| 亚洲精品视频观看| 91精品国产综合久久福利| 成人福利电影精品一区二区在线观看| 五月综合激情日本mⅴ| 欧美国产一区视频在线观看| 欧美夫妻性生活| 一本一道久久a久久精品 | 亚洲素人一区二区| 日韩美女视频在线| 欧美日本国产视频| 91免费版pro下载短视频| 国产一区亚洲一区| 日本成人在线网站| 一区二区欧美视频| 国产精品久久国产精麻豆99网站| 日韩午夜在线影院| 欧美蜜桃一区二区三区| 色诱亚洲精品久久久久久| 国产精品亚洲成人| 久久99精品国产.久久久久| 亚洲成av人片在线| 亚洲欧美区自拍先锋| 国产精品伦理在线| 国产欧美日韩精品在线| 精品成人在线观看| 欧美不卡123| 日韩精品最新网址| 日韩视频在线观看一区二区| 91福利国产精品| 色欧美片视频在线观看| 91日韩精品一区| 99久久婷婷国产综合精品| 国产成人亚洲综合a∨猫咪| 国产自产v一区二区三区c| 韩国欧美国产1区| 国产一区二区导航在线播放| 久久精品理论片| 午夜不卡av在线| 日韩福利电影在线观看| 婷婷亚洲久悠悠色悠在线播放| 亚洲大片精品永久免费| 亚洲第一久久影院| 日韩av电影一区| 美国欧美日韩国产在线播放| 轻轻草成人在线| 精品亚洲成av人在线观看| 久久精品国产999大香线蕉| 亚洲成a天堂v人片| 日本午夜精品视频在线观看| 蜜桃精品视频在线| 国产一区二区三区四区五区美女 | 精品一区二区三区蜜桃| 亚洲综合在线五月| 午夜伦欧美伦电影理论片| 蜜臂av日日欢夜夜爽一区| 美国欧美日韩国产在线播放| 国产一区亚洲一区| zzijzzij亚洲日本少妇熟睡| 91天堂素人约啪| 99re亚洲国产精品| 91免费视频大全| 欧美特级限制片免费在线观看| 欧美肥大bbwbbw高潮| 精品国产三级a在线观看| 国产精品系列在线| 亚洲一区在线视频观看| 老司机精品视频在线| 成人一道本在线| 欧美午夜精品电影| 精品美女一区二区| 日韩毛片一二三区| 日韩电影在线观看网站| 国产成人精品1024| 91亚洲大成网污www| 欧美精品日日鲁夜夜添| 久久色在线观看| 亚洲一区视频在线观看视频| 蜜桃久久久久久| 一区二区三区四区国产精品| 久久精品国产在热久久| 在线观看国产精品网站| 国产精品久久久久一区二区三区| 麻豆极品一区二区三区| 欧美疯狂性受xxxxx喷水图片| 亚洲视频一区二区在线观看| 国产一区二区三区不卡在线观看| 欧美精品丝袜中出| 亚洲尤物在线视频观看| 在线中文字幕一区二区| 国产精品免费看片| 国产.精品.日韩.另类.中文.在线.播放 | 中文字幕av一区二区三区| 激情都市一区二区| 日韩欧美视频一区| 日韩成人精品在线| 91麻豆精品国产91久久久| 亚洲一区二区在线免费看| www.99精品| 亚洲日本一区二区| 91亚洲永久精品| 中文字幕制服丝袜一区二区三区| 国产夫妻精品视频| 国产亚洲欧美日韩在线一区| 韩国在线一区二区| 久久久久综合网| 国产精品自拍一区| 国产欧美日韩在线看| 国产白丝精品91爽爽久久| 国产日韩欧美综合一区| 国产69精品久久99不卡| 国产精品视频一二三| 成人国产一区二区三区精品| 中文字幕亚洲综合久久菠萝蜜| 成人黄色网址在线观看| 1000精品久久久久久久久| 99精品视频在线播放观看| 亚洲色图欧美激情| 欧美色偷偷大香| 日韩中文字幕区一区有砖一区| 日韩一区二区三区四区| 国产一区二区在线免费观看| 国产午夜亚洲精品不卡| 波多野洁衣一区| 亚洲中国最大av网站| 制服丝袜亚洲播放| 国产一级精品在线| 国产精品国产a| 欧美视频一区在线| 看片的网站亚洲| 国产精品盗摄一区二区三区|