Skip to content

Commit 541cd12

Browse files
committed
rename rank to sorted_rank
1 parent 50eeaed commit 541cd12

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

docs/src/avl_tree.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ julia> for k in 1:2:20
1818
julia> haskey(tree, 3)
1919
true
2020
21-
julia> tree[4] # this operation is O(log n)
21+
julia> tree[4] # time complexity of this operation is O(log n)
2222
7
2323
2424
julia> for k in 1:2:10
@@ -28,7 +28,7 @@ julia> for k in 1:2:10
2828
julia> haskey(tree, 5)
2929
false
3030
31-
julia> rank(tree, 17)
31+
julia> sorted_rank(tree, 17) # used for finding rank of the key
3232
4
3333
```
3434

src/DataStructures.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ module DataStructures
6060
export DiBitVector
6161

6262
export RBTree, search_node, minimum_node
63-
export AVLTree, rank
63+
export AVLTree, sorted_rank
6464

6565
export findkey
6666

src/avl_tree.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,11 @@ function Base.delete!(tree::AVLTree{K}, d::K) where K
229229
end
230230

231231
"""
232-
rank(tree::AVLTree, key)
232+
sorted_rank(tree::AVLTree, key)
233233
234234
Returns the rank of `key` present in the `tree`, if it present. A KeyError is thrown if `key` is not present.
235235
"""
236-
function rank(tree::AVLTree{K}, key::K) where K
236+
function sorted_rank(tree::AVLTree{K}, key::K) where K
237237
!haskey(tree, key) && throw(KeyError(key))
238238
node = tree.root
239239
rank = 0

test/test_avl_tree.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@
138138
push!(t9, i)
139139
end
140140
for i in 1:20
141-
@test rank(t9, i) == i
141+
@test sorted_rank(t9, i) == i
142142
end
143-
@test_throws KeyError rank(t9, 21)
143+
@test_throws KeyError sorted_rank(t9, 21)
144144
end
145145
end

0 commit comments

Comments
 (0)