// ĠCopyright Ġ 2 0 0 0 - 2 0 2 1 ĠJetBrains Ġs . r . o . ĠUse Ġof Ġthis Ġsource Ġcode Ġis Ġgoverned Ġby Ġthe ĠApache Ġ 2 . 0 Ġlicense Ġthat Ġcan Ġbe Ġfound Ġin Ġthe ĠLICENSE Ġfile . Ċ package Ġcom . intellij . openapi . external System . service . project . manage Ċ Ċ import Ġcom . intellij . openapi . external System . util . Path Prefix TreeMap Ċ import Ġcom . intellij . test Framework . Use ful TestCase Ċ import Ġorg . junit . Test Ċ Ċ class ĠPath Prefix TreeMap Test Ġ: ĠUseful TestCase () Ġ{ ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` test Ġmap Ġfilling `() Ġ{ ĊĠĠĠ Ġval Ġmap Ġ= ĠPath Prefix TreeMap < Int >() ĊĠĠĠ Ġmap [" C :// path / to / my / dir 3 "] Ġ= Ġ 3 0 ĊĠĠĠ Ġmap [" C :// path / to / my / dir 4 "] Ġ= Ġ 1 0 ĊĠĠĠ Ġmap [" C :// path / to / dir 1 "] Ġ= Ġ 1 1 ĊĠĠĠ Ġmap [" C :// path / to / dir 2 "] Ġ= Ġ 2 1 ĊĠĠĠ Ġmap [" C :// path / to / my "] Ġ= Ġ 4 3 ĊĠĠĠ Ġmap [" C :// path "] Ġ= Ġ 1 3 ĊĠĠĠ ĠassertEquals ( 6 , Ġmap . size ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my / dir 1 "], Ġnull ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my / dir 2 "], Ġnull ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my / dir 3 "], Ġ 3 0 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my / dir 4 "], Ġ 1 0 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / dir 1 "], Ġ 1 1 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / dir 2 "], Ġ 2 1 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / dir 3 "], Ġnull ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / dir 4 "], Ġnull ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my "], Ġ 4 3 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path "], Ġ 1 3 ) ĊĠĠĠ ĠassertFalse ( map . contains (" C :// path / to / my / dir 1 ")) ĊĠĠĠ ĠassertFalse ( map . contains (" C :// path / to / my / dir 2 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / my / dir 3 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / my / dir 4 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / dir 1 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / dir 2 ")) ĊĠĠĠ ĠassertFalse ( map . contains (" C :// path / to / dir 3 ")) ĊĠĠĠ ĠassertFalse ( map . contains (" C :// path / to / dir 4 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / my ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path ")) ĊĠĠĠ Ġmap [" C :// path / to / my / dir 1 "] Ġ= Ġ 1 0 ĊĠĠĠ Ġmap [" C :// path / to / my / dir 2 "] Ġ= Ġ 2 0 ĊĠĠĠ Ġmap [" C :// path / to / dir 3 "] Ġ= Ġ 3 0 ĊĠĠĠ Ġmap [" C :// path / to / dir 4 "] Ġ= Ġ 1 1 ĊĠĠĠ ĠassertEquals ( 1 0 , Ġmap . size ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my / dir 1 "], Ġ 1 0 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my / dir 2 "], Ġ 2 0 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my / dir 3 "], Ġ 3 0 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my / dir 4 "], Ġ 1 0 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / dir 1 "], Ġ 1 1 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / dir 2 "], Ġ 2 1 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / dir 3 "], Ġ 3 0 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / dir 4 "], Ġ 1 1 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my "], Ġ 4 3 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path "], Ġ 1 3 ) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / my / dir 1 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / my / dir 2 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / my / dir 3 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / my / dir 4 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / dir 1 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / dir 2 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / dir 3 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / dir 4 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / my ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path ")) ĊĠĠĠ ĠassertEquals ( set Of ( 1 0 , Ġ 2 0 , Ġ 3 0 , Ġ 1 0 , Ġ 1 1 , Ġ 2 1 , Ġ 3 0 , Ġ 1 1 , Ġ 4 3 , Ġ 1 3 ), Ġmap . values . toSet ()) ĊĠĠĠ ĠassertEquals ( set Of ( ĊĠĠĠĠĠ Ġ" C :// path / to / my / dir 1 ", ĊĠĠĠĠĠ Ġ" C :// path / to / my / dir 2 ", ĊĠĠĠĠĠ Ġ" C :// path / to / my / dir 3 ", ĊĠĠĠĠĠ Ġ" C :// path / to / my / dir 4 ", ĊĠĠĠĠĠ Ġ" C :// path / to / dir 1 ", ĊĠĠĠĠĠ Ġ" C :// path / to / dir 2 ", ĊĠĠĠĠĠ Ġ" C :// path / to / dir 3 ", ĊĠĠĠĠĠ Ġ" C :// path / to / dir 4 ", ĊĠĠĠĠĠ Ġ" C :// path / to / my ", ĊĠĠĠĠĠ Ġ" C :// path " ĊĠĠĠ Ġ), Ġmap . keys ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` test Ġmap Ġremoves `() Ġ{ ĊĠĠĠ Ġval Ġmap Ġ= ĠPath Prefix TreeMap < Int >() ĊĠĠĠ Ġmap [" C :// path / to / my / dir 1 "] Ġ= Ġ 1 0 ĊĠĠĠ Ġmap [" C :// path / to / my / dir 2 "] Ġ= Ġ 2 0 ĊĠĠĠ Ġmap [" C :// path / to / my / dir 3 "] Ġ= Ġ 3 0 ĊĠĠĠ Ġmap [" C :// path / to / my / dir 4 "] Ġ= Ġ 1 0 ĊĠĠĠ Ġmap [" C :// path / to / dir 1 "] Ġ= Ġ 1 1 ĊĠĠĠ Ġmap [" C :// path / to / dir 2 "] Ġ= Ġ 2 1 ĊĠĠĠ Ġmap [" C :// path / to / dir 3 "] Ġ= Ġ 3 0 ĊĠĠĠ Ġmap [" C :// path / to / dir 4 / "] Ġ= Ġ 1 1 ĊĠĠĠ Ġmap [" C :// path / to / my "] Ġ= Ġ 4 3 ĊĠĠĠ Ġmap [" C :// path "] Ġ= Ġ 1 3 ĊĠĠĠ ĠassertEquals ( 1 0 , Ġmap . size ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my / dir 1 "], Ġ 1 0 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my / dir 2 "], Ġ 2 0 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my / dir 3 "], Ġ 3 0 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my / dir 4 "], Ġ 1 0 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / dir 1 "], Ġ 1 1 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / dir 2 "], Ġ 2 1 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / dir 3 "], Ġ 3 0 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / dir 4 "], Ġ 1 1 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my "], Ġ 4 3 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path "], Ġ 1 3 ) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / my / dir 1 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / my / dir 2 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / my / dir 3 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / my / dir 4 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / dir 1 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / dir 2 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / dir 3 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / dir 4 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / my ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path ")) ĊĠĠĠ Ġmap . remove (" C :// path / to / my / dir 1 /") ĊĠĠĠ Ġmap . remove (" C :// path / to / my / dir 2 ") ĊĠĠĠ Ġmap . remove (" C :// path / to / dir 3 ") ĊĠĠĠ Ġmap . remove (" C :// path / to / dir 4 ") ĊĠĠĠ ĠassertEquals ( 6 , Ġmap . size ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my / dir 1 "], Ġnull ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my / dir 2 "], Ġnull ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my / dir 3 "], Ġ 3 0 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my / dir 4 "], Ġ 1 0 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / dir 1 "], Ġ 1 1 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / dir 2 "], Ġ 2 1 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / dir 3 / "], Ġnull ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / dir 4 "], Ġnull ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my "], Ġ 4 3 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path "], Ġ 1 3 ) ĊĠĠĠ ĠassertFalse ( map . contains (" C :// path / to / my / dir 1 ")) ĊĠĠĠ ĠassertFalse ( map . contains (" C :// path / to / my / dir 2 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / my / dir 3 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / my / dir 4 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / dir 1 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / dir 2 ")) ĊĠĠĠ ĠassertFalse ( map . contains (" C :// path / to / dir 3 ")) ĊĠĠĠ ĠassertFalse ( map . contains (" C :// path / to / dir 4 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / my ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path ")) ĊĠĠĠ ĠassertEquals ( set Of ( 3 0 , Ġ 1 0 , Ġ 1 1 , Ġ 2 1 , Ġ 4 3 , Ġ 1 3 ), Ġmap . values . toSet ()) ĊĠĠĠ ĠassertEquals ( set Of ( ĊĠĠĠĠĠ Ġ" C :// path / to / my / dir 3 ", ĊĠĠĠĠĠ Ġ" C :// path / to / my / dir 4 ", ĊĠĠĠĠĠ Ġ" C :// path / to / dir 1 ", ĊĠĠĠĠĠ Ġ" C :// path / to / dir 2 ", ĊĠĠĠĠĠ Ġ" C :// path / to / my ", ĊĠĠĠĠĠ Ġ" C :// path " ĊĠĠĠ Ġ), Ġmap . keys ) ĊĠ Ġ} ĊĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` test Ġcontaining Ġnullable Ġvalues `() Ġ{ ĊĠĠĠ Ġval Ġmap Ġ= ĠPath Prefix TreeMap < Int ?> () ĊĠĠĠ Ġmap [" C :// path / to / my / dir 1 "] Ġ= Ġnull ĊĠĠĠ Ġmap [" C :// path / to / my / dir 2 "] Ġ= Ġ 2 0 ĊĠĠĠ Ġmap [" C :// path / to / my / dir 3 / "] Ġ= Ġnull ĊĠĠĠ Ġmap [" C :// path / to / my / dir 4 / "] Ġ= Ġ 1 0 ĊĠĠĠ Ġmap [" C :// path / to / dir 1 "] Ġ= Ġnull ĊĠĠĠ Ġmap [" C :// path / to / dir 2 "] Ġ= Ġ 2 1 ĊĠĠĠ Ġmap [" C :// path / to / dir 3 "] Ġ= Ġnull ĊĠĠĠ Ġmap [" C :// path / to / dir 4 "] Ġ= Ġ 1 1 ĊĠĠĠ Ġmap [" C :// path / to / my "] Ġ= Ġ 4 3 ĊĠĠĠ Ġmap [" C :// path "] Ġ= Ġ 1 3 ĊĠĠĠ ĠassertEquals ( 1 0 , Ġmap . size ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my / dir 1 "], Ġnull ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my / dir 2 "], Ġ 2 0 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my / dir 3 "], Ġnull ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my / dir 4 "], Ġ 1 0 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / dir 1 "], Ġnull ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / dir 2 "], Ġ 2 1 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / dir 3 "], Ġnull ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / dir 4 / "], Ġ 1 1 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my "], Ġ 4 3 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path "], Ġ 1 3 ) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / my / dir 1 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / my / dir 2 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / my / dir 3 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / my / dir 4 / ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / dir 1 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / dir 2 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / dir 3 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / dir 4 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / my ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path ")) ĊĠĠĠ Ġmap . remove (" C :// path / to / my / dir 1 ") ĊĠĠĠ Ġmap . remove (" C :// path / to / my / dir 2 ") ĊĠĠĠ Ġmap . remove (" C :// path / to / dir 3 ") ĊĠĠĠ Ġmap . remove (" C :// path / to / dir 4 ") ĊĠĠĠ ĠassertEquals ( 6 , Ġmap . size ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my / dir 1 "], Ġnull ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my / dir 2 "], Ġnull ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my / dir 3 "], Ġnull ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my / dir 4 "], Ġ 1 0 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / dir 1 / "], Ġnull ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / dir 2 "], Ġ 2 1 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / dir 3 "], Ġnull ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / dir 4 "], Ġnull ) ĊĠĠĠ ĠassertEquals ( map [" C :// path / to / my "], Ġ 4 3 ) ĊĠĠĠ ĠassertEquals ( map [" C :// path "], Ġ 1 3 ) ĊĠĠĠ ĠassertFalse ( map . contains (" C :// path / to / my / dir 1 / ")) ĊĠĠĠ ĠassertFalse ( map . contains (" C :// path / to / my / dir 2 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / my / dir 3 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / my / dir 4 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / dir 1 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / dir 2 ")) ĊĠĠĠ ĠassertFalse ( map . contains (" C :// path / to / dir 3 ")) ĊĠĠĠ ĠassertFalse ( map . contains (" C :// path / to / dir 4 ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path / to / my ")) ĊĠĠĠ ĠassertTrue ( map . contains (" C :// path ")) ĊĠĠĠ ĠassertEquals ( set Of ( null , Ġ 1 0 , Ġnull , Ġ 2 1 , Ġ 4 3 , Ġ 1 3 ), Ġmap . values . toSet ()) ĊĠĠĠ ĠassertEquals ( set Of ( ĊĠĠĠĠĠ Ġ" C :// path / to / my / dir 3 ", ĊĠĠĠĠĠ Ġ" C :// path / to / my / dir 4 ", ĊĠĠĠĠĠ Ġ" C :// path / to / dir 1 ", ĊĠĠĠĠĠ Ġ" C :// path / to / dir 2 ", ĊĠĠĠĠĠ Ġ" C :// path / to / my ", ĊĠĠĠĠĠ Ġ" C :// path " ĊĠĠĠ Ġ), Ġmap . keys ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` test Ġget Ġall Ġelements Ġunder Ġdir `() Ġ{ ĊĠĠĠ Ġval Ġmap Ġ= ĠPath Prefix TreeMap < Int ?> () ĊĠĠĠ Ġmap [" C :// path / to / my / dir 1 / "] Ġ= Ġ 1 0 ĊĠĠĠ Ġmap [" C :// path / to / my / dir 2 "] Ġ= Ġ 2 0 ĊĠĠĠ Ġmap [" C :// path / to / my / dir 3 / "] Ġ= Ġ 3 0 ĊĠĠĠ Ġmap [" C :// path / to / my / dir 4 "] Ġ= Ġ 1 0 ĊĠĠĠ Ġmap [" C :// path / to / dir 1 "] Ġ= Ġ 1 1 ĊĠĠĠ Ġmap [" C :// path / to / dir 2 / "] Ġ= Ġ 2 1 ĊĠĠĠ Ġmap [" C :// path / to / dir 3 "] Ġ= Ġ 3 0 ĊĠĠĠ Ġmap [" C :// path / to / dir 4 / "] Ġ= Ġ 1 1 ĊĠĠĠ Ġmap [" C :// path / to / my "] Ġ= Ġ 4 3 ĊĠĠĠ Ġmap [" C :// path "] Ġ= Ġ 1 3 ĊĊĠĠĠ ĠassertEquals ( set Of (" C :// path / to / my / dir 1 " Ġto Ġ 1 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path / to / my / dir 2 " Ġto Ġ 2 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path / to / my / dir 3 " Ġto Ġ 3 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path / to / my / dir 4 " Ġto Ġ 1 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path / to / my " Ġto Ġ 4 3 ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠgetAll Desc endant Pairs ( map , Ġ" C :// path / to / my ")) ĊĠĠĠ ĠassertEquals ( set Of (" C :// path / to / my / dir 1 " Ġto Ġ 1 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path / to / my / dir 2 " Ġto Ġ 2 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path / to / my / dir 3 " Ġto Ġ 3 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path / to / my / dir 4 " Ġto Ġ 1 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path / to / dir 1 " Ġto Ġ 1 1 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path / to / dir 2 " Ġto Ġ 2 1 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path / to / dir 3 " Ġto Ġ 3 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path / to / dir 4 " Ġto Ġ 1 1 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path / to / my " Ġto Ġ 4 3 ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠgetAll Desc endant Pairs ( map , Ġ" C :// path / to ")) ĊĠĠĠ ĠassertEquals ( set Of (" C :// path / to / my / dir 1 " Ġto Ġ 1 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path / to / my / dir 2 " Ġto Ġ 2 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path / to / my / dir 3 " Ġto Ġ 3 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path / to / my / dir 4 " Ġto Ġ 1 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path / to / dir 1 " Ġto Ġ 1 1 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path / to / dir 2 " Ġto Ġ 2 1 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path / to / dir 3 " Ġto Ġ 3 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path / to / dir 4 " Ġto Ġ 1 1 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path / to / my " Ġto Ġ 4 3 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path " Ġto Ġ 1 3 ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠgetAll Desc endant Pairs ( map , Ġ" C :// path ")) ĊĠĠĠ ĠassertEquals ( set Of (" C :// path / to / my / dir 1 " Ġto Ġ 1 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path / to / my / dir 2 " Ġto Ġ 2 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path / to / my / dir 3 " Ġto Ġ 3 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path / to / my / dir 4 " Ġto Ġ 1 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path / to / dir 1 " Ġto Ġ 1 1 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path / to / dir 2 " Ġto Ġ 2 1 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path / to / dir 3 " Ġto Ġ 3 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path / to / dir 4 " Ġto Ġ 1 1 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path / to / my " Ġto Ġ 4 3 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" C :// path " Ġto Ġ 1 3 ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠgetAll Desc endant Pairs ( map , Ġ" C :/ ")) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` test Ġusage Ġwith Ġunix Ġpaths `() Ġ{ ĊĠĠĠ Ġval Ġmap Ġ= ĠPath Prefix TreeMap < Int ?> () ĊĠĠĠ Ġmap [" / path / to / my / dir 1 / "] Ġ= Ġ 1 0 ĊĠĠĠ Ġmap [" / path / to / my / dir 2 "] Ġ= Ġ 2 0 ĊĠĠĠ Ġmap [" / path / to / my / dir 3 / "] Ġ= Ġ 3 0 ĊĠĠĠ ĠassertEquals ( 3 , Ġmap . size ) ĊĠĠĠ ĠassertEquals ( 1 0 , Ġmap . remove ("/ path / to / my / dir 1 / ")) ĊĠĠĠ ĠassertEquals ( 2 , Ġmap . size ) ĊĠĠĠ ĠassertEquals ( null , Ġmap . remove ("/ path / to / my / dir 1 / ")) ĊĠĠĠ ĠassertEquals ( 2 , Ġmap . size ) ĊĠĠĠ Ġmap [" / path / to / my / dir 4 "] Ġ= Ġ 1 0 ĊĠĠĠ Ġmap [" / path / to / dir 1 "] Ġ= Ġ 1 1 ĊĠĠĠ Ġmap [" / path / to / dir 2 / "] Ġ= Ġ 2 1 ĊĠĠĠ ĠassertEquals ( 5 , Ġmap . size ) ĊĠĠĠ ĠassertEquals ( 1 1 , Ġmap . remove ("/ path / to / dir 1 / ")) ĊĠĠĠ ĠassertEquals ( 4 , Ġmap . size ) ĊĠĠĠ Ġmap [" / path / to / dir 3 "] Ġ= Ġ 3 0 ĊĠĠĠ ĠassertEquals ( 5 , Ġmap . size ) ĊĠĠĠ ĠassertEquals ( 1 0 , Ġmap . remove ("/ path / to / my / dir 4 / ")) ĊĠĠĠ ĠassertEquals ( 4 , Ġmap . size ) ĊĠĠĠ Ġmap [" / path / to / dir 4 / "] Ġ= Ġ 1 1 ĊĠĠĠ ĠassertEquals ( 5 , Ġmap . size ) ĊĠĠĠ ĠassertEquals ( null , Ġmap . remove ("/ path ")) ĊĠĠĠ ĠassertEquals ( 5 , Ġmap . size ) ĊĠĠĠ Ġmap [" / path / to / my "] Ġ= Ġ 4 3 ĊĠĠĠ Ġmap [" / path "] Ġ= Ġ 1 3 ĊĠĠĠ ĠassertEquals ( 7 , Ġmap . size ) ĊĠĠĠ ĠassertEquals ( 1 3 , Ġmap . remove ("/ path ")) ĊĠĠĠ ĠassertEquals ( 6 , Ġmap . size ) ĊĠĠĠ ĠassertFalse ( map . contains ("/ path / to / my / dir 1 ")) ĊĠĠĠ ĠassertTrue ( map . contains ("/ path / to / my / dir 2 ")) ĊĠĠĠ ĠassertTrue ( map . contains ("/ path / to / my / dir 3 ")) ĊĠĠĠ ĠassertFalse ( map . contains ("/ path / to / my / dir 4 / ")) ĊĠĠĠ ĠassertFalse ( map . contains ("/ path / to / dir 1 ")) ĊĠĠĠ ĠassertTrue ( map . contains ("/ path / to / dir 2 / ")) ĊĠĠĠ ĠassertTrue ( map . contains ("/ path / to / dir 3 ")) ĊĠĠĠ ĠassertTrue ( map . contains ("/ path / to / dir 4 / ")) ĊĠĠĠ ĠassertTrue ( map . contains ("/ path / to / my ")) ĊĠĠĠ ĠassertFalse ( map . contains ("/ path ")) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` test Ġfind Ġall Ġan cestors `() Ġ{ ĊĠĠĠ Ġval Ġmap Ġ= ĠPath Prefix TreeMap < Int >() ĊĠĠĠ Ġmap [" C :// path / to / my / dir 1 / "] Ġ= Ġ 1 0 ĊĠĠĠ Ġmap [" C :// path / to / my / dir 2 "] Ġ= Ġ 2 0 ĊĠĠĠ Ġmap [" C :// path / to / my / dir 3 / "] Ġ= Ġ 3 0 ĊĠĠĠ Ġmap [" C :// path / to / my / dir 4 "] Ġ= Ġ 1 0 ĊĠĠĠ Ġmap [" C :// path / to / dir 1 "] Ġ= Ġ 1 1 ĊĠĠĠ Ġmap [" C :// path / to / dir 2 / "] Ġ= Ġ 2 1 ĊĠĠĠ Ġmap [" C :// path / to / dir 3 "] Ġ= Ġ 3 0 ĊĠĠĠ Ġmap [" C :// path / to / dir 4 / "] Ġ= Ġ 1 1 ĊĠĠĠ Ġmap [" C :// path / to / my "] Ġ= Ġ 4 3 ĊĠĠĠ Ġmap [" C :// path "] Ġ= Ġ 1 3 ĊĠĠĠ ĠassertEquals ( listOf (" C :// path " Ġto Ġ 1 3 , Ġ" C :// path / to / my " Ġto Ġ 4 3 , Ġ" C :// path / to / my / dir 1 " Ġto Ġ 1 0 ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠgetAll Ancestor Pairs ( map , Ġ" C :// path / to / my / dir 1 / loc ")) ĊĠĠĠ ĠassertEquals ( listOf (" C :// path " Ġto Ġ 1 3 , Ġ" C :// path / to / my " Ġto Ġ 4 3 , Ġ" C :// path / to / my / dir 1 " Ġto Ġ 1 0 ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠgetAll Ancestor Pairs ( map , Ġ" C :// path / to / my / dir 1 ")) ĊĠĠĠ ĠassertEquals ( listOf (" C :// path " Ġto Ġ 1 3 , Ġ" C :// path / to / my " Ġto Ġ 4 3 ), ĠgetAll Ancestor Pairs ( map , Ġ" C :// path / to / my ")) ĊĠĠĠ ĠassertEquals ( listOf (" C :// path " Ġto Ġ 1 3 ), ĠgetAll Ancestor Pairs ( map , Ġ" C :// path / to ")) ĊĠĠĠ ĠassertEquals ( listOf (" C :// path " Ġto Ġ 1 3 ), ĠgetAll Ancestor Pairs ( map , Ġ" C :// path / to / ")) ĊĠĠĠ ĠassertEquals ( listOf (" C :// path " Ġto Ġ 1 3 ), ĠgetAll Ancestor Pairs ( map , Ġ" C :// path ")) ĊĠĠĠ ĠassertEquals ( emptyList < Any >(), ĠgetAll Ancestor Pairs ( map , Ġ" C :/ ")) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġ< T > ĠgetAll Desc endant Pairs ( path Prefix TreeMap : ĠPath Prefix TreeMap < T >, Ġkey : ĠString ): ĠSet < Pair < String , ĠT >> Ġ{ ĊĠĠĠ Ġreturn Ġpath Prefix TreeMap . getAll Desc endants ( key ). map Ġ{ Ġ( k , Ġv ) Ġ-> Ġk Ġto Ġv Ġ}. toSet () ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġ< T > ĠgetAll Ancestor Pairs ( path Prefix TreeMap : ĠPath Prefix TreeMap < T >, Ġkey : ĠString ): ĠList < Pair < String , ĠT >> Ġ{ ĊĠĠĠ Ġreturn Ġpath Prefix TreeMap . getAll An cestors ( key ). map Ġ{ Ġ( k , Ġv ) Ġ-> Ġk Ġto Ġv Ġ} ĊĠ Ġ} Ċ }