sum.as

来自「用于flash/flex的 as3的 2D图形图像图表的动态生成」· AS 代码 · 共 46 行

AS
46
字号
package flare.query
{
	/**
	 * Aggregate operator for computing the sum of a set of values.
	 */
	public class Sum extends AggregateExpression
	{
		private var _sum:Number;
		
		/**
		 * Creates a new Sum operator.
		 * @param input the sub-expression of which to compute the sum
		 */
		public function Sum(input:*) {
			super(input);
		}
		
		/**
		 * @inheritDoc
		 */
		public override function reset():void
		{
			_sum = 0;
		}
		
		/**
		 * @inheritDoc
		 */
		public override function eval(o:Object=null):*
		{
			return _sum;
		}
		
		/**
		 * @inheritDoc
		 */
		public override function aggregate(value:Object):void
		{
			var x:Number = Number(_expr.eval(value));
			if (!isNaN(x)) {
				_sum += x;
			}
		}
		
	} // end of class Sum
}

⌨️ 快捷键说明

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