コード例 #1
0
    public double B()
    {
        var r     = new Random();
        var array = new OptionalArray <double>(Length);

        for (int i = 0; i < array.Length; i++)
        {
            array[i] = r.NextDouble() < 0.1 ? Optional <double> .None : new Optional <double>(r.NextDouble());
        }

        var sum = 0.0;

        for (int i = 0; i < array.Length; i++)
        {
            var x = array[i];
            if (x.HasValue)
            {
                sum += x.GetValueOrDefault();
            }
        }
        foreach (var x in array)
        {
            if (x.HasValue)
            {
                sum += x.GetValueOrDefault();
            }
        }
        return(sum);
    }
コード例 #2
0
        public EventBeanUpdateItemForgeWExpressions ToExpression(
            Type type,
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol symbols,
            CodegenClassScope classScope)
        {
            var rhs = Expression.EvaluateCodegen(type, parent, symbols, classScope);
            EventBeanUpdateItemArrayExpressions arrayExpressions = null;
            if (OptionalArray != null) {
                arrayExpressions = OptionalArray.GetArrayExpressions(parent, symbols, classScope);
            }

            return new EventBeanUpdateItemForgeWExpressions(rhs, arrayExpressions);
        }