- Previous segmentation fault was due to a faulty call (wrong parameters

to ScriptAdapter.__wrap_sort_queue()). Now prints an error and check
for retval before Py_DECREF'ing it.
- Fix(?) qsort implementation in Policy
- SWIG doesn't understand "uint". Change into more verbose (but surely
standard) unsigned int


git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@394 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-02-23 10:12:27 +00:00
parent 075e12d14d
commit a2a492b5d5
5 changed files with 28 additions and 26 deletions

View file

@ -1,4 +1,4 @@
from Abstract import *
from Abstract import *
## @brief This is the abstract class a user-defined policy
# should inherit from
@ -28,8 +28,8 @@ class Policy:
# @param queue The SchedulableQueue to be sorted in place
# @param cmpf The binary function to use to compare elements
# @returns None
def sort(queue, cmpf):
__recursive_qsort_(queue, 0, queue.size()-1, cmpf)
def sort(self, queue, cmpf):
self.__recursive_qsort(queue, 0, queue.size()-1, cmpf)
## @brief Recursive (private) call to perform quicksort on a
# queue
@ -39,12 +39,12 @@ class Policy:
# @param b The final element position of the slice
# @param cmpf The user-defined compare function to employ
# @returns None
def __recursive_qsort_(queue, a, b, cmpf):
def __recursive_qsort(self, queue, a, b, cmpf):
if(b>a):
pivot = __partition_(queue, a, b, cmpf)
__recursive_qsort_(queue, a, pivot-1, cmpf)
__recursive_qsort_(queue, pivot+1, b, cmpf)
pivot = self.__partition(queue, a, b, cmpf)
self.__recursive_qsort(queue, a, pivot-1, cmpf)
self.__recursive_qsort(queue, pivot+1, b, cmpf)
## @brief Recursive (private) call to partition a slice of the queue
#
# This private function (the name mangling should work)
@ -58,11 +58,11 @@ class Policy:
# @param b The partition ending element position in the queue
# @param cmpf The binary function to use for comparing two elements
# @return The new pivot index
def __partition_(queue, a, b, cmpf):
def __partition_(self, queue, a, b, cmpf):
# takes pivot element:
right = queue.get_item_at(b)
i = a
for j in range(a,b-1):
for j in range(a,b): # goes from a to b-1
if cmpf(queue.get_item_at(j), right):
# the C++ code should do nothing if i == j:
queue.swap(i,j)