BitwiseOperationsType

protocol BitwiseOperationsType

A set type with O(1) standard bitwise operators.

Each instance is a subset of ~Self.allZeros.

Axioms, where x is an instance of Self:

  • x | Self.allZeros == x
  • x ^ Self.allZeros == x
  • x & Self.allZeros == .allZeros
  • x & ~Self.allZeros == x
  • ~x == x ^ ~Self.allZeros
Inheritance View Protocol Hierarchy →
Import import Swift

Static Variables

static var allZeros: Self Required

The empty bitset.

Also the identity element for | and ^, and the fixed point for &.

Declaration

static var allZeros: Self { get }

Instance Methods

func &(_:rhs:) Required

Returns the intersection of bits set in lhs and rhs.

Complexity: O(1).

Declaration

func &(lhs: Self, rhs: Self) -> Self
func ^(_:rhs:) Required

Returns the bits that are set in exactly one of lhs and rhs.

Complexity: O(1).

Declaration

func ^(lhs: Self, rhs: Self) -> Self
func |(_:rhs:) Required

Returns the union of bits set in lhs and rhs.

Complexity: O(1).

Declaration

func |(lhs: Self, rhs: Self) -> Self
prefix func ~(_:) Required

Returns x ^ ~Self.allZeros.

Complexity: O(1).

Declaration

prefix func ~(x: Self) -> Self