- Add a warning about quicksort being stable only with some

operators


git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1066 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-09-08 15:09:36 +00:00
parent b065d0f099
commit aedac205ea
1 changed files with 8 additions and 2 deletions

View File

@ -109,11 +109,11 @@ class CPUPolicy:
# @code # @code
# # As a lambda anonymous function (preferred) # # As a lambda anonymous function (preferred)
# # (x and y are two DynamicSchedulable objects) # # (x and y are two DynamicSchedulable objects)
# cmpf = lambda x,y: x.someProperty() < y.someProperty() # cmpf = lambda x,y: x.someProperty() <= y.someProperty()
# #
# # As a normal *global* function # # As a normal *global* function
# def compare(a,b): # def compare(a,b):
# return a.someProperty < b.someProperty() # return a.someProperty <= b.someProperty()
# cmpf = compare # cmpf = compare
# @endcode # @endcode
# #
@ -124,6 +124,12 @@ class CPUPolicy:
# self.sort(queue, cmpf) # self.sort(queue, cmpf)
# @endcode # @endcode
# #
# Since queue.sort() uses a in-place version of the
# quicksort algorithm, note the effect of using "<"
# instead than "<=": quicksort wouldn't be stable anymore.
# You have been warned. If your policy behaves strangely,
# this may be the cause.
#
# @param self The object caller # @param self The object caller
# @param queue The ReadyQueue to be sorted in place # @param queue The ReadyQueue to be sorted in place
# @param cmpf The binary function to use to compare elements # @param cmpf The binary function to use to compare elements