Files
swift-collections/Sources/BitCollections/BitSet/BitSet+Invariants.swift
T
Karoy Lorentey cbf933665b [BitSet] Revert to non-generic BitSet
Also, remove members that were generic over FixedWidthInteger.
2022-08-12 19:22:24 -07:00

28 lines
918 B
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Collections open source project
//
// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
//
//===----------------------------------------------------------------------===//
extension BitSet {
#if COLLECTIONS_INTERNAL_CHECKS
@inline(never)
@_effects(releasenone)
public func _checkInvariants() {
let actualCount = _storage.reduce(into: 0) { $0 += $1.count }
precondition(_count == actualCount, "Invalid count")
precondition(_storage.isEmpty || !_storage.last!.isEmpty,
"Extraneous tail slot")
}
#else
@inline(__always) @inlinable
public func _checkInvariants() {}
#endif // COLLECTIONS_INTERNAL_CHECKS
}