diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2025-12-01 11:53:08 +0000 |
|---|---|---|
| committer | gingerBill <gingerBill@users.noreply.github.com> | 2025-12-01 11:53:08 +0000 |
| commit | 3771ff7b123bf1debe2da2886d833791ee890b39 (patch) | |
| tree | 69cc14a85ef5cb47ede1280df76f6206aa934d00 /core/container/small_array | |
| parent | 9f80d697027a41a9c36b8eb42d9c98f9b7fcbe2c (diff) | |
| parent | e72aad983bb683858a1aee935b2956ced40f69f8 (diff) | |
Merge branch 'master' into vendor/curl
Diffstat (limited to 'core/container/small_array')
| -rw-r--r-- | core/container/small_array/small_array.odin | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/core/container/small_array/small_array.odin b/core/container/small_array/small_array.odin index 1d9795db8..b1674566d 100644 --- a/core/container/small_array/small_array.odin +++ b/core/container/small_array/small_array.odin @@ -105,8 +105,13 @@ This operation assumes that the small-array is large enough. This will result in: - the value if 0 <= index < len - - the zero value of the type if len < index < capacity - - 'crash' if capacity < index or index < 0 + - raise a bounds check error if capacity <= index + - the previous value if len < index < capacity, which defauls to T's zero value. + + e.g. if you call `small_array.push(&a, 0, 1, 2)`, and `i := pop_back(&a)`, + then `get(a, 2)` will return the earlier value `2` at that location. + + See also `get_safe`, which returns T's zero value and `false` if `index` is out of bounds. **Inputs** - `a`: The small-array @@ -125,8 +130,13 @@ This operation assumes that the small-array is large enough. This will result in: - the pointer if 0 <= index < len - - the pointer to the zero value if len < index < capacity - - 'crash' if capacity < index or index < 0 + - raise a bounds check error if capacity <= index + - a pointer to the previous value if len < index < capacity, which defauls to T's zero value. + + e.g. if you call `small_array.push(&a, 0, 1, 2)`, and `i := pop_back(&a)`, + then `get_ptr(a, 2)` will return a pointer to the slot containing the earlier value `2` at that location. + + See also `get_ptr_safe`, which returns a nil pointer, and `false` if `index` is out of bounds. **Inputs** - `a`: A pointer to the small-array @@ -309,7 +319,7 @@ Example: import "core:container/small_array" import "core:fmt" - non_zero_resize :: proc() { + non_zero_resize_example :: proc() { a: small_array.Small_Array(5, int) small_array.push_back(&a, 1) |