<commit_before>(function(){
	/**
	 * ConstraintCollection
	 * Combines a number of constraints
	 * @constructor
	 * @param {Array.<Constraint>} constraints
	 * @implements {Constraint}
	 */
	//TODO: option: breakearly
	var ConstraintCollection = function(constraints){
		/**
		 * Collection of Contraints
		 * @private
		 * @type {Array.<Constraint>}
		 */
		this.constraints = constraints == undefined ? [] : constraints;
	};
	var c = ConstraintCollection.prototype;

	/** @inheritDoc */
    c.constrainRotation = function(newRotation, moveable){
		var length = this.constraints.length;
		var i = 0;
		var ret = true;
		while(i<length && ret){
			//TODO: run over all constraints instead of a break as soon as a false is returned from of them?
			// this would allow all constraints to do something with the transformation or the moveable.
			// however, this might lead to a status in a which a change of a constraint changes
			// the behaviour of an following constraint
			ret = ret && this.constraints[i].constrainRotation(newRotation, moveable);
			i++;
		}
    	return ret;
    };

    /** @inheritDoc */
    c.constrainTranslation = function(newPosition, moveable){
		var length = this.constraints.length;
		var i = 0;
		var ret = true;
		while(i<length && ret){
			ret = ret && this.constraints[i].constrainTranslation(newPosition, moveable);
			i++;
		}
    	return ret;
    };

    /**
     * Adds a constraint to the collection
     * @param {Constraint} constraint
     */
    c.addConstraint = function(constraint){
		this.constraints.push(constraint);
    };

    /**
     * Removes a constraint from the collection
     * @param {Constraint} constraint
     */
    c.removeContraint = function(constraint){
		var i = this.constraints.indexOf(constraint);
		//indexOf returns -1 if item was not found
		if(i !== -1) this.constraints.splice(i,1);
    };

    //export
    XMOT.ConstraintCollection = ConstraintCollection;
}());
<commit_msg>Introduced break early option for the Constraint collection<commit_after>(function(){
	/**
	 * ConstraintCollection
	 * Combines a number of constraints
	 * @constructor
	 * @param {Array.<Constraint>|undefined} constraints
	 * @param {boolean} breakEarly do not check all constraints if one fail
	 * @implements {Constraint}
	 */
	var ConstraintCollection = function(constraints, breakEarly){
		/**
		 * Collection of Contraints
		 * @private
		 * @type {Array.<Constraint>|undefined}
		 */
		this.constraints = constraints == undefined ? [] : constraints;
		/**
		 * break early flag
		 * @private
		 * @type{boolean}
		 */
		this.breakEarly = breakEarly || true;
	};
	var c = ConstraintCollection.prototype;

	/** @inheritDoc */
    c.constrainRotation = function(newRotation, moveable){
    	var constraints = this.constraints;
    	var length = constraints.length;
		var i = 0;
		var ret = true;
		var breakEarly = this.breakEarly;
		
		while( i<length && (ret || !breakEarly) ){
			ret = ret && constraints[i].constrainRotation(newRotation, moveable);
			i++;
		}
    	return ret;
    };

    /** @inheritDoc */
    c.constrainTranslation = function(newPosition, moveable){
    	var constraints = this.constraints;
		var length = constraints.length;
		var i = 0;
		var ret = true;
		var breakEarly = this.breakEarly;
		while( i<length && (ret || !breakEarly) ){
			ret = ret && constraints[i].constrainTranslation(newPosition, moveable);
			i++;
		}
    	return ret;
    };

    /**
     * Adds a constraint to the collection
     * @param {Constraint} constraint
     */
    c.addConstraint = function(constraint){
		this.constraints.push(constraint);
    };

    /**
     * Removes a constraint from the collection
     * @param {Constraint} constraint
     */
    c.removeContraint = function(constraint){
		var i = this.constraints.indexOf(constraint);
		//indexOf returns -1 if item was not found
		if(i !== -1) this.constraints.splice(i,1);
    };

    //export
    XMOT.ConstraintCollection = ConstraintCollection;
}());

{'fraction_non_alphanumeric': 0.12384056154424668, 'fraction_numerical': 0.00250689395838556, 'mean_word_length': 3.2, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3683506', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1136, 'n_words': 327}