private long nextSegmentIndex ( long segmentIndex , Segment segment ) { long segmentsTier = this . segmentsTier ; segmentIndex <<= - segmentsTier ; segmentIndex = Long . reverse ( segmentIndex ) ; int numberOfArrayIndexesWithThisSegment = 1 << ( segmentsTier - segment . tier ) ; segmentIndex += numberOfArrayIndexesWithThisSegment ; if ( segmentIndex > segmentsMask ) return - 1 ; segmentIndex = Long . reverse ( segmentIndex ) ; segmentIndex >>>= - segmentsTier ; return segmentIndex ; }
Extension rules make order of iteration of segments a little weird avoiding visiting the same segment twice