Skip to content

Commit f77e504

Browse files
Remove unused code: AbstractContainer (#2662)
1 parent 29d3a42 commit f77e504

File tree

2 files changed

+0
-114
lines changed

2 files changed

+0
-114
lines changed

src/auxiliary/containers.jl

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -149,34 +149,6 @@ function invalidate!(c::AbstractContainer, id::Int)
149149
return invalidate!(c, id, id)
150150
end
151151

152-
# Swap two elements in a container while preserving element connectivity.
153-
function swap!(c::AbstractContainer, a::Int, b::Int)
154-
@assert 1<=a<=length(c) "a out of range"
155-
@assert 1<=b<=length(c) "b out of range"
156-
157-
# Return if swap would be a no-op
158-
if a == b
159-
return c
160-
end
161-
162-
# Move a to dummy location
163-
raw_copy!(c, a, c.dummy)
164-
move_connectivity!(c, a, c.dummy)
165-
166-
# Move b to a
167-
raw_copy!(c, b, a)
168-
move_connectivity!(c, b, a)
169-
170-
# Move from dummy location to b
171-
raw_copy!(c, c.dummy, b)
172-
move_connectivity!(c, c.dummy, b)
173-
174-
# Invalidate dummy to be sure
175-
invalidate!(c, c.dummy)
176-
177-
return c
178-
end
179-
180152
# Insert blank elements in container, shifting the following elements back.
181153
#
182154
# After a call to insert!, the range `position:position + count - 1` will be available for use.
@@ -209,25 +181,6 @@ function insert!(c::AbstractContainer, position::Int, count::Int)
209181
return c
210182
end
211183

212-
# Erase elements from container, deleting their connectivity and then invalidating their data.
213-
# TODO: Shall we extend Base.deleteat! or Base.delete! ?
214-
function erase!(c::AbstractContainer, first::Int, last::Int)
215-
@assert 1<=first<=length(c) "First cell out of range"
216-
@assert 1<=last<=length(c) "Last cell out of range"
217-
218-
# Return if eraseure would be a no-op
219-
if last < first
220-
return c
221-
end
222-
223-
# Delete connectivity and invalidate cells
224-
delete_connectivity!(c, first, last)
225-
invalidate!(c, first, last)
226-
227-
return c
228-
end
229-
erase!(c::AbstractContainer, id::Int) = erase!(c, id, id)
230-
231184
# Remove cells and shift existing cells forward to close the gap
232185
function remove_shift!(c::AbstractContainer, first::Int, last::Int)
233186
@assert 1<=first<=length(c) "First cell out of range"
@@ -257,44 +210,6 @@ function remove_shift!(c::AbstractContainer, first::Int, last::Int)
257210
end
258211
remove_shift!(c::AbstractContainer, id::Int) = remove_shift!(c, id, id)
259212

260-
# Remove cells and fill gap with cells from the end of the container (to reduce copy operations)
261-
function remove_fill!(c::AbstractContainer, first::Int, last::Int)
262-
@assert 1<=first<=length(c) "First cell out of range"
263-
@assert 1<=last<=length(c) "Last cell out of range"
264-
265-
# Return if removal would be a no-op
266-
if last < first
267-
return c
268-
end
269-
270-
# Delete connectivity of cells to be removed and then invalidate them
271-
delete_connectivity!(c, first, last)
272-
invalidate!(c, first, last)
273-
274-
# Copy cells from end (unless last is already the last cell)
275-
count = last - first + 1
276-
if last < length(c)
277-
move!(c, max(length(c) - count + 1, last + 1), length(c), first)
278-
end
279-
280-
# Reduce length
281-
c.length -= count
282-
283-
return c
284-
end
285-
286-
# Reset container to zero-length and with a new capacity
287-
function reset!(c::AbstractContainer, capacity::Int)
288-
@assert capacity >= 0
289-
290-
c.capacity = capacity
291-
c.length = 0
292-
c.dummy = capacity + 1
293-
reset_data_structures!(c)
294-
295-
return c
296-
end
297-
298213
# Invalidate all elements and set length to zero.
299214
function clear!(c::AbstractContainer)
300215
invalidate!(c)

test/test_unit.jl

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -392,22 +392,6 @@ end
392392
@test Trixi.move!(c, 1, 2) == MyContainer([0, 1, 3])
393393
end
394394

395-
@testset "swap!" begin
396-
c = MyContainer([1, 2])
397-
@test Trixi.swap!(c, 1, 1) == MyContainer([1, 2]) # no-op
398-
399-
c = MyContainer([1, 2])
400-
@test Trixi.swap!(c, 1, 2) == MyContainer([2, 1])
401-
end
402-
403-
@testset "erase!" begin
404-
c = MyContainer([1, 2])
405-
@test Trixi.erase!(c, 2, 1) == MyContainer([1, 2]) # no-op
406-
407-
c = MyContainer([1, 2])
408-
@test Trixi.erase!(c, 1) == MyContainer([0, 2])
409-
end
410-
411395
@testset "remove_shift!" begin
412396
c = MyContainer([1, 2, 3, 4])
413397
@test Trixi.remove_shift!(c, 2, 1) == MyContainer([1, 2, 3, 4]) # no-op
@@ -418,19 +402,6 @@ end
418402
c = MyContainer([1, 2, 3, 4])
419403
@test Trixi.remove_shift!(c, 2) == MyContainer([1, 3, 4], 4)
420404
end
421-
422-
@testset "remove_fill!" begin
423-
c = MyContainer([1, 2, 3, 4])
424-
@test Trixi.remove_fill!(c, 2, 1) == MyContainer([1, 2, 3, 4]) # no-op
425-
426-
c = MyContainer([1, 2, 3, 4])
427-
@test Trixi.remove_fill!(c, 2, 2) == MyContainer([1, 4, 3], 4)
428-
end
429-
430-
@testset "reset!" begin
431-
c = MyContainer([1, 2, 3])
432-
@test Trixi.reset!(c, 2) == MyContainer(Int[], 2)
433-
end
434405
end
435406

436407
@timed_testset "example elixirs" begin

0 commit comments

Comments
 (0)