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

📄 contextlist.java

📁 用JAVA实现排序等简单算法的演示
💻 JAVA
字号:
package contextsPoolManager;

import java.util.ArrayList;

/**
 * 存放上下文列表信息的类
 * @author carlven
 * @since 2007/10/15
 * @version 1.0
 *
 */
public class ContextList {

	private ArrayList<Context> contexts = null;		// 存放真正的上下文信息
	
	public ContextList() { 
		contexts = new ArrayList<Context>(10);
	}
	
	/**
	 * 加入上下文
	 */
	public void addContext(Context context) {
		contexts.add(context);
	}

	/**
	 * 删除上下文
	 */
	public void removeContext(Context context) {
		contexts.remove(context);
	}

	/**
	 * 返回列表中上下文个数
	 */
	public int getContextSize() {
		return contexts.size();
	}

	/** 
	 * 返回下标为 index 的上下文,用于遍历列表中的所有上下文
	 */
	public Context getContext(int index) {
		return contexts.get(index);
	}

	/**
	 * 清除所有上下文
	 */
	public void clear() {
		contexts.clear();
	}

	/**
	 * 转换成字符串以方便测试或调试时输出
	 */
	public String toString() {
		StringBuffer result = new StringBuffer();
		
		for (int index = 0; index < contexts.size(); index++) {
			Context context = contexts.get(index);
			result.append(context);
		}
		return result.toString();
	}

}

⌨️ 快捷键说明

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