Skip to content

Commit

Permalink
[NBKCoreKit] No offset-indexed protocol (#76).
Browse files Browse the repository at this point in the history
  • Loading branch information
oscbyspro committed Sep 22, 2023
1 parent 63dea6b commit 0fb5ddd
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 71 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ A new protocol hierarchy that refines Swift's standard library.
- [NBKBitPatternConvertible](Sources/NBKCoreKit/NBKBitPatternConvertible.swift)
- [NBKCoreInteger](Sources/NBKCoreKit/NBKCoreInteger.swift)
- [NBKFixedWidthInteger](Sources/NBKCoreKit/NBKFixedWidthInteger.swift)
- [NBKOffsetAccessCollection](Sources/NBKCoreKit/NBKOffsetAccessCollection.swift)
- [NBKSignedInteger](Sources/NBKCoreKit/NBKSignedInteger.swift)
- [NBKUnsignedInteger](Sources/NBKCoreKit/NBKUnsignedInteger.swift)

Expand Down
2 changes: 1 addition & 1 deletion Sources/NBKCoreKit/Models/NBKChunkedInt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
/// [0x0304, 0x0102] == Array(NBKChunkedInt(([1, 2, 3, 4] as [UInt8]).reversed(), as: Int16.self))
/// ```
///
@frozen public struct NBKChunkedInt<Base, Element>: NBKOffsetAccessCollection where
@frozen public struct NBKChunkedInt<Base, Element>: RandomAccessCollection where
Element: NBKCoreInteger, Base: RandomAccessCollection, Base.Element: NBKCoreInteger {

public typealias Base = Base
Expand Down
2 changes: 1 addition & 1 deletion Sources/NBKCoreKit/Models/NBKTwinHeaded.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//*============================================================================*

/// A collection that iterates forwards or backwards in a dynamic but branchless way.
@frozen public struct NBKTwinHeaded<Base>: NBKOffsetAccessCollection where Base: RandomAccessCollection {
@frozen public struct NBKTwinHeaded<Base>: RandomAccessCollection where Base: RandomAccessCollection {

public typealias Base = Base

Expand Down
2 changes: 1 addition & 1 deletion Sources/NBKCoreKit/NBKBinaryInteger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
/// [2s]: https://en.wikipedia.org/wiki/Two%27s_complement
///
public protocol NBKBinaryInteger: BinaryInteger, LosslessStringConvertible, Sendable
where Magnitude: NBKUnsignedInteger, Words: NBKOffsetAccessCollection & Sendable {
where Magnitude: NBKUnsignedInteger, Words: Sendable {

/// A machine word of some kind, or this type.
associatedtype Digit: NBKBinaryInteger = Self where
Expand Down
59 changes: 0 additions & 59 deletions Sources/NBKCoreKit/NBKOffsetAccessCollection.swift

This file was deleted.

2 changes: 1 addition & 1 deletion Sources/NBKCoreKit/Private/NBKSuccinctInt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extension NBK {
///
/// The base needs `zero` to `count` indices for performance reasons.
///
@frozen public struct SuccinctInt<Base> where Base: NBKOffsetAccessCollection,
@frozen public struct SuccinctInt<Base> where Base: RandomAccessCollection,
Base.Element: NBKCoreInteger & NBKUnsignedInteger {

//=--------------------------------------------------------------------=
Expand Down
2 changes: 1 addition & 1 deletion Sources/NBKDoubleWidthKit/NBKDoubleWidth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ import NBKCoreKit
/// - Note: You can use `StaticString` until `StaticBigInt` becomes available.
///
@frozen public struct NBKDoubleWidth<High>: ExpressibleByStringLiteral,
NBKFixedWidthInteger, MutableCollection, NBKOffsetAccessCollection where
NBKFixedWidthInteger, MutableCollection, RandomAccessCollection where
High: NBKFixedWidthInteger, High.Digit: NBKCoreInteger<UInt> {

/// The most significant half of this type.
Expand Down
2 changes: 0 additions & 2 deletions Sources/Numberick/Documentation.docc/Documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ A new protocol hierarchy that refines Swift's standard library.
- ``NBKBitPatternConvertible``
- ``NBKCoreInteger``
- ``NBKFixedWidthInteger``
- ``NBKOffsetAccessCollection``
- ``NBKSignedInteger``
- ``NBKUnsignedInteger``

Expand Down Expand Up @@ -106,7 +105,6 @@ Int256(5) % Int(5), UInt256(5) % UInt(5)
- ``NBKBitPatternConvertible``
- ``NBKCoreInteger``
- ``NBKFixedWidthInteger``
- ``NBKOffsetAccessCollection``
- ``NBKSignedInteger``
- ``NBKUnsignedInteger``

Expand Down
9 changes: 5 additions & 4 deletions Tests/NBKCoreKitTests/NBKCoreInteger+Words.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ final class NBKCoreIntegerTestsOnWords: XCTestCase {
//=------------------------------------------------------------------------=

func testWordsHaveIndicesFromZeroToCount() {
func whereWordsIs(_ words: some NBKOffsetAccessCollection) {
XCTAssertEqual(words.indices, 0 as Int ..< words.count)
func whereIs(_ integer: some BinaryInteger) {
XCTAssertEqual(integer.words.startIndex, 0 as Int)
XCTAssertEqual(integer.words.endIndex, integer.words.count)
}

for type: T in types {
whereWordsIs(type.min.words)
whereWordsIs(type.max.words)
whereIs(type.min)
whereIs(type.max)
}
}
}
Expand Down

0 comments on commit 0fb5ddd

Please sign in to comment.