Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added stream code #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
32 changes: 32 additions & 0 deletions src/compiler/token/TokenCustom.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,36 @@ public TokenType tokenType() {
public T data() {
return data;
}

//public String findConflicts() {
// Stream<Tuple<Room, List<String>>> roomConf
// = Room.getRooms().parallelStream().map(room->new Tuple<Room, List<String>>(room,
// Stream.of(Block.blocks).parallel().map(
// block->new Tuple<Block, List<Section>>(
// block,
// sections.parallelStream().filter(section->room.equals(locations.get(section))
// && block.equals(timings.get(section))).collect(Collectors.toList())
// )
// ).filter(tuple->tuple.b.size() > 1).
// map(tuple->"\"In room " + room + " during " + tuple.a + ", there are classes " + tuple.b + "\"").
// collect(Collectors.toList()))
// ).filter(tuple->!tuple.b.isEmpty());
// Stream<Tuple<Teacher, List<String>>> teacherConf = teacherList.parallelStream().map(teacher->new Tuple<Teacher, List<String>>(teacher,
// Stream.of(Block.blocks).parallel().map(
// block->new Tuple<Block, List<Section>>(
// block,
// sections.parallelStream().filter(section->teacher.equals(teachers.get(section)) && block.equals(timings.get(section))).collect(Collectors.toList())
// )
// ).filter(tuple->tuple.b.size() > 1).map(tuple->"\"Teacher " + teacher + " during " + tuple.a + " is teaching classes " + tuple.b + "\"").collect(Collectors.toList()))
// ).filter(tuple->!tuple.b.isEmpty());
// String roomConflicts = roomConf.map(tuple->"\n\"" + tuple.a + "\":" + tuple.b).collect(Collectors.joining(",", "{", "}"));
// String teacherConflicts = teacherConf.map(tuple->"\n\"" + tuple.a + "\":" + tuple.b).collect(Collectors.joining(",", "{", "}"));
// Stream<Tuple<Student, List<String>>> studentConf = students.stream().map(student->{
// Map<Block, List<Section>> map = roster.getSections(student).stream().collect(Collectors.groupingBy(section->timings.get(section)));
// List<String> conf = Stream.of(Block.blocks).map(block->new Tuple<Block, List<Section>>(block, map.get(block))).filter(tuple->tuple.b != null && tuple.b.size() > 1).map(tuple->"\"Student " + student + " during " + tuple.a + " is in classes " + tuple.b + "\"").collect(Collectors.toList());
// return new Tuple<Student, List<String>>(student, conf);
// }).filter(tuple->!tuple.b.isEmpty());
// String studentConflicts = studentConf.map(tuple->"\n\"" + tuple.a + "\":" + tuple.b).collect(Collectors.joining(",", "{", "}"));
// return "{room:" + roomConflicts + ",\nteacher:" + teacherConflicts + ",\nstudent:" + studentConflicts + "}";
// }
}