Skip to content

Commit

Permalink
Add IntSet, a (inefficient) implementation of IndexSet
Browse files Browse the repository at this point in the history
  • Loading branch information
aabewhite committed Nov 22, 2023
1 parent 032b1b6 commit d3eae53
Show file tree
Hide file tree
Showing 5 changed files with 426 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let package = Package(
.library(name: "SkipLib", type: .dynamic, targets: ["SkipLib"]),
],
dependencies: [
.package(url: "https://source.skip.tools/skip.git", from: "0.7.28"),
.package(url: "https://source.skip.tools/skip.git", from: "0.7.29"),
.package(url: "https://source.skip.tools/skip-unit.git", from: "0.4.5"),
],
targets: [
Expand Down
89 changes: 89 additions & 0 deletions Sources/SkipLib/IntSet.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// Copyright 2023 Skip
//
// This is free software: you can redistribute and/or modify it
// under the terms of the GNU Lesser General Public License 3.0
// as published by the Free Software Foundation https://fsf.org

// SKIP SYMBOLFILE

#if SKIP

public struct IntSet: BidirectionalCollection, SetAlgebra {
public typealias Index = Int
public typealias Element = Int

public init(integersIn range: any RangeExpression<Int>) {
}

public init(integer: Int) {
}

public init() {
}

@available(*, unavailable)
public var rangeView: Any {
fatalError()
}

@available(*, unavailable)
public func rangeView(of range: any RangeExpression<Int>) -> Any {
}

public func integerGreaterThan(_ integer: Int) -> Int? {
return nil
}

public func integerLessThan(_ integer: Int) -> Int? {
return nil
}

public func integerGreaterThanOrEqualTo(_ integer: Int) -> Int? {
return nil
}

public func integerLessThanOrEqualTo(_ integer: Int) -> Int? {
return nil
}

@available(*, unavailable)
public func indexRange(in range: any RangeExpression<Int>) -> Range<Int> {
fatalError()
}

public func count(in range: any RangeExpression<Int>) -> Int {
return 0
}

public func contains(integersIn range: any RangeExpression<Int>) -> Bool {
return false
}

public func contains(integersIn indexSet: IntSet) -> Bool {
return false
}

public func intersects(integersIn range: any RangeExpression<Int>) -> Bool {
return false
}

public mutating func insert(integersIn range: any RangeExpression<Int>) {
}

public mutating func remove(integersIn range: any RangeExpression<Int>) {
}

public func filteredIndexSet(in range: any RangeExpression<Int>, includeInteger: (Int) throws -> Bool) rethrows -> IntSet {
return self
}

public func filteredIndexSet(includeInteger: (Int) throws -> Bool) rethrows -> IntSet {
return self
}

@available(*, unavailable)
public mutating func shift(startingAt integer: Int, by delta: Int) {
}
}

#endif
5 changes: 3 additions & 2 deletions Sources/SkipLib/Skip/Array.kt
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,11 @@ class Array<Element>: RandomAccessCollection<Element>, RangeReplaceableCollectio
if (other === this) {
return true
}
if (other as? Array<*> == null) {
if (other !is Sequence<*>) {
return false
}
return other.collection == collection
@Suppress("UNCHECKED_CAST")
return elementsEqual(other as Sequence<Element>)
}

override fun hashCode(): Int {
Expand Down
Loading

0 comments on commit d3eae53

Please sign in to comment.