- 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
This commit is contained in:
tchernobog 2006-02-22 21:35:26 +00:00
parent eecb9f109f
commit 47451bf78d
3 changed files with 34 additions and 0 deletions

View File

@ -1,5 +1,22 @@
from Abstract import * 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: class Policy:
## @var Avoid instantiation of an abstract class ## @var Avoid instantiation of an abstract class
__metaclass__ = Metaclass __metaclass__ = Metaclass

View File

@ -50,6 +50,22 @@ namespace sgpem
SchedulableStatus* get_item_at(const uint&); SchedulableStatus* get_item_at(const uint&);
const SchedulableStatus* get_item_at(const uint&) const; const SchedulableStatus* get_item_at(const uint&) const;
void clear(); 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: private:
std::list<SchedulableStatus> _list; std::list<SchedulableStatus> _list;
}; };

View File

@ -132,6 +132,7 @@ namespace sgpem {
uint size() const; uint size() const;
SchedulableStatus* get_item_at(const uint&); SchedulableStatus* get_item_at(const uint&);
const SchedulableStatus* get_item_at(const uint&) const; const SchedulableStatus* get_item_at(const uint&) const;
void swap(unsigned int positionA, unsigned int positionB) throw();
private: private:
// Avoid instantiation and copy // Avoid instantiation and copy