home *** CD-ROM | disk | FTP | other *** search
/ Minami 83 / MINAMI83.iso / Extra / DivXInstaller.exe / $PLUGINSDIR / GoogleToolbarFirefox.msi / xpi / amulet-jslib / google3 / listdictionary.js < prev    next >
Text File  |  2006-08-07  |  827b  |  32 lines

  1. function ListDictionary(name) {
  2. this.name_ = name;
  3. this.members_ = [];
  4. }
  5. ListDictionary.prototype.isMember = function(item) {
  6. for (var i=0; i < this.members_.length; i++)
  7. if (this.members_[i] == item)
  8. return true;
  9. return false;
  10. }
  11. ListDictionary.prototype.addMember = function(item) {
  12. this.members_.push(item);
  13. }
  14. ListDictionary.prototype.removeMember = function(item) {
  15. for (var i=0; i < this.members_.length; i++) {
  16. if (this.members_[i] == item) {
  17. for (var j=i; j < this.members_.length; j++)
  18. this.members_[j] = this.members_[j+1];
  19. this.members_.length--;
  20. return true;
  21. }
  22. }
  23. return false;
  24. }
  25. ListDictionary.prototype.forEach = function(func) {
  26. if (typeof func != "function")
  27. throw new Error("argument to forEach is not a function, it's a(n) " +
  28. typeof func);
  29. for (var i=0; i < this.members_.length; i++)
  30. func(this.members_[i]);
  31. }
  32.