function Collection() { this.List = new Array(); this.Count = 0; return; }
Collection.prototype.GetType = function() { return 'Collection'; }
Collection.prototype.ToString = function() { return this.List.InternalToString(this.GetType()); }
Collection.prototype.toString = function() { return this.ToString(); }
Collection.prototype.Equals = function(p_object) { return this == p_object; }
Collection.prototype.CompareTo = function(p_object) { return 0; }
Collection.prototype.Item = function(p_index, p_value) { if(p_index < this.Count && p_index >= 0) { if(arguments.length == 1) { return this.List[p_index]; } else { this.List[p_index] = p_value; return; } } throw Exception('The specified index of ' + p_index + ' is not within the bounds of the collection.'); }
Collection.prototype.IndexOf = function(p_value) { for(var i = 0; i < this.Count; i++) { if(this.CompareFunction(p_value, this.List[i]) == 0) { return i; } } return -1; }
Collection.prototype.Contains = function(p_value) { return this.IndexOf(p_value) >= 0; }
Collection.prototype.Add = function(p_value) { if(!this.Contains(p_value)) { this.List.push(p_value); this.Count++; return this.Count - 1; } return -1; }
Collection.prototype.RemoveAt = function(p_index) { this.List.RemoveAt(p_index); this.Count = this.List.length; return; }
Collection.prototype.Remove = function(p_value) { this.RemoveAt(this.IndexOf(p_value)); return; }
Collection.prototype.Clear = function() { this.List.Clear(); this.Count = 0; return; }
Collection.prototype.Sort = function() { this.List.sort(this.CompareFunction); return; }
Collection.prototype.CompareFunction = function(p_left, p_right) { return p_left === p_right ? 0 : (p_left < p_right ? -1 : 1); }