2010-02-24 19:16:57 -05:00
|
|
|
|
|
|
|
__author__="bjschuma"
|
|
|
|
__date__ ="$Feb 22, 2010 10:52:13 PM$"
|
|
|
|
|
|
|
|
|
|
|
|
# This is a sorted list (as long as items are inserted with add() )
|
2010-02-24 22:53:26 -05:00
|
|
|
class Slist(list):
|
2010-02-24 19:16:57 -05:00
|
|
|
def __init__(self):
|
|
|
|
list.__init__(self)
|
|
|
|
|
|
|
|
|
2010-02-24 22:53:26 -05:00
|
|
|
def add(self, item, priority):
|
|
|
|
self += [(priority,item)]
|
2010-02-24 19:16:57 -05:00
|
|
|
self.sort()
|
|
|
|
|
2010-02-24 22:53:26 -05:00
|
|
|
|
|
|
|
def remove(self, item):
|
|
|
|
for tuple in self:
|
|
|
|
if tuple[1] == item:
|
|
|
|
list.remove(self,tuple)
|
|
|
|
break
|
|
|
|
|