package Ġx er us . music . mix xx Ċ Ċ import Ġx er us . music . mix xx . data .* Ċ Ċ fun ĠMix xx DB . get Tracks Indexed () Ġ= Ġget Library (). associate By Ġ{ Ġit . id Ġ} Ċ Ċ fun ĠMix xx DB . get Track Locations Indexed () Ġ= Ġget Track Locations (). associate By Ġ{ Ġit . id Ġ} Ċ Ċ fun ĠMix xx DB . get Cr ates Indexed () Ġ= Ġget Cr ates (). associate By Ġ{ Ġit . id Ġ} Ċ Ċ fun ĠMix xx DB . get Play lists Indexed () Ġ= Ġget Play lists (). associate By Ġ{ Ġit . id Ġ} Ċ Ċ /** ĠReturns Ġa ĠMap Ġcontaining Ġthe Ġid Ġof Ġall ĠCr ates Ġand Ġthe ĠTrack s Ġthat Ġbelong Ġto Ġthem Ġ*/ Ċ fun ĠMix xx DB . crate Ids To Tracks (): ĠMap < Long , ĠList < Track >> Ġ{ Ċ ĉ val Ġtracks Ġ= Ġget Tracks Indexed () Ċ ĉ val Ġcrate Tracks Ġ= ĠgetC rate Tracks () Ċ ĉ val Ġcr ates Ġ= Ġget Cr ates () Ċ ĉ val Ġids To Tracks Ġ= ĠHashMap < Long , ĠArrayList < Track >>( crates . size ) Ċ ĉ crates . forEach Ġ{ Ġcrate Ġ-> Ġids To Tracks [ crate . id ] Ġ= ĠArrayList () Ġ} Ċ ĉ crate Tracks . forEach Ġ{ Ġtrack Id , Ġcrate Id Ġ-> Ċĉ ĉ ids To Tracks [ crate Id ] !!. add ( tracks [ track Id ] !! ) Ċ ĉ } Ċ ĉ return Ġids To Tracks Ċ } Ċ Ċ /** ĠReturns Ġa ĠMap Ġcontaining Ġall ĠCr ates Ġand Ġthe ĠTrack s Ġthat Ġbelong Ġto Ġthem Ġ*/ Ċ fun ĠMix xx DB . crates To Tracks (): ĠMap < C rate , ĠList < Track >> Ġ{ Ċ ĉ val Ġcr ates Ġ= Ġget Cr ates Indexed () Ċ ĉ val Ġcr ates To Tracks Ġ= ĠHashMap < C rate , ĠList < Track >>( crates . size ) Ċ ĉ crate Ids To Tracks (). forEach Ġ{ Ġcrate Id , Ġtrack List Ġ-> Ċĉ ĉ crates To Tracks [ crates [ crate Id ] !! ] Ġ= Ġtrack List Ċ ĉ } Ċ ĉ return Ġcr ates To Tracks Ċ } Ċ Ċ /** ĠReturns Ġa ĠMap Ġcontaining Ġthe Ġid Ġof Ġall ĠPlay lists Ġand Ġthe ĠPlaylist Tracks Ġthat Ġbelong Ġto Ġthem Ġ*/ Ċ fun ĠMix xx DB . playlist Ids To Track Ids (): ĠMap < Long , ĠList < Playlist Track >> Ġ{ Ċ ĉ val Ġplaylist Tracks Ġ= Ġget Playlist Tracks () Ċ ĉ val Ġplay lists Ġ= Ġget Play lists () Ċ ĉ val Ġids ToList Ġ= ĠHashMap < Long , ĠArrayList < Playlist Track >>( play lists . size ) Ċ ĉ play lists . forEach Ġ{ Ġcrate Ġ-> Ġids ToList [ crate . id ] Ġ= ĠArrayList () Ġ} Ċ ĉ playlist Tracks . forEach Ġ{ Ġplaylist Track Ġ-> Ċĉ ĉ ids ToList [ playlist Track . playlist Id ]?. add ( playlist Track ) Ċ ĉ } Ċ ĉ return Ġids ToList Ċ } Ċ Ċ /** ĠReturns Ġa ĠMap Ġcontaining Ġthe Ġid Ġof Ġall ĠPlay lists Ġand Ġthe ĠTrack s Ġthat Ġbelong Ġto Ġthem Ġin Ġtheir Ġcorrect Ġorder Ġ*/ Ċ fun ĠMix xx DB . playlist Ids To Tracks (): ĠMap < Long , ĠList < Track >> Ġ{ Ċ ĉ val Ġtracks Ġ= Ġget Tracks Indexed () Ċ ĉ val Ġids ToList Ġ= Ġplaylist Ids To Track Ids () Ċ ĉ val Ġids ToList Sorted Ġ= ĠHashMap < Long , ĠList < Track >>( ids ToList . size ) Ċ ĉ ids ToList . forEach Ġ{ Ġid , Ġtrack List Ġ-> Ċĉ ĉ ids ToList Sorted [ id ] Ġ= Ġtrack List . sorted (). map NotNull Ġ{ Ġtracks [ it . track Id ] Ġ} Ċ ĉ } Ċ ĉ return Ġids ToList Sorted Ċ } Ċ Ċ /** ĠReturns Ġa ĠMap Ġcontaining Ġall ĠPlay lists Ġand Ġthe ĠTrack s Ġthat Ġbelong Ġto Ġthem Ġin Ġtheir Ġcorrect Ġorder Ġ*/ Ċ fun ĠMix xx DB . play lists To Tracks (): ĠMap < Playlist , ĠList < Track >> Ġ{ Ċ ĉ val Ġplay lists Ġ= Ġget Play lists Indexed () Ċ ĉ val Ġplay lists To Tracks Ġ= ĠHashMap < Playlist , ĠList < Track >>( play lists . size ) Ċ ĉ playlist Ids To Tracks (). forEach Ġ{ Ġplaylist Id , Ġtrack List Ġ-> Ċĉ ĉ play lists To Tracks [ play lists [ playlist Id ] !! ] Ġ= Ġtrack List Ċ ĉ } Ċ ĉ return Ġplay lists To Tracks Ċ } Ċ Ċ fun ĠMix xx DB . get Track Ids To C ues (): ĠMap < Long , ĠList < C ue >> Ġ{ Ċ ĉ val Ġc ues Ġ= ĠgetC ues () Ċ ĉ val Ġmap Ġ= ĠHashMap < Long , ĠArrayList < C ue >>() Ċ ĉ c ues . forEach Ġ{ Ċĉ ĉ map . get Or Put ( it . track Id ) Ġ{ ĠArrayList () Ġ}. add ( it ) Ċ ĉ } Ċ ĉ return Ġmap Ċ } Ċ Ċ fun ĠMix xx DB . get Track sTo C ues (): ĠMap < Track , ĠList < C ue >> Ġ{ Ċ ĉ val Ġtracks Ġ= Ġget Tracks Indexed () Ċ ĉ val Ġmap Ġ= ĠHashMap < Track , ĠList < C ue >>() Ċ ĉ get Track Ids To C ues (). forEach Ġ{ Ġid , Ġc ues Ġ-> Ċĉ ĉ tracks [ id ]?. let Ġ{ Ġmap . put ( it , Ġc ues ) Ġ} Ċ ĉ } Ċ ĉ return Ġmap Ċ }