Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge remote-tracking branch 'asbupstream/develop' into use-internal-…

…queue

Conflicts:
	.gitignore
  • Loading branch information...
commit 6a1ff2f37283cc2f19034615b1511f1530636ee5 2 parents 86ce78c + 57b6b94
@fjcapdevila fjcapdevila authored
Showing with 10 additions and 7 deletions.
  1. +3 −0  .gitignore
  2. +7 −7 simpleai/search/utils.py
View
3  .gitignore
@@ -28,3 +28,6 @@ pip-log.txt
# Emacs backups
*.*~
+# Idea files/directory
+.idea
+*.iml
View
14 simpleai/search/utils.py
@@ -11,18 +11,18 @@ def pop(self):
return super(FifoList, self).popleft()
-class BoundedPriorityQueue(list):
+class BoundedPriorityQueue(object):
def __init__(self, limit=None, *args):
self.limit = limit
- super(BoundedPriorityQueue, self).__init__(*args)
+ self.queue = list()
def append(self, x):
- heapq.heappush(self, x)
- if self.limit and len(self) > self.limit:
- self.remove(heapq.nlargest(1, self)[0])
+ heapq.heappush(self.queue, x)
+ if self.limit and len(self.queue) > self.limit:
+ self.queue.remove(heapq.nlargest(1, self.queue)[0])
def pop(self):
- return heapq.heappop(self)
+ return heapq.heappop(self.queue)
def extend(self, iterable):
for x in iterable:
@@ -30,7 +30,7 @@ def extend(self, iterable):
def clear(self):
for x in self:
- self.remove(x)
+ self.queue.remove(x)
class InverseTransformSampler(object):
Please sign in to comment.
Something went wrong with that request. Please try again.