/* automatically generated by JSCoverage - do not edit */
if (typeof _$jscoverage === 'undefined') _$jscoverage = {};
if (! _$jscoverage['collections/Pool.js']) {
  _$jscoverage['collections/Pool.js'] = [];
  _$jscoverage['collections/Pool.js'][1] = 0;
  _$jscoverage['collections/Pool.js'][19] = 0;
  _$jscoverage['collections/Pool.js'][28] = 0;
  _$jscoverage['collections/Pool.js'][29] = 0;
  _$jscoverage['collections/Pool.js'][30] = 0;
  _$jscoverage['collections/Pool.js'][31] = 0;
  _$jscoverage['collections/Pool.js'][32] = 0;
  _$jscoverage['collections/Pool.js'][33] = 0;
  _$jscoverage['collections/Pool.js'][34] = 0;
  _$jscoverage['collections/Pool.js'][43] = 0;
  _$jscoverage['collections/Pool.js'][44] = 0;
  _$jscoverage['collections/Pool.js'][45] = 0;
  _$jscoverage['collections/Pool.js'][46] = 0;
  _$jscoverage['collections/Pool.js'][47] = 0;
  _$jscoverage['collections/Pool.js'][48] = 0;
  _$jscoverage['collections/Pool.js'][49] = 0;
  _$jscoverage['collections/Pool.js'][51] = 0;
  _$jscoverage['collections/Pool.js'][60] = 0;
  _$jscoverage['collections/Pool.js'][61] = 0;
  _$jscoverage['collections/Pool.js'][62] = 0;
  _$jscoverage['collections/Pool.js'][63] = 0;
  _$jscoverage['collections/Pool.js'][64] = 0;
  _$jscoverage['collections/Pool.js'][66] = 0;
  _$jscoverage['collections/Pool.js'][79] = 0;
  _$jscoverage['collections/Pool.js'][80] = 0;
  _$jscoverage['collections/Pool.js'][81] = 0;
  _$jscoverage['collections/Pool.js'][82] = 0;
  _$jscoverage['collections/Pool.js'][83] = 0;
  _$jscoverage['collections/Pool.js'][86] = 0;
  _$jscoverage['collections/Pool.js'][97] = 0;
  _$jscoverage['collections/Pool.js'][108] = 0;
  _$jscoverage['collections/Pool.js'][114] = 0;
  _$jscoverage['collections/Pool.js'][115] = 0;
  _$jscoverage['collections/Pool.js'][116] = 0;
  _$jscoverage['collections/Pool.js'][117] = 0;
  _$jscoverage['collections/Pool.js'][118] = 0;
  _$jscoverage['collections/Pool.js'][119] = 0;
  _$jscoverage['collections/Pool.js'][123] = 0;
  _$jscoverage['collections/Pool.js'][127] = 0;
  _$jscoverage['collections/Pool.js'][128] = 0;
  _$jscoverage['collections/Pool.js'][129] = 0;
  _$jscoverage['collections/Pool.js'][130] = 0;
  _$jscoverage['collections/Pool.js'][131] = 0;
  _$jscoverage['collections/Pool.js'][132] = 0;
  _$jscoverage['collections/Pool.js'][133] = 0;
  _$jscoverage['collections/Pool.js'][136] = 0;
  _$jscoverage['collections/Pool.js'][144] = 0;
  _$jscoverage['collections/Pool.js'][147] = 0;
  _$jscoverage['collections/Pool.js'][150] = 0;
  _$jscoverage['collections/Pool.js'][155] = 0;
  _$jscoverage['collections/Pool.js'][158] = 0;
}
_$jscoverage['collections/Pool.js'][1]++;
var define = require("../define").define, Collection = require("./Collection"), Queue = require("./Queue"), base = require("../base");
_$jscoverage['collections/Pool.js'][19]++;
exports = module.exports = define(null, {instance: {__minObjects: 0, __maxObjects: 1, constructor: (function (options) {
  _$jscoverage['collections/Pool.js'][28]++;
  options = options || {};
  _$jscoverage['collections/Pool.js'][29]++;
  this.__freeObjects = new Queue();
  _$jscoverage['collections/Pool.js'][30]++;
  this.__inUseObjects = [];
  _$jscoverage['collections/Pool.js'][31]++;
  this.__minObjects = options.minObjects || 0;
  _$jscoverage['collections/Pool.js'][32]++;
  this.__maxObjects = options.maxObjects || 1;
  _$jscoverage['collections/Pool.js'][33]++;
  this.minObjects = this.__minObjects;
  _$jscoverage['collections/Pool.js'][34]++;
  this.maxObjects = this.__maxObjects;
}), getObject: (function () {
  _$jscoverage['collections/Pool.js'][43]++;
  var ret = undefined;
  _$jscoverage['collections/Pool.js'][44]++;
  if (this.freeCount > 0) {
    _$jscoverage['collections/Pool.js'][45]++;
    ret = this.__freeObjects.dequeue();
    _$jscoverage['collections/Pool.js'][46]++;
    this.__inUseObjects.push(ret);
  }
  else {
    _$jscoverage['collections/Pool.js'][47]++;
    if (this.__maxObjects > this.count) {
      _$jscoverage['collections/Pool.js'][48]++;
      ret = this.createObject();
      _$jscoverage['collections/Pool.js'][49]++;
      this.__inUseObjects.push(ret);
    }
  }
  _$jscoverage['collections/Pool.js'][51]++;
  return ret;
}), returnObject: (function (obj) {
  _$jscoverage['collections/Pool.js'][60]++;
  if (this.validate(obj) && this.count <= this.__maxObjects) {
    _$jscoverage['collections/Pool.js'][61]++;
    this.__freeObjects.enqueue(obj);
    _$jscoverage['collections/Pool.js'][62]++;
    var index;
    _$jscoverage['collections/Pool.js'][63]++;
    if ((index = this.__inUseObjects.indexOf(obj)) > -1) {
      _$jscoverage['collections/Pool.js'][64]++;
      this.__inUseObjects.splice(index, 1);
    }
  }
  else {
    _$jscoverage['collections/Pool.js'][66]++;
    this.removeObject(obj);
  }
}), removeObject: (function (obj) {
  _$jscoverage['collections/Pool.js'][79]++;
  var index;
  _$jscoverage['collections/Pool.js'][80]++;
  if (this.__freeObjects.contains(obj)) {
    _$jscoverage['collections/Pool.js'][81]++;
    this.__freeObjects.remove(obj);
  }
  else {
    _$jscoverage['collections/Pool.js'][82]++;
    if ((index = this.__inUseObjects.indexOf(obj)) > -1) {
      _$jscoverage['collections/Pool.js'][83]++;
      this.__inUseObjects.splice(index, 1);
    }
  }
  _$jscoverage['collections/Pool.js'][86]++;
  return obj;
}), validate: (function (obj) {
  _$jscoverage['collections/Pool.js'][97]++;
  return true;
}), createObject: (function () {
  _$jscoverage['collections/Pool.js'][108]++;
  return ({});
}), setters: {minObjects: (function (l) {
  _$jscoverage['collections/Pool.js'][114]++;
  if (l <= this.__maxObjects) {
    _$jscoverage['collections/Pool.js'][115]++;
    this.__minObjects = l;
    _$jscoverage['collections/Pool.js'][116]++;
    var i;
    _$jscoverage['collections/Pool.js'][117]++;
    if ((i = this.count) < l) {
      _$jscoverage['collections/Pool.js'][118]++;
      while (i++ < l) {
        _$jscoverage['collections/Pool.js'][119]++;
        this.__freeObjects.enqueue(this.createObject());
}
    }
  }
  else {
    _$jscoverage['collections/Pool.js'][123]++;
    throw "comb.collections.Pool : minObjects cannot be greater than maxObjects.";
  }
}), maxObjects: (function (l) {
  _$jscoverage['collections/Pool.js'][127]++;
  if (l >= this.__minObjects) {
    _$jscoverage['collections/Pool.js'][128]++;
    this.__maxObjects = l;
    _$jscoverage['collections/Pool.js'][129]++;
    var i = this.count, j = this.freeCount, fo = this.__freeObjects;
    _$jscoverage['collections/Pool.js'][130]++;
    while (i > l && j >= 0) {
      _$jscoverage['collections/Pool.js'][131]++;
      this.removeObject(fo.dequeue());
      _$jscoverage['collections/Pool.js'][132]++;
      j--;
      _$jscoverage['collections/Pool.js'][133]++;
      i--;
}
  }
  else {
    _$jscoverage['collections/Pool.js'][136]++;
    throw "comb.collections.Pool : maxObjects cannot be less than maxObjects.";
  }
})}, getters: {freeCount: (function () {
  _$jscoverage['collections/Pool.js'][144]++;
  return this.__freeObjects.count;
}), inUseCount: (function () {
  _$jscoverage['collections/Pool.js'][147]++;
  return this.__inUseObjects.length;
}), count: (function () {
  _$jscoverage['collections/Pool.js'][150]++;
  return this.__freeObjects.count + this.__inUseObjects.length;
}), minObjects: (function () {
  _$jscoverage['collections/Pool.js'][155]++;
  return this.__minObjects;
}), maxObjects: (function () {
  _$jscoverage['collections/Pool.js'][158]++;
  return this.__maxObjects;
})}}});
_$jscoverage['collections/Pool.js'].source = ["var define = require(\"../define\").define,","        Collection = require(\"./Collection\"),","        Queue = require(\"./Queue\"),","        base = require(\"../base\");","","/**"," * @class Base class for a pool."," *"," * @name Pool"," * @memberOf comb.collections"," *"," * @property {Number} count the total number of objects in the pool, including free and in use objects."," * @property {Number} freeCount the number of free objects in this pool."," * @property {Number} inUseCount the number of objects in use in this pool."," * @property {Number} [minObjects=0] the minimum number of objects this pool should contain."," * @property {Number} [maxObjects=1] the maximum number of objects this pool should contain",""," */","exports = module.exports = define(null, {","    instance : {","        /**@lends comb.collections.Pool.prototype*/","","        __minObjects : 0,","","        __maxObjects : 1,","","        constructor : function(options) {","            options = options || {};","            this.__freeObjects = new Queue();","            this.__inUseObjects = [];","            this.__minObjects = options.minObjects || 0;","            this.__maxObjects = options.maxObjects || 1;","            this.minObjects = this.__minObjects;","            this.maxObjects = this.__maxObjects;","        },","","        /**","         * Retrieves an object from this pool.","         * `","         * @return {*} an object to contained in this pool","         */","        getObject : function() {","            var ret = undefined;","            if (this.freeCount &gt; 0) {","                ret = this.__freeObjects.dequeue();","                this.__inUseObjects.push(ret);","            } else if (this.__maxObjects &gt; this.count) {","                ret = this.createObject();","                this.__inUseObjects.push(ret);","            }","            return ret;","        },","","        /**","         * Returns an object to this pool. The object is validated before it is returned to the pool,","         * if the validation fails then it is removed from the pool;","         * @param {*} obj the object to return to the pool","         */","        returnObject : function(obj) {","            if (this.validate(obj) &amp;&amp; this.count &lt;= this.__maxObjects) {","                this.__freeObjects.enqueue(obj);","                var index;","                if ((index = this.__inUseObjects.indexOf(obj)) &gt; -1)","                    this.__inUseObjects.splice(index, 1);","            } else {","                this.removeObject(obj);","            }","        },","","        /**","         * Removes an object from the pool, this can be overriden to provide any","         * teardown of objects that needs to take place.","         *","         * @param {*} obj the object that needs to be removed.","         *","         * @return {*} the object removed.","         */","        removeObject : function(obj) {","            var index;","            if (this.__freeObjects.contains(obj)) {","                this.__freeObjects.remove(obj);","            } else if ((index = this.__inUseObjects.indexOf(obj)) &gt; -1) {","                this.__inUseObjects.splice(index, 1);","            }","            //otherwise its not contained in this pool;","            return obj;","        },","","        /**","         * Validates an object in this pool.","         * &lt;/br&gt;","         * &lt;b&gt;THIS SHOULD BE OVERRIDDEN TO VALIDATE&lt;/b&gt;","         *","         * @param {*} obj the object to validate.","         */","        validate : function(obj) {","            return true;","        },","","        /**","         * Creates a new object for this pool.","         * * &lt;/br&gt;","         * &lt;b&gt;THIS SHOULD BE OVERRIDDEN TO ADD THE CORRECT TYPE OF OBJECT&lt;/b&gt;","         *","         * @return {Object} be default just creates an object.","         */","        createObject : function() {","            return {};","        },","","        setters : {","            minObjects : function(l) {","","                if (l &lt;= this.__maxObjects) {","                    this.__minObjects = l;","                    var i;","                    if ((i = this.count) &lt; l) {","                        while (i++ &lt; l) {","                            this.__freeObjects.enqueue(this.createObject());","                        }","                    }","                } else {","                    throw \"comb.collections.Pool : minObjects cannot be greater than maxObjects.\";","                }","            },","            maxObjects : function(l) {","                if (l &gt;= this.__minObjects) {","                    this.__maxObjects = l;","                    var i = this.count, j = this.freeCount, fo = this.__freeObjects;","                    while (i &gt; l &amp;&amp; j &gt;= 0) {","                        this.removeObject(fo.dequeue());","                        j--;","                        i--;","                    }","                } else {","                    throw \"comb.collections.Pool : maxObjects cannot be less than maxObjects.\";","                }","","            }","        },","","        getters : {","            freeCount : function() {","                return this.__freeObjects.count;","            },","            inUseCount : function() {","                return this.__inUseObjects.length;","            },","            count : function() {","                return  this.__freeObjects.count + this.__inUseObjects.length;","","            },","","            minObjects : function() {","                return this.__minObjects;","            },","            maxObjects : function() {","                return this.__maxObjects;","            }","        }","    }","})"];
