package scheduler;

import os.OperatingSystem;
import readinstruction.ReadInstruction;

import java.util.LinkedList;
import java.util.Queue;

/**
 * Created by Karol Pokomeda on 2017-04-21.
 */
public class ScanScheduler implements Scheduler {
    private Queue<ReadInstruction> waitingQueue;
    private OperatingSystem parentOs;
    private int headPosition;

    public ScanScheduler(){
        this.waitingQueue = new LinkedList<>();
        this.headPosition = 0;
    }

    @Override
    public void update(int time) {

    }

    @Override
    public void setOs(OperatingSystem parentOs) {
        this.parentOs = parentOs;
    }

    @Override
    public void push(ReadInstruction instruction) {
        this.waitingQueue.add(instruction);
    }

    @Override
    public String getName() {
        return "SCAN";
    }

    @Override
    public boolean isEmpty() {
        return this.waitingQueue.isEmpty();
    }
}

@@ -249,21 +249,26 @@
 private 
-Queue
+LinkedList
 %3CReadIns
@@ -701,32 +701,52 @@
 ction) %7B%0A       
+ if (this.isEmpty())
  this.waitingQue
@@ -766,16 +766,213 @@
 ction);%0A
+        else %7B%0A            int i = 0;%0A            while (instruction.getReadAddress() %3C this.waitingQueue.get(i).getReadAddress()) i++;%0A            this.waitingQueue.add(i, instruction);%0A        %7D%0A
     %7D%0A%0A 
@@ -1139,10 +1139,9 @@
 ;%0A    %7D%0A
+
 %7D
-%0A

Reimplement push method for ScanScheduler to incorporate sorted storage of elements;