Skip to content

Commit c118088

Browse files
committed
document complexity of push!
1 parent eb8a084 commit c118088

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

base/docs/helpdb/Base.jl

+4
Original file line numberDiff line numberDiff line change
@@ -1406,6 +1406,10 @@ julia> push!([1, 2, 3], 4, 5, 6)
14061406
6
14071407
```
14081408
1409+
Internally, the storage for the array is increased exponentially (by 50%)
1410+
as needed, so that calling `push!` ``n`` times on an empty array
1411+
involves only ``O(\\log n)`` allocations and ``O(n)`` time.
1412+
14091413
Use [`append!`](:func:`append!`) to add all the elements of another collection to
14101414
`collection`. The result of the preceding example is equivalent to `append!([1, 2, 3], [4,
14111415
5, 6])`.

doc/stdlib/collections.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,8 @@ Dequeues
10221022
5
10231023
6
10241024

1025+
Internally, the storage for the array is increased exponentially (by 50%) as needed, so that calling ``push!`` :math:`n` times on an empty array involves only :math:`O(\log n)` allocations and :math:`O(n)` time.
1026+
10251027
Use :func:`append!` to add all the elements of another collection to ``collection``\ . The result of the preceding example is equivalent to ``append!([1, 2, 3], [4, 5, 6])``\ .
10261028

10271029
.. function:: pop!(collection) -> item

0 commit comments

Comments
 (0)