Skip to content

Commit ac4eb66

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

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
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-1
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
@@ -1385,4 +1387,3 @@ is used, so that elements popped from the heap are given in ascending order.
13851387
.. Docstring generated from Julia source
13861388
13871389
Given a binary heap-ordered array, remove and return the lowest ordered element. For efficiency, this function does not check that the array is indeed heap-ordered.
1388-

0 commit comments

Comments
 (0)