- Add operator== methods to dynamic schedulables, and in their interfaces too

- Write class ReadyQueue


git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@688 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-07-02 12:44:05 +00:00
parent 9da0ef3137
commit fa06e2f4f1
16 changed files with 112 additions and 12 deletions

View file

@ -18,10 +18,51 @@
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "config.h"
#include "gettext.h"
#include "ready_queue.hh"
using namespace sgpem;
using sgpem::ReadyQueue;
ReadyQueue::~ReadyQueue()
{}
void
ReadyQueue::swap(position a, position b)
throw (std::out_of_range)
{
size_t size = _scheds.size();
if(a > size || b > size)
throw std::out_of_range(_("Trying to access a Schedulable "
"with an index outside of the "
"queue limits."));
if(a == b) return;
Schedulable* temp = _scheds[a];
_scheds[a] = _scheds[b];
_scheds[b] = temp;
}
ReadyQueue::size_t
ReadyQueue::size() const
{
return _scheds.size();
}
sgpem::Schedulable&
ReadyQueue::get_item_at(position index)
throw (std::out_of_range)
{
if(index > size())
throw std::out_of_range(_("Trying to access a Schedulable "
"with an index outside of the "
"queue limits."));
return *(_scheds[index]);
}
void
ReadyQueue::append(Schedulable& schedulable)
{
_scheds.push_back(&schedulable);
}