Range

Objective-C

@interface Range : NSObject

Swift

class Range : NSObject

Represents a range of dimension indices

Properties

  • Declaration

    Objective-C

    @property int start

    Swift

    var start: Int32 { get set }
  • end

    Declaration

    Objective-C

    @property int end

    Swift

    var end: Int32 { get set }

Constructors

  • Declaration

    Objective-C

    - (instancetype)init;

    Swift

    init()
  • Declaration

    Objective-C

    - (instancetype)initWithStart:(int)start end:(int)end;

    Swift

    init(start: Int32, end: Int32)
  • Declaration

    Objective-C

    - (instancetype)initWithVals:(NSArray<NSNumber*>*)vals;

    Swift

    init(vals: [NSNumber])

Methods

  • The size of the range

    Declaration

    Objective-C

    - (int)size;

    Swift

    func size() -> Int32
  • Determines if the range is empty

    Declaration

    Objective-C

    - (BOOL)empty;

    Swift

    func empty() -> Bool
  • Creates a range representing all possible indices for a particular dimension

    Declaration

    Objective-C

    + (nonnull Range *)all;

    Swift

    class func all() -> Range
  • Calculates the intersection of the range with another range

    Declaration

    Objective-C

    - (nonnull Range *)intersection:(nonnull Range *)r1;

    Swift

    func intersection(_ r1: Range) -> Range

    Parameters

    r1

    The other range

  • Adjusts each of the range limts

    Declaration

    Objective-C

    - (nonnull Range *)shift:(int)delta;

    Swift

    func shift(_ delta: Int32) -> Range

    Parameters

    delta

    The amount of the adjustment

  • Set the range limits from the values of an array

    Declaration

    Objective-C

    - (void)set:(nonnull NSArray<NSNumber *> *)vals;

    Swift

    func set(vals: [NSNumber])

    Parameters

    vals

    The array of values from which to set the range limits

  • Clone object

    Declaration

    Objective-C

    - (nonnull Range *)clone;

    Swift

    func clone() -> Range
  • Compare for equality

    Declaration

    Objective-C

    - (BOOL)isEqual:(nullable id)object;

    Swift

    func isEqual(_ object: Any?) -> Bool

    Parameters

    other

    Object to compare

  • Calculate hash value for this object

    Declaration

    Objective-C

    - (NSUInteger)hash;

    Swift

    func hash() -> UInt
  • Returns a string that describes the contents of the object

    Declaration

    Objective-C

    - (nonnull NSString *)description;

    Swift

    func description() -> String