From 0f0d8d1ebdbc1c318cd1be2b6b324c4327e041ca Mon Sep 17 00:00:00 2001 From: ZD292 Date: Mon, 13 Nov 2023 19:18:28 +0800 Subject: [PATCH] Deleted unused class --- .../java/seedu/address/model/FreeTime.java | 117 ------------------ 1 file changed, 117 deletions(-) delete mode 100644 src/main/java/seedu/address/model/FreeTime.java diff --git a/src/main/java/seedu/address/model/FreeTime.java b/src/main/java/seedu/address/model/FreeTime.java deleted file mode 100644 index d4e6eb89c3b..00000000000 --- a/src/main/java/seedu/address/model/FreeTime.java +++ /dev/null @@ -1,117 +0,0 @@ -package seedu.address.model; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.stream.Stream; - -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; - -/** - * A class representing a free time interval of a group - */ -public class FreeTime implements Iterable { - - private final ObservableList internalList = FXCollections.observableArrayList(); - private final ObservableList internalUnmodifiableList = - FXCollections.unmodifiableObservableList(internalList); - - /** - * Adds a time interval to the list - * @param timeInterval the time interval to add - */ - public void addTime(TimeInterval timeInterval) { - internalList.add(timeInterval); - } - - /** - * Adds a list of time intervals to the list - * @param timeIntervals the list of time intervals to add - */ - public void addTime(ArrayList timeIntervals) { - internalList.addAll(timeIntervals); - } - - /** - * Converts the internal list to streams. - * - * @return Internal list into streams. - */ - public Stream toStream() { - return internalList.stream(); - } - - - /** - * Check whether no time is stored - * - * @return boolean representing whether no time is stored - */ - public boolean isEmpty() { - return internalList.isEmpty(); - } - - - /** - * Generate String representing list of intervals - * - * @param br StringBuilder to store message - * @param format specify Message format - */ - public void getMessage(StringBuilder br, String format) { - int intervalCount = 1; - for (TimeInterval t : this.internalList) { - br.append(br.append(String.format(format, intervalCount, t.toString()))); - intervalCount++; - } - - } - - /** - * Finds the overlap between 2 free times and a duration - * @param otherTime the other free times to compare with - * @param duration the duration of overlap needed - * @return a list of times that there is an overlap in time interval - */ - public FreeTime findOverlap(FreeTime otherTime, Duration duration) { - // 4 steps, sort by start time, min start min end 2 pointers, get overlap, interval >= duration check - this.internalList.sort(TimeInterval::compareStart); - otherTime.internalList.sort(TimeInterval::compareEnd); - FreeTime newFreeTime = new FreeTime(); - - int p1 = 0; - int p2 = 0; - - while (p1 < this.internalList.size() && p2 < otherTime.internalList.size()) { - TimeInterval firstListInterval = this.internalList.get(p1); - TimeInterval secondListInterval = this.internalList.get(p2); - - boolean overLap = firstListInterval.isTimeIntervalOverlapWithTimeInterval(secondListInterval); - // given 2 intervals, return the one with smaller end to increment pointer - TimeInterval intervalWithMaxStart = TimeInterval.getMaxStart(firstListInterval, secondListInterval); - TimeInterval intervalWithMinEnd = TimeInterval.getMinEnd(firstListInterval, secondListInterval); - // store the intersect, 2 steps, get intersect, see if can fit duration - if (overLap) { - TimeInterval intersect = intervalWithMaxStart.getIntersect(intervalWithMinEnd); - if (intersect.allows(duration)) { - newFreeTime.addTime(intersect); - } - } - // increment pointers - if (intervalWithMinEnd.equalStartAndEnd(firstListInterval)) { - p1++; - } else { - p2++; - } - } - - return newFreeTime; - } - - - @Override - public Iterator iterator() { - return this.internalList.iterator(); - } - -}