How do you create two priority arrays of queues in java? / Linux constant time scheduler -


this step in assignment , seems easy, seems little confusing me. great considering thing due tomorrow. code format response great. here step:

you need create 2 priority arrays of queues: active array , expired array. in our case simplify , have priority values of 0 4, i.e. active array , expired array each comprised of 5 queues.

the java class priorityqueue, not "priority array". think misunderstood assignment.

let's suppose have object priority value, , we'll leave out restriction here. can put in on own.

public class task {     private integer priority;  // let's not have priorities change accident.     private string name;     private double cost;     // constructors, getters, setters elided. } 

now, priorityqueue needs of comparable class or made comparator. let's use latter, since i'm assuming equal priorities equally weighted, , there's no natural ordering of task.

public class taskcomparator implements comparator<task> {     public int compare(task left, task right) {         return left.getpriority() - right.getpriority();         // because numbers limited.      } } 

you can create priorityqueue of tasks with

priorityqueue<task> active = new priorityqueue<task>(10, new taskcomparator()); 

what own lookout.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -