Skip to content

Commit e4a377c

Browse files
committed
More HelpDB pruning for Bit/SparseArray, more examples
Yet MORE examples from the REPL. Fixed and added links, changd some wording.
1 parent 2d24eda commit e4a377c

File tree

4 files changed

+368
-73
lines changed

4 files changed

+368
-73
lines changed

base/bitarray.jl

+134
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,25 @@ function (~)(B::BitArray)
10051005
return C
10061006
end
10071007

1008+
"""
1009+
flipbits!(B::BitArray{N}) -> BitArray{N}
1010+
1011+
Performs a bitwise not operation on `B`. See [`~`](:ref:`~ operator <~>`).
1012+
1013+
```jldoctest
1014+
julia> A = bitrand(3,5)
1015+
3×5 BitArray{2}:
1016+
true true true true true
1017+
false false false true false
1018+
true false false false true
1019+
1020+
julia> flipbits!(A)
1021+
3×5 BitArray{2}:
1022+
false false false false false
1023+
true true true false true
1024+
false true true true false
1025+
```
1026+
"""
10081027
function flipbits!(B::BitArray)
10091028
Bc = B.chunks
10101029
@inbounds if !isempty(Bc)
@@ -1416,6 +1435,39 @@ end
14161435

14171436
(>>)(B::BitVector, i::Int) = B >>> i
14181437

1438+
"""
1439+
rol!(dest::BitVector, src::BitVector, i::Integer) -> BitVector
1440+
1441+
Performs a left rotation operation on `src` and put the result into `dest`.
1442+
1443+
```jldoctest
1444+
julia> a = bitrand(5)
1445+
5-element BitArray{1}:
1446+
false
1447+
false
1448+
true
1449+
true
1450+
true
1451+
1452+
julia> b = falses(5);
1453+
1454+
julia> rol!(b,a,2)
1455+
5-element BitArray{1}:
1456+
true
1457+
true
1458+
true
1459+
false
1460+
false
1461+
1462+
julia> rol!(b,a,3)
1463+
5-element BitArray{1}:
1464+
true
1465+
true
1466+
false
1467+
false
1468+
true
1469+
```
1470+
"""
14191471
function rol!(dest::BitVector, src::BitVector, i::Integer)
14201472
length(dest) == length(src) || throw(ArgumentError("destination and source should be of same size"))
14211473
n = length(dest)
@@ -1428,14 +1480,67 @@ function rol!(dest::BitVector, src::BitVector, i::Integer)
14281480
return dest
14291481
end
14301482

1483+
"""
1484+
rol!(B::BitVector, i::Integer) -> BitVector
1485+
1486+
Performs a left rotation operation on `B`.
1487+
1488+
```jldoctest
1489+
julia> a = bitrand(5)
1490+
5-element BitArray{1}:
1491+
true
1492+
false
1493+
false
1494+
true
1495+
true
1496+
1497+
julia> rol!(a,4)
1498+
5-element BitArray{1}:
1499+
true
1500+
true
1501+
false
1502+
false
1503+
true
1504+
"""
14311505
function rol!(B::BitVector, i::Integer)
14321506
return rol!(B, B, i)
14331507
end
14341508

1509+
"""
1510+
rol(B::BitVector, i::Integer) -> BitVector
1511+
1512+
Performs a left rotation operation without modifying `B`.
1513+
See also [`rol!`](:func:`rol!`).
1514+
"""
14351515
function rol(B::BitVector, i::Integer)
14361516
return rol!(similar(B), B, i)
14371517
end
14381518

1519+
"""
1520+
ror!(dest::BitVector, src::BitVector, i::Integer) -> BitVector
1521+
1522+
Performs a right rotation operation on `src` and put the result into `dest`.
1523+
1524+
```jldoctest
1525+
julia> a = bitrand(5)
1526+
5-element BitArray{1}:
1527+
false
1528+
false
1529+
true
1530+
true
1531+
true
1532+
1533+
julia> b = falses(5);
1534+
1535+
julia> ror!(b,a,2)
1536+
5-element BitArray{1}:
1537+
true
1538+
true
1539+
false
1540+
false
1541+
true
1542+
```
1543+
"""
14391544
function ror!(dest::BitVector, src::BitVector, i::Integer)
14401545
length(dest) == length(src) || throw(ArgumentError("destination and source should be of same size"))
14411546
n = length(dest)
@@ -1448,10 +1553,39 @@ function ror!(dest::BitVector, src::BitVector, i::Integer)
14481553
return dest
14491554
end
14501555

1556+
"""
1557+
ror!(B::BitVector, i::Integer) -> BitVector
1558+
1559+
Performs a right rotation operation on `B`.
1560+
1561+
```jldoctest
1562+
julia> a = bitrand(5)
1563+
5-element BitArray{1}:
1564+
false
1565+
true
1566+
false
1567+
true
1568+
false
1569+
1570+
julia> ror!(a,3)
1571+
5-element BitArray{1}:
1572+
false
1573+
true
1574+
false
1575+
false
1576+
true
1577+
```
1578+
"""
14511579
function ror!(B::BitVector, i::Integer)
14521580
return ror!(B, B, i)
14531581
end
14541582

1583+
"""
1584+
ror(B::BitVector, i::Integer) -> BitVector
1585+
1586+
Performs a right rotation operation without modifying `B`.
1587+
See also [`ror!`](:func:`ror!`).
1588+
"""
14551589
function ror(B::BitVector, i::Integer)
14561590
return ror!(similar(B), B, i)
14571591
end

base/docs/helpdb/Base.jl

-49
Original file line numberDiff line numberDiff line change
@@ -400,20 +400,6 @@ Element-wise multiplication operator.
400400
"""
401401
Base.:(.*)
402402

403-
"""
404-
ror!(dest::BitArray{1}, src::BitArray{1}, i::Integer) -> BitArray{1}
405-
406-
Performs a right rotation operation on `src` and put the result into `dest`.
407-
"""
408-
ror!(dest::BitArray{1}, src::BitArray{1}, i::Integer)
409-
410-
"""
411-
ror!(B::BitArray{1}, i::Integer) -> BitArray{1}
412-
413-
Performs a right rotation operation on `B`.
414-
"""
415-
ror!(B::BitArray{1}, i::Integer)
416-
417403
"""
418404
range(start, [step], length)
419405
@@ -805,13 +791,6 @@ Returns `true` if `path` has the sticky bit set, `false` otherwise.
805791
"""
806792
issticky
807793

808-
"""
809-
rol(B::BitArray{1}, i::Integer) -> BitArray{1}
810-
811-
Performs a left rotation operation.
812-
"""
813-
rol
814-
815794
"""
816795
Mmap.mmap(io::Union{IOStream,AbstractString,Mmap.AnonymousMmap}[, type::Type{Array{T,N}}, dims, offset]; grow::Bool=true, shared::Bool=true)
817796
Mmap.mmap(type::Type{Array{T,N}}, dims)
@@ -4330,13 +4309,6 @@ Returns `string` with the first character converted to lowercase.
43304309
"""
43314310
lcfirst
43324311

4333-
"""
4334-
flipbits!(B::BitArray{N}) -> BitArray{N}
4335-
4336-
Performs a bitwise not operation on `B`. See [`~`](:ref:`~ operator <~>`).
4337-
"""
4338-
flipbits!
4339-
43404312
"""
43414313
readlink(path) -> AbstractString
43424314
@@ -7465,20 +7437,6 @@ dims)` will return an array filled with the result of evaluating `Foo()` once.
74657437
"""
74667438
fill
74677439

7468-
"""
7469-
rol!(dest::BitArray{1}, src::BitArray{1}, i::Integer) -> BitArray{1}
7470-
7471-
Performs a left rotation operation on `src` and put the result into `dest`.
7472-
"""
7473-
rol!(::BitArray,::BitArray,::Integer)
7474-
7475-
"""
7476-
rol!(B::BitArray{1}, i::Integer) -> BitArray{1}
7477-
7478-
Performs a left rotation operation on `B`.
7479-
"""
7480-
rol!(::BitArray,::Integer)
7481-
74827440
"""
74837441
issubset(a, b)
74847442
⊆(a,b) -> Bool
@@ -8280,13 +8238,6 @@ Optional argument `msg` is a descriptive error string.
82808238
"""
82818239
AssertionError
82828240

8283-
"""
8284-
ror(B::BitArray{1}, i::Integer) -> BitArray{1}
8285-
8286-
Performs a right rotation operation.
8287-
"""
8288-
ror
8289-
82908241
"""
82918242
Ac_ldiv_Bc(A, B)
82928243

0 commit comments

Comments
 (0)