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

📄 abstractexpressionevaluation.java

📁 <算法导论>第二版大部分算法实现. 1. 各类排序和顺序统计学相关 2. 数据结构 2.1 基本数据结构 2.2 散列表 2.3 二叉查找树 2.4 红黑树 2.5 数据结构
💻 JAVA
字号:
/* * Copyright (C) 2003-2008 Wang Pengcheng <wpc0000@gmail.com> * Permission is granted to copy, distribute and/or modify this * document under the terms of the GNU Free Documentation License, * Version 2.0 or any later version published by the Free Software Foundation; * with no Invariant Sections. * You may obtain a copy of the License at *   http://www.gnu.org/licenses/lgpl.txt *///20 Feb 2008package cn.edu.whu.iss.algorithm.unit10.expression.evaluation;/** * Abstract expression evaluation. * @author wpc * @version 0.0.1 */public abstract class AbstractExpressionEvaluation implements		EvaluateExpression {	/**	 * saving expression	 */	protected String expression;	/**	 * the operator +	 */	public static final char OPERATOR_ADD = '+';	public static final char OPERATOR_MINUS = '-';	public static final char OPERATOR_MULTI = '*';	public static final char OPERATOR_DIV = '/';	public static final char OPERATOR_POW = '^';	public static final char OPERATOR_LEFT_BRACKET = '(';	public static final char OPERATOR_RIGHT_BRACKET = ')';	public static final String EMPTY_STR = "";	public static final int DEFAULT_SCALE = 10;	/**	 * the negative sign -number	 */	public static final String NEGATIVE_SIGN = "-negative";	public static final char NUMBER_POINT = '.';		public static final char[] CHAR_OPERA ={		OPERATOR_ADD,OPERATOR_MINUS,OPERATOR_MULTI,OPERATOR_DIV,OPERATOR_LEFT_BRACKET,		OPERATOR_RIGHT_BRACKET	};		public static final int WITHOUD_BRACKET_END = 4;		/**	 * Check the char is operator or not	 * @param c the char	 * @return true is the operator	 */	public static boolean isCharOpera(char c){		for(int i=0;i<CHAR_OPERA.length;i++){			if(c==CHAR_OPERA[i]){				return true;			}		}		return false;	}		/**	 * Check the char is the operator divide or multiplication 	 * @param s the String will be used the string.charAt(0)	 * @return true is the divide or multiplication,otherwise is null or not 	 */	public static boolean isOperaDivOrMULTI(String s){		if(s==null){			return false;		}		return isOperaDivOrMULTI(s.charAt(0));	}		/**	 * Check the char is the operator divide or multiplication 	 * @param s the char	 * @return true is the divide or multiplication,otherwise is null or not 	 */	public static boolean isOperaDivOrMULTI(char s){		if(s==OPERATOR_DIV||s==OPERATOR_MULTI){			return true;		}else{			return false;		}	}		/**	 * Check the string is the negative sign	 * @param s the expression or number	 * @return true is the negative sign	 */	public static boolean isNegativeSign(String s){		if(s!=null&&s.equals(NEGATIVE_SIGN)){			return true;		}else{			return false;		}			}		/**	 * Check the expression is the border( null or "(" )	 * @param s the expression	 * @return true is the border 	 */	public static boolean isBorder(String s){		if(s==null||s.charAt(0)==OPERATOR_LEFT_BRACKET){			return true;		}else{			return false;		}	}		public static boolean isNumberPoint(char c){		return c==NUMBER_POINT;	}}

⌨️ 快捷键说明

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