membershipuos.java

来自「国外的数据结构与算法分析用书」· Java 代码 · 共 54 行

JAVA
54
字号
/* MembershipUos.java
 * ---------------------------------------------
 * Copyright (c) 2001 University of Saskatchewan
 * All Rights Reserved
 * --------------------------------------------- */
 
package dslib.base;

/**	A ContainerUos class which includes a membership test has and 
	equality test membershipEqual */
public interface MembershipUos extends ContainerUos
{
	/**	Does the structure contain 'y'?. 
		@param y item whose presence is to be determined */
	public boolean has(Object y);
 
// 		Suggested implementation
//	/**	Defines the type of comparison to use
//		Initialize objectReferenceComparison to false, 
//		so the default is compare contents */
//	protected boolean objectReferenceComparison = false;
  
//		Suggested implementation
	/**	Test whether x equals y using the current comparison mode 
		@param x item to be compared to y
		@param y item to be compared to x */
	public boolean membershipEquals(Object x, Object y);
//  	{
//  		if (objectReferenceComparison)
//  			return  (x==y);
//  		else if ((x instanceof Comparable) && (y instanceof Comparable))
//  			return  0==((Comparable)x).compareTo((Comparable)y);
//  		else if (x.equals(y))
//  			return true;
//  		else 
//  			return false;
//  	} 

	/**	Set comparison operations to use '=='or equals */
	public void compareObjectReferences();
//		suggested implementation
//		{
//			objectReferenceComparison = true;
//		}
 
	/**	Set comparison operations to use equal() or compareTo() */
	public void compareContents();
//		suggested implementation
// 		{
//			objectReferenceComparison =false;
//		} 

} 

⌨️ 快捷键说明

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