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

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

?? entries.java

?? Chord package into p2psim
?? JAVA
字號(hào):
/***************************************************************************
 *                                                                         *
 *                               Entries.java                              *
 *                            -------------------                          *
 *   date                 : 28.02.2005                                     *
 *   copyright            : (C) 2004-2008 Distributed and                  *
 *                              Mobile Systems Group                       *
 *                              Lehrstuhl fuer Praktische Informatik       *
 *                              Universitaet Bamberg                       *
 *                              http://www.uni-bamberg.de/pi/              *
 *   email                : sven.kaffille@uni-bamberg.de                   *
 *   			    		karsten.loesing@uni-bamberg.de                 *
 *                                                                         *
 *                                                                         *
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program 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 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   A copy of the license can be found in the license.txt file supplied   *
 *   with this software or at: http://www.gnu.org/copyleft/gpl.html        *
 *                                                                         *
 ***************************************************************************/

package de.uniba.wiai.lspi.chord.service.impl;

import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

import de.uniba.wiai.lspi.chord.com.Entry;
import de.uniba.wiai.lspi.chord.data.ID;
import de.uniba.wiai.lspi.util.logging.Logger;

/**
 * Stores entries for the local node in a local hash table and provides methods
 * for accessing them. It IS allowed, that multiple objects of type
 * {@link Entry} with same {@link ID} are stored!
 * 
 * @author Karsten Loesing, Sven Kaffille
 * @version 1.0.5
 * 
 */

/*
 * 23.12.2006. Fixed synchronization. The Map<ID, Set<Entry>> entries must be
 * synchronized with a synchronized statement, when executing several methods
 * that depend on each other. This would also apply to the internal Set<Entry>
 * if it were not only used in the same synchronized statements for entries,
 * which than functions as a synchronization point. It must also be locked by a
 * synchronized statement, when iterating over it. TODO: What about fairness?
 * sven
 */
final class Entries {

	/**
	 * Object logger.
	 */
	private final static Logger logger = Logger.getLogger(Entries.class);

	private final static boolean debugEnabled = logger
			.isEnabledFor(Logger.LogLevel.DEBUG);

	/**
	 * Local hash table for entries. Is synchronized, st. methods do not have to
	 * be synchronized.
	 */
	private Map<ID, Set<Entry>> entries = null;

	/**
	 * Creates an empty repository for entries.
	 */
	Entries(){ 
		this.entries = Collections
				.synchronizedMap(new TreeMap<ID, Set<Entry>>());
	}

	/**
	 * Stores a set of entries to the local hash table.
	 * 
	 * @param entriesToAdd
	 *            Set of entries to add to the repository.
	 * @throws NullPointerException
	 *             If set reference is <code>null</code>.
	 */
	final void addAll(Set<Entry> entriesToAdd) {

		if (entriesToAdd == null) {
			NullPointerException e = new NullPointerException(
					"Set of entries to be added to the local hash table may "
							+ "not be null!");
			Entries.logger.error("Null pointer", e);
			throw e;
		}

		for (Entry nextEntry : entriesToAdd) {
			this.add(nextEntry);
		}

		if (debugEnabled) {
			Entries.logger.debug("Set of entries of length "
					+ entriesToAdd.size() + " was added.");
		}
	}

	/**
	 * Stores one entry to the local hash table.
	 * 
	 * @param entryToAdd
	 *            Entry to add to the repository.
	 * @throws NullPointerException
	 *             If entry to add is <code>null</code>.
	 */
	final void add(Entry entryToAdd) {
		
		if (entryToAdd == null) {
			NullPointerException e = new NullPointerException(
					"Entry to add may not be null!");
			Entries.logger.error("Null pointer", e);
			throw e;
		}

		Set<Entry> values;
		synchronized (this.entries) {
			if (this.entries.containsKey(entryToAdd.getId())) {
				values = this.entries.get(entryToAdd.getId());
			} else {
				values = new HashSet<Entry>();
				this.entries.put(entryToAdd.getId(), values);
			}
			values.add(entryToAdd);
		}
		if (debugEnabled) {
			Entries.logger.debug("Entry was added: " + entryToAdd);
		}
	}

	/**
	 * Removes the given entry from the local hash table.
	 * 
	 * @param entryToRemove
	 *            Entry to remove from the hash table.
	 * @throws NullPointerException
	 *             If entry to remove is <code>null</code>.
	 */
	final void remove(Entry entryToRemove) {
		
		if (entryToRemove == null) {
			NullPointerException e = new NullPointerException(
					"Entry to remove may not be null!");
			Entries.logger.error("Null pointer", e);
			throw e;
		}

		synchronized (this.entries) {
			if (this.entries.containsKey(entryToRemove.getId())) {
				Set<Entry> values = this.entries.get(entryToRemove.getId());
				values.remove(entryToRemove);
				if (values.size() == 0) {
					this.entries.remove(entryToRemove.getId());
				}
			}
		}
		if (debugEnabled) {
			Entries.logger.debug("Entry was removed: " + entryToRemove);
		}
	}

	/**
	 * Returns a set of entries matching the given ID. If no entries match the
	 * given ID, an empty set is returned.
	 * 
	 * @param id
	 *            ID of entries to be returned.
	 * @throws NullPointerException
	 *             If given ID is <code>null</code>.
	 * @return Set of matching entries. Empty Set if no matching entries are
	 *         available.
	 */
	final Set<Entry> getEntries(ID id) {

		if (id == null) {
			NullPointerException e = new NullPointerException(
					"ID to find entries for may not be null!");
			Entries.logger.error("Null pointer", e);
			throw e;
		}
		synchronized (this.entries) {
			/*
			 * This has to be synchronized as the test if the map contains a set
			 * associated with id can succeed and then the thread may hand
			 * control over to another thread that removes the Set belonging to
			 * id. In that case this.entries.get(id) would return null which
			 * would break the contract of this method.
			 */
			if (this.entries.containsKey(id)) {
				Set<Entry> entriesForID = this.entries.get(id);
				/*
				 * Return a copy of the set to avoid modification of Set stored
				 * in this.entries from outside this class. (Avoids also
				 * modifications concurrent to iteration over the Set by a
				 * client of this class.
				 */
				if (debugEnabled) {
					Entries.logger.debug("Returning entries " + entriesForID);
				}
				return new HashSet<Entry>(entriesForID);
			}
		}
		if (debugEnabled) {
			Entries.logger.debug("No entries available for " + id
					+ ". Returning empty set.");
		}
		return new HashSet<Entry>();
	}

	/**
	 * Returns all entries in interval, excluding lower bound, but including
	 * upper bound
	 * 
	 * @param fromID
	 *            Lower bound of IDs; entries matching this ID are NOT included
	 *            in result.
	 * @param toID
	 *            Upper bound of IDs; entries matching this ID ARE included in
	 *            result.
	 * @throws NullPointerException
	 *             If either or both of the given ID references have value
	 *             <code>null</code>.
	 * @return Set of matching entries.
	 */
	final Set<Entry> getEntriesInInterval(ID fromID, ID toID) {

		if (fromID == null || toID == null) {
			NullPointerException e = new NullPointerException(
					"Neither of the given IDs may have value null!");
			Entries.logger.error("Null pointer", e);
			throw e;
		}

		Set<Entry> result = new HashSet<Entry>();

		synchronized (this.entries) {
			for (ID nextID : this.entries.keySet()) {
				if (nextID.isInInterval(fromID, toID)) {
					Set<Entry> entriesForID = this.entries.get(nextID);
					for (Entry entryToAdd : entriesForID) {
						result.add(entryToAdd);
					}
				}
			}
		}

		// add entries matching upper bound
		result.addAll(this.getEntries(toID));

		return result;
	}

	/**
	 * Removes the given entries from the local hash table.
	 * 
	 * @param toRemove
	 *            Set of entries to remove from local hash table.
	 * @throws NullPointerException
	 *             If the given set of entries is <code>null</code>.
	 */
	final void removeAll(Set<Entry> toRemove) {

		if (toRemove == null) {
			NullPointerException e = new NullPointerException(
					"Set of entries may not have value null!");
			Entries.logger.error("Null pointer", e);
			throw e;
		}

		for (Entry nextEntry : toRemove) {
			this.remove(nextEntry);
		}

		if (debugEnabled) {
			Entries.logger.debug("Set of entries of length " + toRemove.size()
					+ " was removed.");
		}
	}

	/**
	 * Returns an unmodifiable map of all stored entries.
	 * 
	 * @return Unmodifiable map of all stored entries.
	 */
	final Map<ID, Set<Entry>> getEntries() {
		return Collections.unmodifiableMap(this.entries);
	}

	/**
	 * Returns the number of stored entries.
	 * 
	 * @return Number of stored entries.
	 */
	final int getNumberOfStoredEntries() {
		return this.entries.size();
	}

	/**
	 * Returns a formatted string of all entries stored in the local hash table.
	 * 
	 * @return String representation of all stored entries.
	 */
	public final String toString() {
		StringBuilder result = new StringBuilder("Entries:\n");
		for (Map.Entry<ID, Set<Entry>> entry : this.entries.entrySet()) {
			result.append("  key = " + entry.getKey().toString()
					+ ", value = " + entry.getValue() + "\n");
		}
		return result.toString();
	}
}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区二区三区日韩| 欧美一级xxx| 成人国产精品免费观看视频| 老司机免费视频一区二区 | 婷婷六月综合亚洲| 亚洲一区二区三区三| 亚洲美女淫视频| 亚洲图片欧美色图| 亚洲一线二线三线久久久| 一二三四社区欧美黄| 亚洲最新视频在线播放| 亚洲小说春色综合另类电影| 亚洲一二三四区| 日韩在线a电影| 日韩 欧美一区二区三区| 免费成人在线网站| 激情丁香综合五月| 粉嫩蜜臀av国产精品网站| www..com久久爱| 色av成人天堂桃色av| 欧美高清性hdvideosex| 日韩免费在线观看| 国产色综合一区| 日韩伦理免费电影| 水野朝阳av一区二区三区| 怡红院av一区二区三区| 一区二区三区在线视频观看| 亚洲成人精品一区| 久久se精品一区二区| 国产69精品久久久久毛片| 色88888久久久久久影院野外| 91传媒视频在线播放| 欧美一区在线视频| 国产亚洲欧美在线| 亚洲久草在线视频| 石原莉奈一区二区三区在线观看 | 欧美美女黄视频| 精品国产一区久久| 国产精品久久久久婷婷二区次| 夜夜揉揉日日人人青青一国产精品 | 亚洲精选视频在线| 日本91福利区| 精品理论电影在线| 国产无一区二区| 亚洲一区在线观看视频| 久久国产欧美日韩精品| 成人av网站大全| 欧美日韩精品欧美日韩精品一综合| 精品999久久久| 亚洲一区二区中文在线| 国模无码大尺度一区二区三区| 99re热这里只有精品视频| 日韩无一区二区| 日韩毛片在线免费观看| 韩国毛片一区二区三区| 色八戒一区二区三区| 久久蜜臀精品av| 日韩影院精彩在线| 成人黄色a**站在线观看| 日韩欧美色电影| 一卡二卡三卡日韩欧美| 粉嫩蜜臀av国产精品网站| 欧美一级xxx| 亚洲精品成人少妇| 国产传媒日韩欧美成人| 日韩一二在线观看| 亚洲黄色片在线观看| 国产成人av影院| 日韩欧美一区电影| 亚洲亚洲精品在线观看| 99精品视频在线播放观看| 久久久久久一级片| 日本成人中文字幕| 欧美日韩综合在线| 亚洲精品乱码久久久久久| 成人免费观看视频| 久久综合久久综合久久综合| 日本va欧美va精品发布| 午夜精品久久久久| 福利电影一区二区三区| 欧美xxxxxxxx| 青娱乐精品视频| 欧美精选一区二区| 亚洲一区二区av在线| 日本韩国精品在线| 一区二区中文字幕在线| 国产成人av电影在线观看| 日韩视频免费直播| 日韩成人精品在线| 51精品国自产在线| 五月天激情综合| 777xxx欧美| 亚洲电影一级片| 欧美日韩一区不卡| 午夜精品国产更新| 制服.丝袜.亚洲.另类.中文 | 国产黑丝在线一区二区三区| 久久综合给合久久狠狠狠97色69| 美腿丝袜一区二区三区| 在线播放国产精品二区一二区四区| 亚洲一区日韩精品中文字幕| 91福利社在线观看| 亚洲一区二区免费视频| 欧美天天综合网| 亚洲第一会所有码转帖| 6080午夜不卡| 麻豆一区二区99久久久久| 精品国产电影一区二区| 国产综合久久久久影院| 国产日本欧洲亚洲| av欧美精品.com| 一级做a爱片久久| 69堂成人精品免费视频| 久久99精品视频| 久久日一线二线三线suv| 国产盗摄视频一区二区三区| 亚洲国产经典视频| 国产真实乱偷精品视频免| 久久一区二区视频| 丁香婷婷综合五月| 亚洲欧美日韩在线播放| 欧美亚洲国产怡红院影院| 婷婷久久综合九色综合伊人色| 欧美一区二区三区成人| 激情国产一区二区| 国产精品国产三级国产aⅴ入口| 91色porny在线视频| 亚洲午夜成aⅴ人片| 欧美一级高清片| 粉嫩一区二区三区在线看| 一区二区三区在线免费播放| 67194成人在线观看| 国产一区二区三区四| 亚洲天堂久久久久久久| 欧美精品1区2区| 国产激情一区二区三区四区| 亚洲欧美电影一区二区| 欧美日韩国产在线观看| 久久 天天综合| 中文字幕中文在线不卡住| 欧美日韩精品三区| 国产成人av资源| 亚洲风情在线资源站| 久久综合给合久久狠狠狠97色69| 91在线视频观看| 久久久www成人免费无遮挡大片| 精品一区二区精品| 久久久久久久久久久黄色| 国内精品国产成人国产三级粉色| 日韩理论片在线| 久久免费精品国产久精品久久久久| 亚洲乱码一区二区三区在线观看| 69堂精品视频| 国产69精品一区二区亚洲孕妇| 欧美另类videos死尸| 极品少妇一区二区三区精品视频| 视频一区视频二区在线观看| 3d成人动漫网站| 精品99一区二区| 综合电影一区二区三区 | av在线播放一区二区三区| 精品国产髙清在线看国产毛片| 亚洲精品成人天堂一二三| 久久se精品一区精品二区| 精品国产髙清在线看国产毛片| 亚洲成人资源网| 一区二区三区中文字幕在线观看| 日韩一区二区免费在线观看| 视频一区二区国产| 欧美一级精品大片| 日韩成人一区二区| 亚洲欧美色图小说| 久久久亚洲午夜电影| 国产精品美女久久久久aⅴ国产馆| 在线观看一区不卡| 亚洲福利国产精品| 夜夜嗨av一区二区三区网页| 中文字幕一区二区三区视频 | 精品日产卡一卡二卡麻豆| 91丨porny丨首页| 国产麻豆欧美日韩一区| 美女精品自拍一二三四| 亚洲精品久久久久久国产精华液| 欧美日韩精品免费观看视频| 日韩高清在线一区| 水野朝阳av一区二区三区| 欧美精品久久一区二区三区| 亚洲欧美综合色| 亚洲综合免费观看高清完整版在线| 成人免费在线视频观看| 波多野结衣精品在线| 午夜久久久久久| 亚洲一区二区三区国产| 日韩精品专区在线影院重磅| 国产激情视频一区二区三区欧美| 亚洲欧洲成人精品av97| 亚洲图片你懂的| 中文字幕中文字幕在线一区 | 天天影视网天天综合色在线播放| 日韩精品中文字幕在线一区|