Range.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. //
  2. // Range.h
  3. //
  4. // Created by Giles Payne on 2019/10/08.
  5. //
  6. #pragma once
  7. #ifdef __cplusplus
  8. #import "opencv2/core.hpp"
  9. #else
  10. #define CV_EXPORTS
  11. #endif
  12. #import <Foundation/Foundation.h>
  13. NS_ASSUME_NONNULL_BEGIN
  14. /**
  15. * Represents a range of dimension indices
  16. */
  17. CV_EXPORTS @interface Range : NSObject
  18. #pragma mark - Properties
  19. @property int start;
  20. @property int end;
  21. #pragma mark - Constructors
  22. - (instancetype)init;
  23. - (instancetype)initWithStart:(int)start end:(int)end;
  24. - (instancetype)initWithVals:(NSArray<NSNumber*>*)vals;
  25. #pragma mark - Methods
  26. /**
  27. * The size of the range
  28. */
  29. - (int)size;
  30. /**
  31. * Determines if the range is empty
  32. */
  33. - (BOOL)empty;
  34. /**
  35. * Creates a range representing all possible indices for a particular dimension
  36. */
  37. + (Range*)all;
  38. /**
  39. * Calculates the intersection of the range with another range
  40. * @param r1 The other range
  41. */
  42. - (Range*)intersection:(Range*)r1;
  43. /**
  44. * Adjusts each of the range limts
  45. * @param delta The amount of the adjustment
  46. */
  47. - (Range*)shift:(int)delta;
  48. /**
  49. * Set the range limits from the values of an array
  50. * @param vals The array of values from which to set the range limits
  51. */
  52. - (void)set:(NSArray<NSNumber*>*)vals NS_SWIFT_NAME(set(vals:));
  53. # pragma mark - Common Methods
  54. /**
  55. * Clone object
  56. */
  57. - (Range*)clone;
  58. /**
  59. * Compare for equality
  60. * @param other Object to compare
  61. */
  62. - (BOOL)isEqual:(nullable id)object;
  63. /**
  64. * Calculate hash value for this object
  65. */
  66. - (NSUInteger)hash;
  67. /**
  68. * Returns a string that describes the contents of the object
  69. */
  70. - (NSString*)description;
  71. @end
  72. NS_ASSUME_NONNULL_END