From 47451bf78dd1a0d00e4ad51d736ad8021200622c Mon Sep 17 00:00:00 2001 From: tchernobog Date: Wed, 22 Feb 2006 21:35:26 +0000 Subject: [PATCH] - Add swap() method signature to SchedulableQueue - Export swap() to SWIG - Add sort function (just its documentation, actually, implementation will follow) to Policy.py git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@385 3ecf2c5c-341e-0410-92b4-d18e462d057c --- src/backend/pyloader/Policy.py | 17 +++++++++++++++++ src/backend/schedulable_list.hh | 16 ++++++++++++++++ src/backend/sgpem.i | 1 + 3 files changed, 34 insertions(+) diff --git a/src/backend/pyloader/Policy.py b/src/backend/pyloader/Policy.py index 8f2a2ac..bb7aa34 100644 --- a/src/backend/pyloader/Policy.py +++ b/src/backend/pyloader/Policy.py @@ -1,5 +1,22 @@ from Abstract import * +## @brief this function implements a quicksort in place +# using the SchedulableQueue methods +# +# The compare parameter should be a user defined function +# name returning either True or False, defined like: +# @code +# def compare(SchedulableA,SchedulableB): +# return SchedulableA.someProperty() < SchedulableB.someProperty() +# @endcode +# +# @param queue The SchedulableQueue to be sorted in place +# @param cmp The binary function to use to compare elements +# @returns None +def sort(queue, cmp): + pass + + class Policy: ## @var Avoid instantiation of an abstract class __metaclass__ = Metaclass diff --git a/src/backend/schedulable_list.hh b/src/backend/schedulable_list.hh index 6b3658d..d56fc1e 100644 --- a/src/backend/schedulable_list.hh +++ b/src/backend/schedulable_list.hh @@ -50,6 +50,22 @@ namespace sgpem SchedulableStatus* get_item_at(const uint&); const SchedulableStatus* get_item_at(const uint&) const; void clear(); + + /** \brief This method swaps the element at positionA with + * the one at positionB. + * + * At the present moment, this function shouldn't throw any + * exception, but just do nothing when the parameters don't + * make sense (e.g. positionB > this.size()). + * However, it should work the same either if positionA is greater + * than or less than positionB. + * In the future, this method could throw an OutOfRange exception. + * + * \param positionA The position of the first element to swap + * \param positionB The position of the second element to swap + */ + void swap(unsigned int positionA, unsigned int positionB) throw() {} + private: std::list _list; }; diff --git a/src/backend/sgpem.i b/src/backend/sgpem.i index 4f49015..246cee2 100644 --- a/src/backend/sgpem.i +++ b/src/backend/sgpem.i @@ -132,6 +132,7 @@ namespace sgpem { uint size() const; SchedulableStatus* get_item_at(const uint&); const SchedulableStatus* get_item_at(const uint&) const; + void swap(unsigned int positionA, unsigned int positionB) throw(); private: // Avoid instantiation and copy