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

📄 vertexuos.java

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

/**	A vertex of a graph that has a name and index. */
public class VertexUos implements Cloneable
{
	/**	The name of this vertex. */
	protected String name;

	/**	The index of this vertex. */
	protected int index;

	/**	Construct a new vertex and store n and id as its name and index. <br>
		Analysis: Time = O(1)
		@param n name of the new vertex
		@param id index of the new vertex */
	public VertexUos(String n, int id)
	{
		name = n;
		index = id;
	}

	/**	The name of this vertex. <br>
		Analysis: Time = O(1) */
	public String name()
	{
		return name;
	}
	
	/**	Set the name of the vertex. <br>
		Analysis : Time = O(1) 
		@param n new name for the current vertex */
	public void setName(String n)
	{
		name = n;
	}

	/**	The index of this vertex. <br>
		Analysis: Time = O(1) */
	public int index()
	{
		return index;
	}

	/**	String representation of the vertex. <br>
		Analysis: Time = O(1) */
	public String toString()
	{
		if (name != null)
			return name;
		else
			return String.valueOf(index);
	}
	
	/**	A shallow clone of this object. <br> 
		Analysis: Time = O(1) */
	public Object clone()
	{
		try
		{
			return super.clone();
		} catch (CloneNotSupportedException e)
		{
			/*	Should not occur: implements Cloneable. */
			e.printStackTrace();
			return null;
		}
	}
}

⌨️ 快捷键说明

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