@ SuppressWarnings ( { "unchecked" } ) public static < K1 , K2 > TwoDimensionalCounter < K2 , K1 > reverseIndexOrder ( TwoDimensionalCounter < K1 , K2 > cc ) { // they typing on the outerMF is violated a bit, but it'll work.... TwoDimensionalCounter < K2 , K1 > result = new TwoDimensionalCounter < K2 , K1 > ( ( MapFactory ) cc . outerMF , ( MapFactory ) cc . innerMF ) ; for ( K1 key1 : cc . firstKeySet ( ) ) { ClassicCounter < K2 > c = cc . getCounter ( key1 ) ; for ( K2 key2 : c . keySet ( ) ) { double count = c . getCount ( key2 ) ; result . setCount ( key2 , key1 , count ) ; } } return result ; }
Produces a new ConditionalCounter .