Skip to content

Commit 4af2ff7

Browse files
committed
arr: Better document insertAt.
Be a little more explicit on what the valid insertion options are, in particular, that it's possible to insert at the very end. Document the complexity accurately.
1 parent b698c7a commit 4af2ff7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/csnip/arr.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@
119119
* The members currently at the given position and after are moved
120120
* back one index.
121121
*
122-
* Complexity: n - index element moves.
122+
* Note that for an array of size n, there are n + 1 valid
123+
* insertion positions p: 0 <= p <= n.
124+
*
125+
* Complexity: (n - p) moves + amortized O(n) resize cost.
123126
*/
124127
#define csnip_arr_InsertAt(a, n, cap, index, val, err) \
125128
do { \

0 commit comments

Comments
 (0)