Skip to content

Commit b0b4373

Browse files
authored
Merge pull request JuliaCollections#538 from mortenpi/whitespace
Remove trailing whitespace and newlines
2 parents 80aa612 + e2b72a8 commit b0b4373

32 files changed

+174
-181
lines changed

Changelog.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ v0.4.2 / 2016-01-13
9191
==================
9292

9393
* Fix OrderedDict constructors (with tests)
94-
* Add IntSet to DataStructures
94+
* Add IntSet to DataStructures
9595
(see #114, https://github.com/JuliaLang/julia/pull/10065)
9696
* Dead code, tree.jl removal
9797

@@ -341,7 +341,7 @@ v0.2.5 / 2013-10-08
341341
* Revised implementation of Deque, without using Union(Nothing, DequeBlock).
342342
* Fixed the doc regarding API for heaps: binary_heap -> binary_{min|max}heap and mutable_binary_heap -> mutable_binary_{min|max}heap
343343
* Added 1 missing API call to the documentation
344-
* Fixed bugs related to Dequeue functions front and back.
344+
* Fixed bugs related to Dequeue functions front and back.
345345
* Front would give garbage data when called on a newly created queue, and back when popping a queue from the front.
346346
* Implemented simple show method inside Dequeue to hide unnecessary (large!) implementation detail from the client, in particular when using REPL
347347

@@ -374,4 +374,3 @@ v0.2.5 / 2013-10-08
374374
* add stack and queue (tested)
375375
* add Dequeue (tested)
376376
* Initial commit
377-

benchmark/benchmarks.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,3 @@ SUITE["SparseIntSet"]["iterate two"] =
108108

109109
SUITE["SparseIntSet"]["iterate two exclude one"] =
110110
@benchmarkable iterate_two_exclude_one_bench(x,y,z) setup=x_y_z_setup
111-

docs/src/heaps.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ h = MutableBinaryMaxHeap([1,4,3,2]) # create a mutable min/max heap from a ve
5555
```
5656

5757
## Min-max heaps
58-
Min-max heaps maintain the minimum _and_ the maximum of a set,
58+
Min-max heaps maintain the minimum _and_ the maximum of a set,
5959
allowing both to be retrieved in constant (`O(1)`) time.
6060
The min-max heaps in this package are subtypes of `AbstractMinMaxHeap <: AbstractHeap`
6161
and have the same interface as other heaps with the following additions:
@@ -73,7 +73,7 @@ popmax!(h, k) # remove and return the largest k elements
7373
popall!(h) # remove and return all the elements, sorted smallest to largest
7474
popall!(h, o) # remove and return all the elements according to ordering o
7575
```
76-
The usual `top(h)` and `pop!(h)` are defined to be `minimum(h)` and `popmin!(h)`,
76+
The usual `top(h)` and `pop!(h)` are defined to be `minimum(h)` and `popmin!(h)`,
7777
respectively.
7878

7979
This package includes an implementation of a binary min-max heap (`BinaryMinMaxHeap`).

docs/src/sorted_containers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ end
452452

453453
Here, `st1` and `st2` are semitokens that refer to the container `sc`.
454454
Token `(sc,st1)` may not be the before-start token and
455-
token `(sc,st2)` may not be the past-end token.
455+
token `(sc,st2)` may not be the past-end token.
456456
It is acceptable for `(sc,st1)` to be the past-end token or `(sc,st2)`
457457
to be the before-start token or both (in these cases, the body is not executed).
458458
If `compare(sc,st1,st2)==1` then the body is not executed. A second
@@ -765,7 +765,7 @@ Lt((x,y) -> isless(lowercase(x),lowercase(y)))
765765
The ordering object is indicated in the above list of constructors in
766766
the `o` position (see above for constructor syntax).
767767

768-
This approach may suffer from a performance hit because higher performance
768+
This approach may suffer from a performance hit because higher performance
769769
may be possible if an equality method is also available as well as a
770770
less-than method.
771771
A more complicated but higher-performance method to implement

docs/src/sparse_int_set.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# DataStructures.SparseIntSet
22

33
Implementation of a __Sparse Integer Set__, for background see [Sparse Sets](https://www.computist.xyz/2018/06/sparse-sets.html).
4-
Only positive non-zero `Int`s are allowed inside the set.
4+
Only positive non-zero `Int`s are allowed inside the set.
55
The idea is to have one **packed** `Vector` storing all the `Int`s contained in the set as to allow for fast iteration, and a sparse, paged **reverse** `Vector` with the position of a particular `Int` inside the **packed** `Vector`. This allows for very fast iteration, insertion and deletion of indices.
6-
Most behavior is similar to a normal `IntSet`, however `collect`, `first` and `last` are with respected to the **packed** vector, in which the ordering is not guaranteed.
7-
The **reverse** `Vector` is paged, meaning that it is a `Vector{Vector{Int}}` where each of the `Vector{Int}`s has the length of one memory page of `Int`s. Every time an index that was not yet in the range of the already present pages, a new one will be created and added to the **reverse**, allowing for dynamical growth.
8-
Popping the last `Int` of a particular page will automatically clean up the memory of that page.
6+
Most behavior is similar to a normal `IntSet`, however `collect`, `first` and `last` are with respected to the **packed** vector, in which the ordering is not guaranteed.
7+
The **reverse** `Vector` is paged, meaning that it is a `Vector{Vector{Int}}` where each of the `Vector{Int}`s has the length of one memory page of `Int`s. Every time an index that was not yet in the range of the already present pages, a new one will be created and added to the **reverse**, allowing for dynamical growth.
8+
Popping the last `Int` of a particular page will automatically clean up the memory of that page.

src/circular_buffer.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""
22
CircularBuffer{T}(n)
33
4-
The CircularBuffer type implements a circular buffer of fixed capacity
5-
where new items are pushed to the back of the list, overwriting values
4+
The CircularBuffer type implements a circular buffer of fixed capacity
5+
where new items are pushed to the back of the list, overwriting values
66
in a circular fashion.
77
88
Allocate a buffer of elements of type `T` with maximum capacity `n`.
@@ -115,7 +115,7 @@ end
115115
"""
116116
pushfirst!(cb, data)
117117
118-
Insert one or more items at the beginning of CircularBuffer
118+
Insert one or more items at the beginning of CircularBuffer
119119
and overwrite back if full.
120120
"""
121121
function pushfirst!(cb::CircularBuffer, data)

src/container_loops.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,20 +258,20 @@ onlysemitokens(ba::SAIterableTypesBase) = SAOnlySemiTokensIteration(ba)
258258

259259

260260

261-
261+
262262
function nexthelper(c::SAContainer, state::SAIterationState)
263263
sn = state.next
264264
(sn < 3 || !(sn in c.bt.useddatacells)) && throw(BoundsError())
265265
SAIterationState(nextloc0(c.bt, sn), state.final)
266266
end
267267

268268

269-
269+
270270
getitem(::SDMIterableTypesBase, dt, sn) = dt.k => dt.d
271271
getitem(::SSIterableTypesBase, dt, sn) = dt.k
272272
getitem(::SDMKeyIteration, dt, sn) = dt.k
273273
getitem(::SDMValIteration, dt, sn) = dt.d
274-
getitem(::SDMSemiTokenIteration, dt, sn) = (IntSemiToken(sn), dt.k, dt.d)
274+
getitem(::SDMSemiTokenIteration, dt, sn) = (IntSemiToken(sn), dt.k, dt.d)
275275
getitem(::SSSemiTokenIteration, dt, sn) = (IntSemiToken(sn), dt.k)
276276
getitem(::SDMSemiTokenKeyIteration, dt, sn) = (IntSemiToken(sn), dt.k)
277277
getitem(::SDMSemiTokenValIteration, dt, sn) = (IntSemiToken(sn), dt.d)

src/fenwick.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ end
55

66
"""
77
FenwickTree{T}(n)
8-
8+
99
Constructs a [`FenwickTree`](https://en.wikipedia.org/wiki/Fenwick_tree) of length `n`.
10-
10+
1111
"""
1212
FenwickTree{T}(n::Integer) where T = FenwickTree{T}(zeros(T, n), n)
1313

1414
"""
15-
FenwickTree(counts::AbstractArray)
16-
15+
FenwickTree(counts::AbstractArray)
16+
1717
Constructs a [`FenwickTree`](https://en.wikipedia.org/wiki/Fenwick_tree) from an array of `counts`
18-
18+
1919
"""
2020
function FenwickTree(a::AbstractVector{U}) where U
2121
n = length(a)
@@ -34,7 +34,7 @@ Base.eltype(::Type{FenwickTree{T}}) where T = T
3434
3535
Increases the value of the [`FenwickTree`] by `val` from the index `ind` upto the length of the Fenwick Tree.
3636
37-
"""
37+
"""
3838
function inc!(ft::FenwickTree{T}, ind::Integer, val = 1) where T
3939
val0 = convert(T, val)
4040
i = ind
@@ -51,15 +51,15 @@ end
5151
5252
Decreases the value of the [`FenwickTree`] by `val` from the index `ind` upto the length of the Fenwick Tree.
5353
54-
"""
54+
"""
5555
dec!(ft::FenwickTree, ind::Integer, val = 1 ) = inc!(ft, ind, -val)
5656

5757
"""
5858
incdec!(ft::FenwickTree{T}, left, right, val)
5959
6060
Increases the value of the [`FenwickTree`] by `val` from the indices from `left` and decreases it from the `right`.
6161
62-
"""
62+
"""
6363
function incdec!(ft::FenwickTree{T}, left::Integer, right::Integer, val = one(T)) where T
6464
val0 = convert(T, val)
6565
inc!(ft, left, val0)
@@ -68,7 +68,7 @@ end
6868

6969
"""
7070
prefixsum(ft::FenwickTree{T}, ind)
71-
71+
7272
Return the cumulative sum from index 1 upto `ind` of the [`FenwickTree`](@ref)
7373
7474
# Examples
@@ -86,7 +86,7 @@ function prefixsum(ft::FenwickTree{T}, ind::Integer) where T
8686
i = ind
8787
n = ft.n
8888
@boundscheck 1 <= i <= n || throw(ArgumentError("$i should be in between 1 and $n"))
89-
@inbounds while i > 0
89+
@inbounds while i > 0
9090
sum += ft.bi_tree[i]
9191
i -= i&(-i)
9292
end

src/heaps/minmax_heap.jl

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
mutable struct BinaryMinMaxHeap{T} <: AbstractMinMaxHeap{T}
88
valtree::Vector{T}
9-
9+
1010
BinaryMinMaxHeap{T}() where {T} = new{T}(Vector{T}())
11-
11+
1212
function BinaryMinMaxHeap(xs::AbstractVector{T}) where {T}
1313
valtree = _make_binary_minmax_heap(xs)
1414
new{T}(valtree)
@@ -41,7 +41,7 @@ function _minmax_heap_bubble_up!(A::AbstractVector, i::Integer)
4141
# bubble up min
4242
_minmax_heap_bubble_up!(A, i, Forward)
4343
end
44-
44+
4545
else
4646
# max level
4747
if i > 1 && A[i] < A[hparent(i)]
@@ -55,7 +55,7 @@ function _minmax_heap_bubble_up!(A::AbstractVector, i::Integer)
5555
_minmax_heap_bubble_up!(A, i, Reverse)
5656
end
5757
end
58-
return
58+
return
5959
end
6060

6161
function _minmax_heap_bubble_up!(A::AbstractVector, i::Integer, o::Ordering, x=A[i])
@@ -67,7 +67,7 @@ function _minmax_heap_bubble_up!(A::AbstractVector, i::Integer, o::Ordering, x=A
6767
_minmax_heap_bubble_up!(A, gparent, o)
6868
end
6969
end
70-
return
70+
return
7171
end
7272

7373
function _minmax_heap_trickle_down!(A::AbstractVector, i::Integer)
@@ -80,7 +80,7 @@ function _minmax_heap_trickle_down!(A::AbstractVector, i::Integer)
8080
end
8181

8282
function _minmax_heap_trickle_down!(A::AbstractVector, i::Integer, o::Ordering, x=A[i])
83-
83+
8484
if haschildren(i, A)
8585
# get the index of the extremum (min or max) descendant
8686
extremum = o === Forward ? minimum : maximum
@@ -106,7 +106,7 @@ function _minmax_heap_trickle_down!(A::AbstractVector, i::Integer, o::Ordering,
106106
end
107107
return
108108
end
109-
109+
110110
################################################
111111
#
112112
# utilities
@@ -118,10 +118,10 @@ end
118118
@inline rchild(i) = 2*i+1
119119
@inline children(i) = (lchild(i), rchild(i))
120120
@inline hparent(i) = i ÷ 2
121-
@inline on_minlevel(i) = level(i) % 2 == 0
121+
@inline on_minlevel(i) = level(i) % 2 == 0
122122
@inline haschildren(i, A) = lchild(i) length(A)
123123
@inline isgrandchild(j, i) = j > rchild(i)
124-
@inline hasgrandparent(i) = i 4
124+
@inline hasgrandparent(i) = i 4
125125

126126
"""
127127
children_and_grandchildren(maxlen, i)
@@ -189,7 +189,7 @@ end
189189

190190
"""
191191
popmin!(h::BinaryMinMaxHeap) -> min
192-
192+
193193
Remove the minimum value from the heap.
194194
"""
195195
function popmin!(h::BinaryMinMaxHeap)
@@ -204,19 +204,19 @@ function popmin!(h::BinaryMinMaxHeap)
204204
return x
205205
end
206206

207-
207+
208208
"""
209209
popmin!(h::BinaryMinMaxHeap, k::Integer) -> vals
210-
210+
211211
Remove up to the `k` smallest values from the heap.
212212
"""
213-
@inline function popmin!(h::BinaryMinMaxHeap, k::Integer)
213+
@inline function popmin!(h::BinaryMinMaxHeap, k::Integer)
214214
return [popmin!(h) for _ in 1:min(length(h), k)]
215215
end
216216

217217
"""
218218
popmax!(h::BinaryMinMaxHeap) -> max
219-
219+
220220
Remove the maximum value from the heap.
221221
"""
222222
function popmax!(h::BinaryMinMaxHeap)
@@ -228,55 +228,54 @@ function popmax!(h::BinaryMinMaxHeap)
228228
@inbounds valtree[i] = y
229229
_minmax_heap_trickle_down!(valtree, i)
230230
end
231-
return x
231+
return x
232232
end
233233

234234
"""
235235
popmax!(h::BinaryMinMaxHeap, k::Integer) -> vals
236-
236+
237237
Remove up to the `k` largest values from the heap.
238238
"""
239-
@inline function popmax!(h::BinaryMinMaxHeap, k::Integer)
240-
return [popmax!(h) for _ in 1:min(length(h), k)]
239+
@inline function popmax!(h::BinaryMinMaxHeap, k::Integer)
240+
return [popmax!(h) for _ in 1:min(length(h), k)]
241241
end
242-
243-
242+
243+
244244
function push!(h::BinaryMinMaxHeap, v)
245-
valtree = h.valtree
245+
valtree = h.valtree
246246
push!(valtree, v)
247247
_minmax_heap_bubble_up!(valtree, length(valtree))
248248
end
249249

250250
"""
251251
top(h::BinaryMinMaxHeap)
252-
252+
253253
Get the top (minimum) of the heap.
254254
"""
255255
@inline top(h::BinaryMinMaxHeap) = minimum(h)
256256

257-
@inline function minimum(h::BinaryMinMaxHeap)
257+
@inline function minimum(h::BinaryMinMaxHeap)
258258
valtree = h.valtree
259259
!isempty(h) || throw(ArgumentError("heap must be non-empty"))
260260
return @inbounds h.valtree[1]
261261
end
262262

263-
@inline function maximum(h::BinaryMinMaxHeap)
263+
@inline function maximum(h::BinaryMinMaxHeap)
264264
valtree = h.valtree
265265
!isempty(h) || throw(ArgumentError("heap must be non-empty"))
266266
return @inbounds maximum(valtree[1:min(end, 3)])
267267
end
268-
268+
269269
empty!(h::BinaryMinMaxHeap) = (empty!(h.valtree); h)
270-
270+
271271

272272
"""
273273
popall!(h::BinaryMinMaxHeap, ::Ordering = Forward)
274-
274+
275275
Remove and return all the elements of `h` according to
276-
the given ordering. Default is `Forward` (smallest to
276+
the given ordering. Default is `Forward` (smallest to
277277
largest).
278278
"""
279279
popall!(h::BinaryMinMaxHeap) = popall!(h, Forward)
280280
popall!(h::BinaryMinMaxHeap, ::ForwardOrdering) = popmin!(h, length(h))
281281
popall!(h::BinaryMinMaxHeap, ::ReverseOrdering) = popmax!(h, length(h))
282-

0 commit comments

Comments
 (0)