Using selections from the given set of tuples, completes binding for all remaining variables.
Returns true if all variables have been bound.
351825
private boolean completeSatisfied( TestCaseDef testCase, VarTupleSet tuples, List<VarDef> vars)
    {
    List<VarDef> varsRemaining = getVarsRemaining( vars, testCase);
    VarDef varApplicable;
    boolean complete; 

    // Any variables remaining unbound?
    if( varsRemaining.isEmpty())
      {
      // No, this test case is complete.
      complete = true;
      }
    
    // Any variables remaining that are currently applicable to this test case?
    else if( (varApplicable = varsRemaining.stream().filter( v -> testCase.isApplicable(v)).findFirst().orElse( null)) == null)
      {
      // No, continue with an NA binding for the next variable
      testCase.addCompatible( getNaBindingFor( varsRemaining.get( 0)));
      complete = makeComplete( testCase, tuples, varsRemaining);
      }

    else
      {
      // Find an applicable binding that will lead to a complete test case
      int prevBindings = testCase.getBindingCount();
      Iterator<Tuple> bindingTuples = getBindingsFor( tuples, varApplicable);
      for( complete = false;

           // More tuples to try?
           bindingTuples.hasNext()
             && !(
               // Compatible tuple found?
               testCase.addCompatible( (bindingTuples.next())) != null

               // Did this tuple create an infeasible combination?
               && !testCase.isInfeasible()

               // Can we complete bindings for remaining variables?
               && (complete = makeComplete( testCase, tuples, varsRemaining)));
             
           // No path to completion with this tuple -- try the next one.
           testCase.revertBindings( prevBindings));
      }
    
    return complete;
    }
442243
public static <T extends SyntacticItem> java.util.function.Function<Identifier, SyntacticItem> bindingFunction(
			Tuple<Template.Variable> variables, Tuple<T> arguments) {
		//
		return (Identifier var) -> {
			for (int i = 0; i != variables.size(); ++i) {
				if (var.equals(variables.get(i).getName())) {
					return arguments.get(i);
				}
			}
			return null;
		};
	}
86133
def selections(self):
        """
        for sel in self._selections:
            if sel.annotation.axes is None:
                raise RuntimeError("Annotation unexpectedly removed; "
                                   "use 'cursor.remove_selection' instead")
        return tuple(self._selections)
1111829
def deselect_all(self):
        
        if not self.is_multiple:
            raise NotImplementedError("You may only deselect all options of a multi-select")
        for opt in self.options:
            self._unsetSelected(opt)
427568
public static Tuple of( Collection<VarBindingDef> tupleBindings)
    {
    Tuple tuple = new Tuple();
    
    boolean bindingsCompatible;
    Iterator<VarBindingDef> bindings;
    VarBindingDef nextBinding;
    for( bindings = tupleBindings.iterator(),
           bindingsCompatible = true; 

         bindings.hasNext()
           && (bindingsCompatible = isBindingCompatible( tuple, (nextBinding = bindings.next())));

         tuple.add( nextBinding));
    
    return
      bindingsCompatible && tuple.isCompatible()
      ? tuple
      : null;
    }
1104803
def contains_variables_from_set(expression, variables):
    """"""
    if hasattr(expression, 'variable_name') and expression.variable_name in variables:
        return True
    if isinstance(expression, Operation):
        return any(contains_variables_from_set(o, variables) for o in op_iter(expression))
    return False
1029210
public TupleRefBuilder bindings( Stream<VarBinding> bindings)
    {
    bindings.forEach( binding -> tupleRef_.addVarBinding( binding));
    return this;
    }
625259
public static java.util.function.Function<Identifier, SyntacticItem> removeFromBinding(
			java.util.function.Function<Identifier, SyntacticItem> binding, Tuple<Identifier> variables) {
		return (Identifier var) -> {
			// Sanity check whether this is a variable which is being removed
			for (int i = 0; i != variables.size(); ++i) {
				if (var.equals(variables.get(i))) {
					return null;
				}
			}
			// Not being removed, reuse existing binding
			return binding.apply(var);
		};
	}
747170
def select(self, fixed):
        
        names = [n for n in self.names() if self[n].isfixed == fixed]
        return Variables({n: self[n] for n in names})
962779
private void closeResultSet
        (CodeBuilder b, LocalVariable rsVar, Label tryAfterRs)
    {
        Label contLabel = b.createLabel();
        Label endFinallyLabel = b.createLabel().setLocation();

        b.loadLocal(rsVar);
        b.invokeInterface(TypeDesc.forClass(ResultSet.class), "close", null, null);
        b.branch(contLabel);

        b.exceptionHandler(tryAfterRs, endFinallyLabel, null);
        b.loadLocal(rsVar);
        b.invokeInterface(TypeDesc.forClass(ResultSet.class), "close", null, null);
        b.throwObject();

        contLabel.setLocation();
    }
1165708
public boolean containsKey(Object key) {
    if(wrappedBindings.containsKey(key)) {
      return true;
    }
    if (key instanceof String) {
      return variableContext.containsVariable((String) key);
    }
    else {
      return false;
    }
  }
679803
def bind(self, **bindings):
    """"""
    found_vars = set()
    result = []
    for layer in self.flatten():
      if isinstance(layer, _DeferredLayer):
        var_keys = {var.key for var in six.itervalues(layer.unbound_vars)}
        layers_bindings = {
            k: v
            for k, v in six.iteritems(bindings) if k in var_keys
        }
        result.append(layer.bind(**layers_bindings))
        found_vars.update(six.iterkeys(layers_bindings))
      else:
        result.append(layer)
    missing_vars = set(six.iterkeys(bindings)) - found_vars
    if missing_vars:
      raise ValueError('Unused bindings: %s' % missing_vars)
    return self.__class__(*result)
604071
private double getUsedScore( VarBindingDef binding, boolean onceOnly)
    {
    // Since used tuples are in least-recently-used-first order, start from the end of the list and look
    // for the first tuple that includes this binding. This is the most recent use of this binding.
    // Return the distance of this tuple from the start of the list, as percentage of the size of the list.
    int index;
    int usedCount;
    Tuple nextTuple;
    for( usedCount = used_.size(),
           index = usedCount - 1;

         index >= 0
           && (nextTuple = used_.get( index)) != null
           && !((!onceOnly || nextTuple.isOnce()) && nextTuple.contains( binding));

         index--);

    return
      index < 0
      ? 0.0

      : (double)(index + 1) / (usedCount + 1);
    }
609516
public static boolean isVariableSet(QuerySolution resultRow, String variableName) {

        if (resultRow != null) {
            return resultRow.contains(variableName);
        }

        return false;
    }
797537
def _finish_selecting(self, event):
        """"""
        self._selecting = False
        canvas = self._canvas
        x = canvas.canvasx(event.x)
        y = canvas.canvasy(event.y)
        
        canvas.coords(self._sobject, -1, -1, -1, -1)
        canvas.itemconfigure(self._sobject, state=tk.HIDDEN)

        sel_region = self._sstart[0], self._sstart[1], x, y
        canvas.region_selected = sel_region
        canvas.event_generate('<<RegionSelected>>')
634073
def context_binding(variables)
      context = TemplateEvaluationContext.new

      helpers.each { |helper| context.extend(helper) }

      variables.each do |k, v|
        context.instance_variable_set("@#{k}", v)
      end

      context.__get_binding
    end
214385
def bound_variable(self):
        
        class BoundVariable:
            def __init__(self, variable):
                self.__variable = variable
                self.changed_event = Event.Event()
                self.needs_rebind_event = Event.Event()
                def property_changed(key):
                    if key == "value":
                        self.changed_event.fire()
                self.__variable_property_changed_listener = variable.property_changed_event.listen(property_changed)
            @property
            def value(self):
                return self.__variable.value
            def close(self):
                self.__variable_property_changed_listener.close()
                self.__variable_property_changed_listener = None

        return BoundVariable(self)