/**
 * Array extensions - by Jakob Kruse <kruse@kruse-net.dk>
 *
 * $Id: ArrayX.js,v 1.1 2006/03/02 20:16:59 Jakob Kruse Exp $
 */

// Finds the index of the first occurence of item in the array, or -1 if not found
Array.prototype.indexOf = function (item) {
  for (var i = 0; i < this.length; i++) {
    if (this[i] == item) {
      return i;
    }
  }
  return -1;
};

// Returns an array of items judged true by the passed in test function
Array.prototype.filter = function (test) {
  var matches = [];
  for (var i = 0; i < this.length; i++) {
    if (test(this[i])) {
      matches[matches.length] = this[i];
    }
  }
  return matches;
};

// EOF

