Skip to content

Instantly share code, notes, and snippets.

@AravinthVelusamy
Last active May 17, 2020 16:05
Show Gist options
  • Select an option

  • Save AravinthVelusamy/bf7c0a96d4568df732fb7735b0dae9a2 to your computer and use it in GitHub Desktop.

Select an option

Save AravinthVelusamy/bf7c0a96d4568df732fb7735b0dae9a2 to your computer and use it in GitHub Desktop.

Revisions

  1. Aravinth Velusamy revised this gist May 17, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions HeaderIndexer.kt
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    /**
    * Find the first block of each day (rounded down to nearest day) and return pairs of
    * index to start time. Assumes that [agendaItems] are sorted by ascending start time.
    * Find the first league of each set and return pairs of
    * index to league name. Assumes that clubs are sorted by ascending league name.
    */
    fun indexAgendaHeaders(agendaItems: List<ClubEntity>): List<Pair<Int, String>> {
    return agendaItems
  2. Aravinth Velusamy created this gist May 17, 2020.
    9 changes: 9 additions & 0 deletions HeaderIndexer.kt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    /**
    * Find the first block of each day (rounded down to nearest day) and return pairs of
    * index to start time. Assumes that [agendaItems] are sorted by ascending start time.
    */
    fun indexAgendaHeaders(agendaItems: List<ClubEntity>): List<Pair<Int, String>> {
    return agendaItems
    .mapIndexed { index, block -> index to block.clubLeague }
    .distinctBy { it.second }
    }