• R/O
  • SSH
  • HTTPS

eirrepo: Commit


Commit MetaInfo

Revision174 (tree)
Time2018-12-26 03:58:08
Authorquiret

Log Message

- improved another corner-case of eir::mathSlice to be more mathematically useful (docking of two floating-point slices)

Change Summary

Incremental Difference

--- common/sdk/MathSlice.h (revision 173)
+++ common/sdk/MathSlice.h (revision 174)
@@ -1105,6 +1105,19 @@
11051105 return false;
11061106 }
11071107
1108+template <typename numberType>
1109+AINLINE bool AreBoundsTight( const upperBound <numberType>& left, const lowerBound <numberType>& right )
1110+{
1111+ // Actually allow no room between numbers.
1112+ // This is achieved if at least one bound is wanting to dock onto the other.
1113+ if ( left.is_included() == false && right.is_included() == false )
1114+ {
1115+ return false;
1116+ }
1117+
1118+ return IsNumberInNeighborhood( left.get_value(), right.get_value() );
1119+}
1120+
11081121 } //namespace eir
11091122
11101123 #endif //_EIR_SDK_MATH_SLICE_HEADER_
\ No newline at end of file
--- common/sdk/SortedSliceSector.h (revision 173)
+++ common/sdk/SortedSliceSector.h (revision 174)
@@ -459,14 +459,10 @@
459459 {
460460 if ( doCountInNeighbors )
461461 {
462- // Both slices have to have meeting points.
463- if ( leftSlice.IsEndIncluded() && rightSlice.IsStartIncluded() )
462+ // We are also the same if we are neighboring slices.
463+ if ( AreBoundsTight( leftSlice.GetSliceEndBound(), rightSlice.GetSliceStartBound() ) )
464464 {
465- // We are also the same if we are neighboring slices.
466- if ( IsNumberInNeighborhood( leftSlice.GetSliceEndPoint(), rightSlice.GetSliceStartPoint() ) )
467- {
468- return eCompResult::EQUAL;
469- }
465+ return eCompResult::EQUAL;
470466 }
471467 }
472468
@@ -479,7 +475,7 @@
479475 // Both slices have to have meeting points.
480476 if ( rightSlice.IsEndIncluded() && leftSlice.IsStartIncluded() )
481477 {
482- if ( IsNumberInNeighborhood( rightSlice.GetSliceEndPoint(), leftSlice.GetSliceStartPoint() ) )
478+ if ( AreBoundsTight( rightSlice.GetSliceEndBound(), leftSlice.GetSliceStartBound() ) )
483479 {
484480 return eCompResult::EQUAL;
485481 }
--- unittests/src/sortedslicesector.cpp (revision 173)
+++ unittests/src/sortedslicesector.cpp (revision 174)
@@ -404,7 +404,14 @@
404404 slices.Insert( eir::mathSlice <float>::fromOffsets( 4, 6, true, false ) );
405405 slices.Insert( eir::mathSlice <float>::fromOffsets( 6, 8, true, true ) );
406406
407- assert( slices.GetSliceCount() == 2 );
407+ assert( slices.GetSliceCount() == 1 );
408+
409+ slices.Clear();
410+
411+ slices.Insert( eir::mathSlice <float>::fromOffsets( 4, 6, true, true ) );
412+ slices.Insert( eir::mathSlice <float>::fromOffsets( 6, 8, false, true ) );
413+
414+ assert( slices.GetSliceCount() == 1 );
408415 }
409416 printf( "ok.\n" );
410417
Show on old repository browser