Skip to content

Instantly share code, notes, and snippets.

@niklasfi
Created February 3, 2011 20:42
Show Gist options
  • Save niklasfi/810154 to your computer and use it in GitHub Desktop.
Save niklasfi/810154 to your computer and use it in GitHub Desktop.
/* John Resig's array.remove taken from http://ejohn.org/blog/javascript-array-remove/ */
Array.prototype.remove = function(from, to) {
var rest = this.slice((to || from) + 1 || this.length);
this.length = from < 0 ? this.length + from : from;
return this.push.apply(this, rest);
};
var ticket = function(id){this.id=id}
var ticketlist = function(){ this.q = [] , this.all= {}}
ticketlist.prototype.add = function(id){var t = ticket(id); this.q.push(t); this.all[id]=t;}
ticketlict.prototype.delticket = function(t){
//what do i have to do if i want to delete a ticket? the options are:
delete this.all[t.id]
this.remove(this.q.indexOf(t))
delete t
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment