12.11.2014 Views

PRV Zadaci - Programiranje u Realnom Vremenu

PRV Zadaci - Programiranje u Realnom Vremenu

PRV Zadaci - Programiranje u Realnom Vremenu

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Implementacija<br />

Implementacija se oslanja na postojeću implementaciju kolekcije.<br />

Da bi kompleksnost obe operacije vraćanja trenutno najprioritetnijeg elementa i operacije umetanja<br />

elementa bila manja od O(n), potrebno je da nijedna od njih ne uključuje linearnu pretragu po eventualno<br />

ureĎenoj listi. Zbog toga ova implementacija sadrži pokazivač na trenutno najprioritetniji element, koji se<br />

ažurira prilikom promene strukture reda ili promene prioriteta nekog elementa.<br />

// Project: Real-Time Programming<br />

// Subject: Data Structures<br />

// Module: Priority Queue<br />

// File: pqueue.h<br />

// Date: October 2002<br />

// Author: Dragan Milicev<br />

// Contents:<br />

// Class:<br />

// PriorityElement<br />

// PriorityQueue<br />

// Type:<br />

// Priority<br />

#ifndef _PQUEUE_<br />

#define _PQUEUE_<br />

#include "collect.h"<br />

/////////////////////////////////////////////////////////////////////<br />

// class PriorityElement<br />

/////////////////////////////////////////////////////////////////////<br />

typedef unsigned int Priority;<br />

const Priority MinPri = 0;<br />

class PriorityQueue;<br />

class PriorityElement : public CollectionElement {<br />

public:<br />

private:<br />

};<br />

PriorityElement (Object* holder, Priority p = 0)<br />

: CollectionElement(holder), pri(p), container(0) {}<br />

Priority getPriority () { return pri; }<br />

void setPriority (Priority newPri);<br />

PriorityQueue* getContainer () { return container; }<br />

Priority pri;<br />

friend class PriorityQueue;<br />

void setContainer (PriorityQueue* c) { container = c; }<br />

PriorityQueue* container;<br />

20

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!