Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
2 changes: 1 addition & 1 deletion src/Bins.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

//Hello World!
/**
* Runs a number of algorithms that try to fit files onto disks.
*/
Expand Down
15 changes: 14 additions & 1 deletion src/Disk.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.AbstractMap.SimpleEntry;
import java.util.Map.Entry;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
* Represents a collection of files; how many it can hold is limited by its capacity.
Expand Down Expand Up @@ -57,6 +62,7 @@ public String toString () {
for (int k = 0; k < myFiles.size(); k++) {
result += " " + myFiles.get(k);
}
fitDiskAndPrint(myFiles, (input) -> input.stream().sorted().collect(Collectors.toList()));
return result;
}

Expand Down Expand Up @@ -103,4 +109,11 @@ public int compareTo (Disk other) {
return -1;
}
}
}

public static void fitDiskAndPrint(List<Integer> list, Function<List<Integer>, List<Integer>> func){
//list.stream().sorted().collect(Collectors.toList());

List<Integer> transformed = func.apply(list);
transformed.forEach(System.out::println);
}
}