| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 | 
							- "use strict";
 
- var MatchExpression = require("./MatchExpression");
 
- /**
 
-  * Create a match expression to match a list of
 
-  * @class ListOfMatchExpression
 
-  * @namespace mungedb-aggregate.matcher
 
-  * @module mungedb-aggregate
 
-  * @constructor
 
-  */
 
- var ListOfMatchExpression = module.exports = function ListOfMatchExpression(matchType){
 
- 	base.call(this);
 
- 	this._expressions = [];
 
- 	this._matchType = matchType;
 
- }, klass = ListOfMatchExpression, base = MatchExpression, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}}); //jshint ignore:line
 
- proto._expressions = undefined;
 
- /**
 
-  *
 
-  * Append a new expression to our list
 
-  * @method add
 
-  * @param Expression
 
-  *
 
-  */
 
- proto.add = function add( exp ){
 
- 	// verify(expression)
 
- 	if(!exp)
 
- 		throw new Error(exp + " failed verify on ListOfMatchExpression:add");
 
- 	if(this._expressions) {
 
- 		this._expressions.push(exp);
 
- 	} else {
 
- 		this._expressions = [exp];
 
- 	}
 
- };
 
- /**
 
-  *
 
-  * Empty us out
 
-  * @method clearAndRelease
 
-  *
 
-  */
 
- proto.clearAndRelease = function clearAndRelease(){
 
- 	this._expressions = []; // empty the expressions
 
- };
 
- /**
 
-  *
 
-  * Get the length of the list
 
-  * @method numChildren
 
-  * @param
 
-  *
 
-  */
 
- proto.numChildren = function numChildren(){
 
- 	return this._expressions.length;
 
- };
 
- /**
 
-  *
 
-  * Get an item from the expressions
 
-  * @method getChild
 
-  * @param i index of the child
 
-  *
 
-  */
 
- proto.getChild = function getChild(i){
 
- 	return this._expressions[i];
 
- };
 
- /**
 
-  *
 
-  * Get the expressions
 
-  * @method getChildVector
 
-  * @param
 
-  *
 
-  */
 
- proto.getChildVector = function getChildVector(){
 
- 	return this._expressions;
 
- };
 
- /**
 
-  *
 
-  * Print the debug info from each expression in the list
 
-  * @method _debugList
 
-  * @param level
 
-  *
 
-  */
 
- proto._debugList = function _debugList(debug, level){
 
- 	for (var i = 0; i < this._expressions.length; i++ )
 
- 		this._expressions[i].debugString(debug, level + 1);
 
- };
 
- /**
 
-  *
 
-  * Check if the input list is considered the same as this one
 
-  * @method equivalent
 
-  * @param other
 
-  *
 
-  */
 
- proto.equivalent = function equivalent(other){
 
- 	if (this._matchType !== other._matchType)
 
- 		return false;
 
- 	var realOther = new ListOfMatchExpression(other);
 
- 	if (this._expressions.length !== realOther._expressions.length)
 
- 		return false;
 
- 	// TODO: order doesn't matter
 
- 	for (var i = 0; i < this._expressions.length; i++ )
 
- 		if (!this._expressions[i].equivalent(realOther._expressions[i]))
 
- 			return false;
 
- 	return true;
 
- };
 
 
  |