@@ -219,7 +219,7 @@ static IntersectionImpl wrapInstance(
219219 @ Override
220220 public CompactSketch intersect (final Sketch a , final Sketch b , final boolean dstOrdered ,
221221 final WritableMemory dstMem ) {
222- if (( wmem_ != null ) && readOnly_ ) { throw new SketchesReadOnlyException (); }
222+ if (wmem_ != null && readOnly_ ) { throw new SketchesReadOnlyException (); }
223223 hardReset ();
224224 intersect (a );
225225 intersect (b );
@@ -233,7 +233,7 @@ public void intersect(final Sketch sketchIn) {
233233 if (sketchIn == null ) {
234234 throw new SketchesArgumentException ("Intersection argument must not be null." );
235235 }
236- if (( wmem_ != null ) && readOnly_ ) { throw new SketchesReadOnlyException (); }
236+ if (wmem_ != null && readOnly_ ) { throw new SketchesReadOnlyException (); }
237237 if (empty_ || sketchIn .isEmpty ()) { //empty rule
238238 //Because of the def of null above and the Empty Rule (which is OR), empty_ must be true.
239239 //Whatever the current internal state, we make our local empty.
@@ -262,14 +262,14 @@ public void intersect(final Sketch sketchIn) {
262262 final int sketchInEntries = sketchIn .getRetainedEntries (true );
263263
264264 //states 1,2,3,6
265- if (( curCount_ == 0 ) || ( sketchInEntries == 0 ) ) {
265+ if (curCount_ == 0 || sketchInEntries == 0 ) {
266266 curCount_ = 0 ;
267267 if (wmem_ != null ) { insertCurCount (wmem_ , 0 ); }
268268 hashTable_ = null ; //No need for a HT. Don't bother clearing mem if valid
269269 } //end of states 1,2,3,6
270270
271271 // state 5
272- else if (( curCount_ < 0 ) && ( sketchInEntries > 0 ) ) {
272+ else if (curCount_ < 0 && sketchInEntries > 0 ) {
273273 curCount_ = sketchIn .getRetainedEntries (true );
274274 final int requiredLgArrLongs = minLgHashTableSize (curCount_ , REBUILD_THRESHOLD );
275275 final int priorLgArrLongs = lgArrLongs_ ; //prior only used in error message
@@ -295,7 +295,7 @@ else if ((curCount_ < 0) && (sketchInEntries > 0)) {
295295 } //end of state 5
296296
297297 //state 7
298- else if (( curCount_ > 0 ) && ( sketchInEntries > 0 ) ) {
298+ else if (curCount_ > 0 && sketchInEntries > 0 ) {
299299 //Sets resulting hashTable, curCount and adjusts lgArrLongs
300300 performIntersect (sketchIn );
301301 } //end of state 7
@@ -339,6 +339,16 @@ public CompactSketch getResult(final boolean dstOrdered, final WritableMemory ds
339339 dstMem , compactCache );
340340 }
341341
342+ @ Override
343+ public boolean hasResult () {
344+ return wmem_ != null ? wmem_ .getInt (RETAINED_ENTRIES_INT ) >= 0 : curCount_ >= 0 ;
345+ }
346+
347+ @ Override
348+ public boolean isSameResource (final Memory that ) {
349+ return wmem_ != null ? wmem_ .isSameResource (that ) : false ;
350+ }
351+
342352 @ Override
343353 public void reset () {
344354 hardReset ();
@@ -347,7 +357,7 @@ public void reset() {
347357 @ Override
348358 public byte [] toByteArray () {
349359 final int preBytes = CONST_PREAMBLE_LONGS << 3 ;
350- final int dataBytes = ( curCount_ > 0 ) ? 8 << lgArrLongs_ : 0 ;
360+ final int dataBytes = curCount_ > 0 ? 8 << lgArrLongs_ : 0 ;
351361 final byte [] byteArrOut = new byte [preBytes + dataBytes ];
352362 if (wmem_ != null ) {
353363 wmem_ .getByteArray (0 , byteArrOut , 0 , preBytes + dataBytes );
@@ -376,16 +386,6 @@ public byte[] toByteArray() {
376386 return byteArrOut ;
377387 }
378388
379- @ Override
380- public boolean hasResult () {
381- return (wmem_ != null ) ? wmem_ .getInt (RETAINED_ENTRIES_INT ) >= 0 : curCount_ >= 0 ;
382- }
383-
384- @ Override
385- public boolean isSameResource (final Memory that ) {
386- return (wmem_ != null ) ? wmem_ .isSameResource (that ) : false ;
387- }
388-
389389 //restricted
390390
391391 /**
@@ -405,7 +405,7 @@ boolean isEmpty() {
405405 @ Override
406406 long [] getCache () {
407407 if (wmem_ == null ) {
408- return ( hashTable_ != null ) ? hashTable_ : new long [0 ];
408+ return hashTable_ != null ? hashTable_ : new long [0 ];
409409 }
410410 //Direct
411411 final int arrLongs = 1 << lgArrLongs_ ;
@@ -426,7 +426,7 @@ long getThetaLong() {
426426
427427 private void performIntersect (final Sketch sketchIn ) {
428428 // curCount and input data are nonzero, match against HT
429- assert (( curCount_ > 0 ) && ( !empty_ )) ;
429+ assert curCount_ > 0 && !empty_ ;
430430 final long [] cacheIn = sketchIn .getCache ();
431431 final int arrLongsIn = cacheIn .length ;
432432 final long [] hashTable ;
@@ -458,7 +458,7 @@ private void performIntersect(final Sketch sketchIn) {
458458 //either unordered compact or hash table
459459 for (int i = 0 ; i < arrLongsIn ; i ++ ) {
460460 final long hashIn = cacheIn [i ];
461- if (( hashIn <= 0L ) || ( hashIn >= thetaLong_ ) ) { continue ; }
461+ if (hashIn <= 0L || hashIn >= thetaLong_ ) { continue ; }
462462 final int foundIdx = hashSearch (hashTable , lgArrLongs_ , hashIn );
463463 if (foundIdx == -1 ) { continue ; }
464464 matchSet [matchSetCount ++] = hashIn ;
@@ -505,7 +505,7 @@ private void moveDataToTgt(final long[] arr, final int count) {
505505 tmpCnt ++;
506506 }
507507 }
508- assert ( tmpCnt == count ) : "Intersection Count Check: got: " + tmpCnt + ", expected: " + count ;
508+ assert tmpCnt == count : "Intersection Count Check: got: " + tmpCnt + ", expected: " + count ;
509509 }
510510
511511 private void hardReset () {
0 commit comments