// AddCostFunc returns a copy of g with a new cost function assigned.
15889
func (g *Virtual) AddCostFunc(c CostFunc) *Virtual {
	if c == nil {
		h := g.AddCost(0)
		return h
	}
	res := *g
	res.cost = c
	res.visit = func(v int, a int, do func(w int, c int64) bool) (aborted bool) {
		return g.visit(v, a, func(w int, _ int64) bool {
			return do(w, c(v, w))
		})
	}
	return &res
}
1058329
func AddCustomFunc(name string, f CustomFunc) error {
	name = strings.Title(name)
	if unFuncs[name] {
		return fmt.Errorf("invalid function name: %s", name)
	}

	funcs[name] = reflect.ValueOf(f)
	return nil
}
63432
func (mp *MockPeerCCSupport) AddCC(name string, recv chan *pb.ChaincodeMessage, send chan *pb.ChaincodeMessage) (*MockCCComm, error) {
	if mp.ccStream[name] != nil {
		return nil, fmt.Errorf("CC %s already added", name)
	}
	mcc := &MockCCComm{name: name, recvStream: recv, sendStream: send}
	mp.ccStream[name] = mcc
	return mcc, nil
}
127994
func (o *ResourceQuotaControllerOptions) AddFlags(fs *pflag.FlagSet) {
	if o == nil {
		return
	}

	fs.DurationVar(&o.ResourceQuotaSyncPeriod.Duration, "resource-quota-sync-period", o.ResourceQuotaSyncPeriod.Duration, "The period for syncing quota usage status in the system")
	fs.Int32Var(&o.ConcurrentResourceQuotaSyncs, "concurrent-resource-quota-syncs", o.ConcurrentResourceQuotaSyncs, "The number of resource quotas that are allowed to sync concurrently. Larger number = more responsive quota management, but more CPU (and network) load")
}
537586
func (s *Supervisor) AddFunc(f func(context.Context), opts ...ServiceOption) string {
	svc := &funcsvc{
		id: funcSvcID(),
		f:  f,
	}
	s.addService(svc, opts...)
	return svc.String()
}
416026
func (this *Router) AddParamFunc(name string, fn func(*Request, *Response, func())) {
	this.ParamFuncs[name] = fn
}
935494
func GtFunc(column string, fn *Func) Cmp {
	return Cmp{
		op:     gt,
		column: column,
		value:  fn,
	}
}
816816
func (s *RecurringCharge) SetCost(v *MonetaryAmount) *RecurringCharge {
	s.Cost = v
	return s
}
211598
func addValueFuncs(out map[string]reflect.Value, in FuncMap) {
	for name, fn := range in {
		v := reflect.ValueOf(fn)
		if v.Kind() != reflect.Func {
			panic("value for " + name + " not a function")
		}
		if !goodFunc(v.Type()) {
			panic(fmt.Errorf("can't install method/function %q with %d results", name, v.Type().NumOut()))
		}
		out[name] = v
	}
}
1294970
func NewDistAggFunc(expr *tipb.Expr, fieldTps []*types.FieldType, sc *stmtctx.StatementContext) (Aggregation, error) {
	args := make([]expression.Expression, 0, len(expr.Children))
	for _, child := range expr.Children {
		arg, err := expression.PBToExpr(child, fieldTps, sc)
		if err != nil {
			return nil, err
		}
		args = append(args, arg)
	}
	switch expr.Tp {
	case tipb.ExprType_Sum:
		return &sumFunction{aggFunction: newAggFunc(ast.AggFuncSum, args, false)}, nil
	case tipb.ExprType_Count:
		return &countFunction{aggFunction: newAggFunc(ast.AggFuncCount, args, false)}, nil
	case tipb.ExprType_Avg:
		return &avgFunction{aggFunction: newAggFunc(ast.AggFuncAvg, args, false)}, nil
	case tipb.ExprType_GroupConcat:
		return &concatFunction{aggFunction: newAggFunc(ast.AggFuncGroupConcat, args, false)}, nil
	case tipb.ExprType_Max:
		return &maxMinFunction{aggFunction: newAggFunc(ast.AggFuncMax, args, false), isMax: true}, nil
	case tipb.ExprType_Min:
		return &maxMinFunction{aggFunction: newAggFunc(ast.AggFuncMin, args, false)}, nil
	case tipb.ExprType_First:
		return &firstRowFunction{aggFunction: newAggFunc(ast.AggFuncFirstRow, args, false)}, nil
	case tipb.ExprType_Agg_BitOr:
		return &bitOrFunction{aggFunction: newAggFunc(ast.AggFuncBitOr, args, false)}, nil
	case tipb.ExprType_Agg_BitXor:
		return &bitXorFunction{aggFunction: newAggFunc(ast.AggFuncBitXor, args, false)}, nil
	case tipb.ExprType_Agg_BitAnd:
		return &bitAndFunction{aggFunction: newAggFunc(ast.AggFuncBitAnd, args, false)}, nil
	}
	return nil, errors.Errorf("Unknown aggregate function type %v", expr.Tp)
}
498764
func (alias *AliasPackage) AddConst(decl *ast.GenDecl) (err error) {
	if decl == nil {
		err = errors.New("unexpected nil")
		return
	} else if decl.Tok != token.CONST {
		err = ErrorUnexpectedToken{Expected: token.CONST, Received: decl.Tok}
		return
	}

	targetFile := alias.ModelFile()

	for _, spec := range decl.Specs {
		cast := spec.(*ast.ValueSpec)
		for j, name := range cast.Names {
			cast.Values[j] = &ast.SelectorExpr{
				X: &ast.Ident{
					Name: origImportAlias,
				},
				Sel: &ast.Ident{
					Name: name.Name,
				},
			}
		}
	}

	targetFile.Decls = append(targetFile.Decls, decl)

	return
}
160906
func (ms *MetricSystem) RegisterGaugeFunc(name string, f func() float64) {
	ms.gaugeFuncsMu.Lock()
	ms.gaugeFuncs[name] = f
	ms.gaugeFuncsMu.Unlock()
}
639558
func (t *toolbox) AddHealthCheckFunc(desc string, fn HealthCheckFunc) {
	t.healthCheckJobs = append(t.healthCheckJobs, &healthCheck{
		desc:  desc,
		check: fn,
	})
}
1327508
func (woc *wfOperationCtx) addParamToGlobalScope(param wfv1.Parameter) {
	if param.GlobalName == "" {
		return
	}
	index := -1
	if woc.wf.Status.Outputs != nil {
		for i, gParam := range woc.wf.Status.Outputs.Parameters {
			if gParam.Name == param.GlobalName {
				index = i
				break
			}
		}
	} else {
		woc.wf.Status.Outputs = &wfv1.Outputs{}
	}
	paramName := fmt.Sprintf("workflow.outputs.parameters.%s", param.GlobalName)
	woc.globalParams[paramName] = *param.Value
	if index == -1 {
		woc.log.Infof("setting %s: '%s'", paramName, *param.Value)
		gParam := wfv1.Parameter{Name: param.GlobalName, Value: param.Value}
		woc.wf.Status.Outputs.Parameters = append(woc.wf.Status.Outputs.Parameters, gParam)
		woc.updated = true
	} else {
		prevVal := *woc.wf.Status.Outputs.Parameters[index].Value
		if prevVal != *param.Value {
			woc.log.Infof("overwriting %s: '%s' -> '%s'", paramName, *woc.wf.Status.Outputs.Parameters[index].Value, *param.Value)
			woc.wf.Status.Outputs.Parameters[index].Value = param.Value
			woc.updated = true
		}
	}
}
758524
func (g *gatewayFlags) addFlagsToConfig(loadedConfig *config.GatewayConfig) {
	if g.operation.IsSet() {
		loadedConfig.ClusterOperation = pointer.String(g.operation.String())
	}
}
1141860
func (alias *AliasPackage) AddFunc(decl *ast.FuncDecl) (err error) {

	if decl == nil {
		err = errUnexpectedNil
		return
	}

	paramNames := collection.AsEnumerable(decl.Type.Params.List)
	paramNames = collection.SelectMany(paramNames, func(x interface{}) collection.Enumerator {
		return collection.AsEnumerable(x.(*ast.Field).Names).Enumerate(nil)
	})

	arguments := []ast.Expr{}

	for n := range paramNames.Enumerate(nil) {
		arguments = append(arguments, n.(*ast.Ident))
	}

	decl.Body = &ast.BlockStmt{
		List: []ast.Stmt{
			&ast.ReturnStmt{
				Results: []ast.Expr{
					&ast.CallExpr{
						Fun: &ast.SelectorExpr{
							X: &ast.Ident{
								Name: origImportAlias,
							},
							Sel: &ast.Ident{
								Name: decl.Name.Name,
							},
						},
						Args: arguments,
					},
				},
			},
		},
	}

	targetFile := alias.ModelFile()

	targetFile.Decls = append(targetFile.Decls, decl)

	return
}
1173270
func (p *PhysicalSort) GetCost(count float64) float64 {
	if count < 2.0 {
		count = 2.0
	}
	return count*cpuFactor + count*memoryFactor
}