protocol IntervalType

An interval over a Comparable type.

Inheritance View Protocol Hierarchy →
Associated Types
Bound : Comparable

The type of the Interval's endpoints.

Import import Swift

Instance Variables

var end: Self.Bound Required

The Interval's upper bound.

Invariant: start <= end.


var end: Self.Bound { get }
var isEmpty: Bool Required

true iff self is empty.


var isEmpty: Bool { get }
var start: Self.Bound Required

The Interval's lower bound.

Invariant: start <= end.


var start: Self.Bound { get }

Instance Methods

func clamp(_:) Required

Return rhs clamped to self. The bounds of the result, even if it is empty, are always within the bounds of self.


func clamp(intervalToClamp: Self) -> Self
func contains(_:) Required

Returns true iff the interval contains value.


func contains(value: Self.Bound) -> Bool

Default Implementations

func overlaps(_:)

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


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