diff --git a/Package.swift b/Package.swift index ae05b8b..938d93e 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:4.2 +// swift-tools-version:5.0 import PackageDescription diff --git a/Sources/ElementaryCycles/Private/AdjacencyMatrix+getAdjacencyMatrix.swift b/Sources/ElementaryCycles/Private/AdjacencyMatrix+getAdjacencyMatrix.swift index f077d64..c93f756 100644 --- a/Sources/ElementaryCycles/Private/AdjacencyMatrix+getAdjacencyMatrix.swift +++ b/Sources/ElementaryCycles/Private/AdjacencyMatrix+getAdjacencyMatrix.swift @@ -24,7 +24,7 @@ extension Matrix where Element == Bool { for (offset, node) in nodes.enumerated() { if let adjacentNodes = adjacencyDictionary[node] { for adjacentNode in adjacentNodes { - guard let adjacentIndex = nodes.index(of: adjacentNode) else { + guard let adjacentIndex = nodes.firstIndex(of: adjacentNode) else { throw Error.indexNotFound(node: adjacentNode, nodes: nodes) } matrix[offset][adjacentIndex] = true diff --git a/Sources/ElementaryCyclesSearch/Public/ElementaryCyclesSearch.swift b/Sources/ElementaryCyclesSearch/Public/ElementaryCyclesSearch.swift index 2a514d3..f4dd71a 100644 --- a/Sources/ElementaryCyclesSearch/Public/ElementaryCyclesSearch.swift +++ b/Sources/ElementaryCyclesSearch/Public/ElementaryCyclesSearch.swift @@ -168,7 +168,7 @@ public class ElementaryCyclesSearch { } } - if let index = stack.index(of: v) { + if let index = stack.firstIndex(of: v) { stack.remove(at: index) } return f diff --git a/Sources/ElementaryCyclesSearch/Public/Vector/Vector.swift b/Sources/ElementaryCyclesSearch/Public/Vector/Vector.swift index 8fecf85..e5da1f8 100644 --- a/Sources/ElementaryCyclesSearch/Public/Vector/Vector.swift +++ b/Sources/ElementaryCyclesSearch/Public/Vector/Vector.swift @@ -83,7 +83,7 @@ extension Vector where Element: Equatable { @discardableResult func remove(element: Element) -> Bool { - if let index = array.index(of: element) { + if let index = array.firstIndex(of: element) { array.remove(at: -index.distance(to: 0)) return true } diff --git a/Tests/ElementaryCyclesTests/AdjacencyMatrixShould.swift b/Tests/ElementaryCyclesTests/AdjacencyMatrixShould.swift index abddd21..571e061 100644 --- a/Tests/ElementaryCyclesTests/AdjacencyMatrixShould.swift +++ b/Tests/ElementaryCyclesTests/AdjacencyMatrixShould.swift @@ -31,10 +31,10 @@ final class AdjacencyMatrixShould: XCTestCase { "IT": ["FR"]] let nodes = AdjacencyMatrix.getNodes(graph: graph, sort: nil) let adjacencyMatrix = try! AdjacencyMatrix.getAdjacencyMatrix(nodes: nodes, adjacencyDictionary: graph) - let es = nodes.index(of: "ES")! - let pt = nodes.index(of: "PT")! - let fr = nodes.index(of: "FR")! - let it = nodes.index(of: "IT")! + let es = nodes.firstIndex(of: "ES")! + let pt = nodes.firstIndex(of: "PT")! + let fr = nodes.firstIndex(of: "FR")! + let it = nodes.firstIndex(of: "IT")! XCTAssertTrue(adjacencyMatrix[es][pt] ?? adjacencyMatrix[pt][es] ?? false) XCTAssertTrue(adjacencyMatrix[es][fr] ?? adjacencyMatrix[fr][es] ?? false) XCTAssertTrue(adjacencyMatrix[fr][it] ?? adjacencyMatrix[it][fr] ?? false)