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

📄 pairuos.java

📁 国外的数据结构与算法分析用书
💻 JAVA
字号:
/* PairUos.java
 * ---------------------------------------------
 * Copyright (c) 2001 University of Saskatchewan
 * All Rights Reserved
 * --------------------------------------------- */
 
package dslib.base;

/**	This class represents a pair of objects. */
public class PairUos implements Cloneable,  java.io.Serializable
{
	/**	The first item of the pair. */
	protected Object firstItem;
  
	/**	The second item of the pair. */
	protected Object secondItem;
  
	/**	Initialize the values of the Pair. <br>
		Analysis: Time = O(1) <br>
		@param v1 the first value to be stored
		@param v2 the second value to be stored */
	public PairUos(Object v1, Object v2)
	{
		firstItem = v1;
		secondItem = v2;
	}

	/**	The first item of the pair. <br> 
		Analysis: Time = O(1) */
	public Object firstItem()
	{
		return firstItem;
	}
  
	/**	The second item of the pair. <br> 
		Analysis: Time = O(1) */
	public Object secondItem()
	{
		return secondItem;
	}
  
	/**	Set firstItem to newItem. <br> 
		Analysis: Time = O(1) 
		@param newItem item to be stored as the first item */
	public void setFirstItem(Object newItem)
	{
		firstItem = newItem;
	}
  
	/**	Set secondItem to newItem. <br> 
	 	Analysis: Time = O(1) 
	 	@param newItem item to be stored as the second item */
	public void setSecondItem(Object newItem)
	{
		secondItem = newItem;
	}
  
	/**	A shallow clone of this pair. <br> 
		Analysis: Time = O(1) */
	public Object clone()
	{
		try
		{
			return super.clone();
		} catch (CloneNotSupportedException e)
		{
			// Should not occur: PairUos implements Cloneable 
			e.printStackTrace();
 			return null;
		}
	}

	/**	String representation of the pair. <br> 
		Analysis: Time = O(1) */
	public String toString()
	{
		return "(" + firstItem + "," + secondItem + ")";
	}

} 

⌨️ 快捷键说明

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