Skip to content

Commit

Permalink
Deprecate permute!! and invpermute!! (#51337)
Browse files Browse the repository at this point in the history
  • Loading branch information
LilithHafner authored Sep 16, 2023
1 parent a61d1b4 commit b2dfa1d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 46 deletions.
46 changes: 0 additions & 46 deletions base/combinatorics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -136,28 +136,6 @@ function permutecols!!(a::AbstractMatrix, p::AbstractVector{<:Integer})
a
end

function permute!!(a, p::AbstractVector{<:Integer})
require_one_based_indexing(a, p)
count = 0
start = 0
while count < length(a)
ptr = start = findnext(!iszero, p, start+1)::Int
temp = a[start]
next = p[start]
count += 1
while next != start
a[ptr] = a[next]
p[ptr] = 0
ptr = next
next = p[next]
count += 1
end
a[ptr] = temp
p[ptr] = 0
end
a
end

"""
permute!(v, p)
Expand Down Expand Up @@ -189,30 +167,6 @@ julia> A
"""
permute!(v, p::AbstractVector) = (v .= v[p])

function invpermute!!(a, p::AbstractVector{<:Integer})
require_one_based_indexing(a, p)
count = 0
start = 0
while count < length(a)
start = findnext(!iszero, p, start+1)::Int
temp = a[start]
next = p[start]
count += 1
while next != start
temp_next = a[next]
a[next] = temp
temp = temp_next
ptr = p[next]
p[next] = 0
next = ptr
count += 1
end
a[next] = temp
p[next] = 0
end
a
end

"""
invpermute!(v, p)
Expand Down
9 changes: 9 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -384,3 +384,12 @@ macro pure(ex)
end

# END 1.10 deprecations

# BEGIN 1.11 deprecations

# these were never a part of the public API and so they can be removed without deprecation
# in a minor release but we're being nice and trying to avoid transient breakage.
@deprecate permute!!(a, p::AbstractVector{<:Integer}) permute!(a, p) false
@deprecate invpermute!!(a, p::AbstractVector{<:Integer}) invpermute!(a, p) false

# END 1.11 deprecations

0 comments on commit b2dfa1d

Please sign in to comment.