⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clusterborderiterator.java

📁 good project for programmer,,
💻 JAVA
字号:
package com.sillysoft.lux.util;import com.sillysoft.lux.Country;import java.util.ArrayList;import java.util.List;////  ClusterBorderIterator.java//  Lux////  Copyright (c) 2002-2007 Sillysoft Games. //	http://sillysoft.net//	lux@sillysoft.net////	This source code is licensed free for non-profit purposes. //	For other uses please contact lux@sillysoft.net///**Iterate through the countries that form the border of a cluster around a root Country.NOTE: This class is slightly different than the other CountryIterators. 	When created with a Country <i>root</i>, this will give an enumeration of all the coutries on the border of the cluster centered around this root.*/public class ClusterBorderIterator extends CountryIterator {public ClusterBorderIterator(Country root)	{	List cluster = new ArrayList();	cluster.add(root);		List borders = new ArrayList();		for (int i = 0; i < cluster.size(); i++) {		CountryIterator neighbors = new NeighborIterator( (Country)cluster.get(i) );		while (neighbors.hasNext()) {			Country neighbor = neighbors.next();			if (neighbor.getOwner() == root.getOwner()) {				if (! cluster.contains(neighbor) ) {					cluster.add(neighbor);					}				}			else				{				// an enemy, so cluster.get(i) is a border of this cluster				if (! borders.contains(cluster.get(i)))					borders.add(cluster.get(i));				}			}		}		// So we have found the borders of the cluster. set the countries array to it	countries = new Country[borders.size()];	for (int i = 0; i < countries.length; i++)		countries[i] = (Country)borders.get(i);		getNextReady();	}// This method should be over-riden in subclasses for different kinds.protected boolean isAHit( int code )	{	return true;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -