ClosedInterval

struct ClosedInterval<Bound : Comparable>

A closed IntervalType, which contains both its start and its end. Cannot represent an empty interval.

Bound: The type of the endpoints.

Inheritance CustomDebugStringConvertible, CustomStringConvertible, Equatable, IntervalType, _Reflectable View Protocol Hierarchy →
Import import Swift

Initializers

init(_:)

Construct a copy of x.

Declaration

init(_ x: ClosedInterval<Bound>)
init(_:_:)

Construct an interval with the given bounds.

Requires: start <= end.

Declaration

init(_ start: Bound, _ end: Bound)

Instance Variables

var debugDescription: String

A textual representation of self, suitable for debugging.

Declaration

var debugDescription: String { get }
var description: String

A textual representation of self.

Declaration

var description: String { get }
var end: Bound

The Interval's upper bound.

Invariant: start <= end.

Declaration

var end: Bound { get }
var isEmpty: Bool

true iff the Interval is empty. In the case of ClosedInterval, always returns false.

Declaration

var isEmpty: Bool { get }
var start: Bound

The Interval's lower bound.

Invariant: start <= end.

Declaration

var start: Bound { get }

Instance Methods

func clamp(_:)

Returns intervalToClamp clamped to self.

The bounds of the result, even if it is empty, are always limited to the bounds of self.

Declaration

func clamp(intervalToClamp: ClosedInterval<Bound>) -> ClosedInterval<Bound>
func contains(_:)

Returns true iff the Interval contains x.

Declaration

func contains(x: Bound) -> Bool
func overlaps(_:)

Returns true if lhs and rhs have a non-empty intersection.

Declaration

func overlaps<I : IntervalType where I.Bound == Bound>(other: I) -> Bool

Declared In

IntervalType