Java: How do I store a timeline/schedule, location full or empty from time x to y (interval)?

后端 未结 2 1609
囚心锁ツ
囚心锁ツ 2021-01-13 00:11

Some brief background:

I have a java app that\'s used to see when certain locations (classrooms) are in use or not. The user puts a location identifier into a searc

2条回答
  •  天命终不由人
    2021-01-13 00:54

    Sorting is probably the key to your problem here.

    Presumably you have a big collection of all the courses you've scraped. First you'll need to be able to pull out all the courses given a particular location into a new list. You'll want this list to be sorted by the course date. Check out the various sorted collections (e.g. TreeSet). You'll probably also need to make use of a "comparator" to make sure your courses get sorted by their date.

    Once you have that list, it's just a matter of iterating over it and finding the gaps.

提交回复
热议问题