@ SuppressWarnings ( "unchecked" ) private void insertPair ( ReflectedHandle < K , V > handle1 , ReflectedHandle < K , V > handle2 ) { int c ; if ( comparator == null ) { c = ( ( Comparable < ? super K > ) handle1 . key ) . compareTo ( handle2 . key ) ; } else { c = comparator . compare ( handle1 . key , handle2 . key ) ; } AddressableHeap . Handle < K , HandleMap < K , V > > innerHandle1 ; AddressableHeap . Handle < K , HandleMap < K , V > > innerHandle2 ; if ( c <= 0 ) { innerHandle1 = minHeap . insert ( handle1 . key ) ; handle1 . minNotMax = true ; innerHandle2 = maxHeap . insert ( handle2 . key ) ; handle2 . minNotMax = false ; } else { innerHandle1 = maxHeap . insert ( handle1 . key ) ; handle1 . minNotMax = false ; innerHandle2 = minHeap . insert ( handle2 . key ) ; handle2 . minNotMax = true ; } handle1 . inner = innerHandle1 ; handle2 . inner = innerHandle2 ; innerHandle1 . setValue ( new HandleMap < K , V > ( handle1 , innerHandle2 ) ) ; innerHandle2 . setValue ( new HandleMap < K , V > ( handle2 , innerHandle1 ) ) ; }
Insert a pair of elements one in the min heap and one in the max heap .