File include/jlib/darray.h changed (mode: 100644) (index 2fbb598..b6cfdc6) |
... |
... |
namespace jl { template<typename T, typename G = grow_policy<>> struct darray; } |
17 |
17 |
* |
* |
18 |
18 |
* Made for usage without constructors, destructors, exceptions. |
* Made for usage without constructors, destructors, exceptions. |
19 |
19 |
* |
* |
20 |
|
* Before using any function, darray must be initialized |
|
|
20 |
|
* Before using a function, darray must be initialized |
21 |
21 |
* by any of darray::init functions |
* by any of darray::init functions |
22 |
22 |
* |
* |
23 |
23 |
* Methods in jl::item_call specifies what to do with elements |
* Methods in jl::item_call specifies what to do with elements |
|
... |
... |
struct jl::darray |
50 |
50 |
/** |
/** |
51 |
51 |
* @brief Initialize array with reserved allocated memory. |
* @brief Initialize array with reserved allocated memory. |
52 |
52 |
* |
* |
53 |
|
* Function must not be called if darray was already initialized and not destroyed. |
|
|
53 |
|
* Function must not be called if darray was already |
|
54 |
|
* initialized and not destroyed. |
54 |
55 |
* |
* |
55 |
56 |
* @param[in] reserved_count Reserved count of items, |
* @param[in] reserved_count Reserved count of items, |
56 |
57 |
* which can fit without reallocating the array |
* which can fit without reallocating the array |
57 |
58 |
* @return If memory allocation failed, false is returned |
* @return If memory allocation failed, false is returned |
58 |
|
* and darray is an undefined state. |
|
|
59 |
|
* and darray is in an undefined state. |
59 |
60 |
*/ |
*/ |
60 |
61 |
[[nodiscard]] bool init(size_t reserved_count) |
[[nodiscard]] bool init(size_t reserved_count) |
61 |
62 |
{ |
{ |
|
... |
... |
struct jl::darray |
72 |
73 |
/** |
/** |
73 |
74 |
* @brief Set array item count to zero. |
* @brief Set array item count to zero. |
74 |
75 |
* |
* |
75 |
|
* Function will not do anything with items, |
|
76 |
|
* just will make darray to forget about them. |
|
77 |
|
* Array items will be unaccessible after, |
|
78 |
|
* so they must be cleaned up before, if needed. |
|
|
76 |
|
* The items must be cleaned up beforehand, if needed. |
79 |
77 |
* Memory allocation size will be unchanged. |
* Memory allocation size will be unchanged. |
80 |
78 |
*/ |
*/ |
81 |
79 |
void clean() { p_end = p_begin_allocated; } |
void clean() { p_end = p_begin_allocated; } |
82 |
80 |
|
|
83 |
81 |
/** |
/** |
84 |
|
* @brief Destroy all array items by using pointer to function |
|
85 |
|
* or to member function. |
|
|
82 |
|
* @brief Destroy all array items by using pointer |
|
83 |
|
* to function or to member function. |
86 |
84 |
* |
* |
87 |
|
* Function reduce used elements count to 0, |
|
88 |
|
* while allocated size unchanged. |
|
89 |
|
* Array items will be unaccessible after, |
|
90 |
|
* so they must be cleaned up by item_call meshod. |
|
|
85 |
|
* Function reduces used elements count to 0, |
|
86 |
|
* while allocated size remains unchanged. |
|
87 |
|
* Array items will become unaccessible, |
|
88 |
|
* so they must be cleaned up by item_call method. |
91 |
89 |
* |
* |
92 |
90 |
* @tparam P_FOO Type of pointer to function or to member function. |
* @tparam P_FOO Type of pointer to function or to member function. |
93 |
|
* @tparam Args Parameters pack template, should not be specified |
|
94 |
|
* in template instantiation |
|
|
91 |
|
* @tparam Args Parameter pack template, should not be specified |
|
92 |
|
* in template instantiation. |
95 |
93 |
* @param[in] pfoo Pointer to function with first argument must be |
* @param[in] pfoo Pointer to function with first argument must be |
96 |
|
* copy or refference of item (T) |
|
|
94 |
|
* a copy, a refference of item (T) |
97 |
95 |
* or pointer to member function. |
* or pointer to member function. |
98 |
96 |
* @param[in,out] args Pack of arguments to pass to pfoo function. |
* @param[in,out] args Pack of arguments to pass to pfoo function. |
99 |
97 |
*/ |
*/ |
|
... |
... |
struct jl::darray |
108 |
106 |
/** |
/** |
109 |
107 |
* @brief Deallocate memory used by darray. |
* @brief Deallocate memory used by darray. |
110 |
108 |
* |
* |
111 |
|
* All items in the array will be unavailable after. |
|
|
109 |
|
* All items in the array will become unavailable. |
112 |
110 |
* |
* |
113 |
111 |
* @see darray::clean |
* @see darray::clean |
114 |
112 |
* @see darray::destroy |
* @see darray::destroy |
|
... |
... |
struct jl::darray |
154 |
152 |
[[nodiscard]] uint8_t count8() const |
[[nodiscard]] uint8_t count8() const |
155 |
153 |
{ return uint8_t (count()); } |
{ return uint8_t (count()); } |
156 |
154 |
|
|
157 |
|
///@brief Count of items, which can fit without growing allocation size. |
|
|
155 |
|
///@brief Count of items, which can fit without increasing allocation size. |
158 |
156 |
[[nodiscard]] size_t reserved_count() const |
[[nodiscard]] size_t reserved_count() const |
159 |
157 |
{ return size_t(p_end_allocated - p_end) / sizeof(T); } |
{ return size_t(p_end_allocated - p_end) / sizeof(T); } |
160 |
158 |
|
|
|
... |
... |
struct jl::darray |
173 |
171 |
} |
} |
174 |
172 |
|
|
175 |
173 |
///@brief Reduce allocated size to max_item_count, |
///@brief Reduce allocated size to max_item_count, |
176 |
|
/// but only if used_size is less and allocated size is greater. |
|
|
174 |
|
/// if max_item_count is greater than used_size and less than allocated size. |
177 |
175 |
bool cut_if_oversize(size_t max_item_count) { |
bool cut_if_oversize(size_t max_item_count) { |
178 |
176 |
if (count() < max_item_count |
if (count() < max_item_count |
179 |
177 |
and size_allocated() > max_item_count * sizeof(T)) |
and size_allocated() > max_item_count * sizeof(T)) |
|
... |
... |
struct jl::darray |
191 |
189 |
* @brief Set reserved count of items. |
* @brief Set reserved count of items. |
192 |
190 |
* |
* |
193 |
191 |
* @param[in] count Set count of items to be reserved, overwriting existing |
* @param[in] count Set count of items to be reserved, overwriting existing |
194 |
|
* value, function will ignore if reserved count already |
|
195 |
|
* larger or equal than requested count. |
|
196 |
|
* @return if needed to reallocated memory and reallocation fails, |
|
197 |
|
* false is returned, requested reserved count will not be set. |
|
|
192 |
|
* value, function will do nothing if reserved count already |
|
193 |
|
* larger or equal to requested count. |
|
194 |
|
* @return if memory reallocation is needed and it fails, |
|
195 |
|
* false is returned and requested reserved count will not be set. |
198 |
196 |
*/ |
*/ |
199 |
197 |
[[nodiscard]] bool reserve(size_t count) { |
[[nodiscard]] bool reserve(size_t count) { |
200 |
198 |
int64_t extra_count = int64_t(count - reserved_count()); |
int64_t extra_count = int64_t(count - reserved_count()); |
|
... |
... |
struct jl::darray |
208 |
206 |
/** |
/** |
209 |
207 |
* @brief Insert specified count of items without initializing them. |
* @brief Insert specified count of items without initializing them. |
210 |
208 |
* |
* |
211 |
|
* @param[in] count Count of items to insert, default is 1. |
|
|
209 |
|
* @param[in] count Count of items to insert, 1 by default. |
212 |
210 |
* |
* |
213 |
211 |
* @return False if reserved count is less than insertion |
* @return False if reserved count is less than insertion |
214 |
212 |
* count and memory reallocation fails. |
* count and memory reallocation fails. |
|
... |
... |
struct jl::darray |
223 |
221 |
/** |
/** |
224 |
222 |
* @brief Insert specified count of items and call function for them. |
* @brief Insert specified count of items and call function for them. |
225 |
223 |
* |
* |
226 |
|
* Point of pfoo pointer to function or to member |
|
227 |
|
* function is to initialize items. |
|
228 |
|
* Example, conditionally initializing 10 ints with value 4 or 3: |
|
|
224 |
|
* pfoo pointer to function or to member |
|
225 |
|
* function is used to initialize items. |
|
226 |
|
* Example: conditionally initializing 10 ints with value 4 or 3: |
229 |
227 |
* @code |
* @code |
230 |
228 |
* bool is_true = true; |
* bool is_true = true; |
231 |
229 |
* darray<int> da = {}; |
* darray<int> da = {}; |
|
... |
... |
struct jl::darray |
236 |
234 |
* @tparam Args Parameters pack template, |
* @tparam Args Parameters pack template, |
237 |
235 |
* should not be specified in template instantiation |
* should not be specified in template instantiation |
238 |
236 |
* |
* |
239 |
|
* @param[in] count Count of items to insert, default is 1. |
|
240 |
|
* @param[in] pfoo Pointer to function with first argument |
|
241 |
|
* must be pointer to item (T*) |
|
242 |
|
* or pointer to member function. |
|
|
237 |
|
* @param[in] count Count of items to insert, 1 by default. |
|
238 |
|
* @param[in] pfoo Pointer to function where first argument |
|
239 |
|
* must be a pointer to item (T*) |
|
240 |
|
* or to member function. |
243 |
241 |
* @param[in,out] args Pack of arguments to pass to pfoo function. |
* @param[in,out] args Pack of arguments to pass to pfoo function. |
244 |
242 |
* |
* |
245 |
243 |
* @return False if reserved count is less than insertion |
* @return False if reserved count is less than insertion |
|
... |
... |
struct jl::darray |
289 |
287 |
} |
} |
290 |
288 |
|
|
291 |
289 |
/** |
/** |
292 |
|
* @brief Insert single item, copied from value, to the end. |
|
|
290 |
|
* @brief Copy an item from value and insert it in the and of the array. |
293 |
291 |
* |
* |
294 |
|
* @param[in] value Item value to be copited to new item in the end of array |
|
|
292 |
|
* @param[in] value Item value that gets copied to new item in |
|
293 |
|
* the end of array |
295 |
294 |
* @return False if reserved count is zero |
* @return False if reserved count is zero |
296 |
295 |
* and memory reallocation fails. |
* and memory reallocation fails. |
297 |
296 |
*/ |
*/ |
|
... |
... |
struct jl::darray |
303 |
302 |
} |
} |
304 |
303 |
|
|
305 |
304 |
/** |
/** |
306 |
|
* @brief Insert single item, copied from value, |
|
307 |
|
* to position of iterator pointed to. |
|
|
305 |
|
* @brief Copy an item from value and insert it |
|
306 |
|
* in the position pointed by itterator. |
308 |
307 |
* |
* |
309 |
308 |
* All items from position of iterator to the end of the array |
* All items from position of iterator to the end of the array |
310 |
|
* will be moved by 1 position right, to free space for new item. |
|
|
309 |
|
* will be moved 1 position to the right, to free up the space for new item. |
311 |
310 |
* |
* |
312 |
|
* @param[in] value Item value to be copited to new item |
|
|
311 |
|
* @param[in] value Item value that gets copied to new item |
313 |
312 |
* in the position of iterator |
* in the position of iterator |
314 |
|
* @param[in] iterator Valid pointer to the item in the range [begin,end]. |
|
|
313 |
|
* @param[in] iterator Valid pointer to the item in range [begin,end]. |
315 |
314 |
* @return False if reserved count is zero and memory reallocation fails. |
* @return False if reserved count is zero and memory reallocation fails. |
316 |
315 |
*/ |
*/ |
317 |
316 |
[[nodiscard]] bool insert(const T &value, T* iterator) { |
[[nodiscard]] bool insert(const T &value, T* iterator) { |
|
... |
... |
struct jl::darray |
324 |
323 |
} |
} |
325 |
324 |
|
|
326 |
325 |
/** |
/** |
327 |
|
* @brief Insert single item, copied from value, to the index position. |
|
|
326 |
|
* @brief Copy an item from value and insert it to the index position. |
328 |
327 |
* |
* |
329 |
328 |
* All items from index position to the end of the array |
* All items from index position to the end of the array |
330 |
|
* will be moved by 1 position right, to free space for new item. |
|
|
329 |
|
* will be moved 1 position right, to free up the space for new item. |
331 |
330 |
* |
* |
332 |
|
* @param[in] value Item value to be copited to new item by index |
|
|
331 |
|
* @param[in] value Item value that gets copied to new item by index |
333 |
332 |
* @param[in] index Ofset from darray::begin, |
* @param[in] index Ofset from darray::begin, |
334 |
333 |
* not greater or equal than darray::count. |
* not greater or equal than darray::count. |
335 |
334 |
* @return False if reserved count is zero and memory reallocation fails. |
* @return False if reserved count is zero and memory reallocation fails. |
|
... |
... |
struct jl::darray |
340 |
339 |
} |
} |
341 |
340 |
|
|
342 |
341 |
/** |
/** |
343 |
|
* @brief Remove item by iterator position. |
|
|
342 |
|
* @brief Remove item at iterator position. |
344 |
343 |
* |
* |
345 |
|
* All items after removed one will be shifted to the left by 1 |
|
346 |
|
* to fill freed slot. |
|
|
344 |
|
* After an item gets removed all other items will be shifted to the left |
|
345 |
|
* by 1 to fill the freed slot. |
347 |
346 |
* |
* |
348 |
|
* @param[in] iterator Valid pointer to the item in the range [begin,end). |
|
|
347 |
|
* @param[in] iterator Valid pointer to the item in range [begin,end). |
349 |
348 |
* |
* |
350 |
349 |
* @see darray::begin |
* @see darray::begin |
351 |
350 |
* @see darray::end |
* @see darray::end |
|
... |
... |
struct jl::darray |
360 |
359 |
} |
} |
361 |
360 |
|
|
362 |
361 |
/** |
/** |
363 |
|
* @brief Call function with item from iterator position, and remove. |
|
|
362 |
|
* @brief Call function for an item from iterator position, and remove it. |
364 |
363 |
* |
* |
365 |
|
* All items after removed one will be shifted to the left by 1 |
|
366 |
|
* to fill freed slot. |
|
|
364 |
|
* After an item gets removed all other items will be shifted to the left |
|
365 |
|
* by 1 to fill the freed slot. |
367 |
366 |
* |
* |
368 |
|
* @param[in] iterator Valid pointer to the item in the range [begin,end). |
|
|
367 |
|
* @param[in] iterator Valid pointer to item in the range [begin,end). |
369 |
368 |
* @param[in] pfoo Pointer to function with first argument must be |
* @param[in] pfoo Pointer to function with first argument must be |
370 |
369 |
* pointer to item (T*) or pointer to member function. |
* pointer to item (T*) or pointer to member function. |
371 |
|
* @param[in,out] args Pack of arguments for function call. |
|
|
370 |
|
* @param[in,out] args Pack of arguments used to call the function. |
372 |
371 |
* |
* |
373 |
372 |
* @see darray::begin |
* @see darray::begin |
374 |
373 |
* @see darray::end |
* @see darray::end |
|
... |
... |
struct jl::darray |
383 |
382 |
} |
} |
384 |
383 |
|
|
385 |
384 |
/** |
/** |
386 |
|
* @brief Remove item by index. |
|
|
385 |
|
* @brief Remove item based on index. |
387 |
386 |
* |
* |
388 |
|
* Same function as darray::remove, but by index istead of pointer. |
|
|
387 |
|
* Same as darray::remove |
|
388 |
|
* Removes an item, but based on index istead of pointer. |
389 |
389 |
* |
* |
390 |
390 |
* @param[in] index Offset from darray::begin, |
* @param[in] index Offset from darray::begin, |
391 |
391 |
* must be less than darray::count. |
* must be less than darray::count. |
|
... |
... |
struct jl::darray |
394 |
394 |
void remove(size_t index) { remove(begin() + index); } |
void remove(size_t index) { remove(begin() + index); } |
395 |
395 |
|
|
396 |
396 |
/** |
/** |
397 |
|
* @brief Call function with item and remove this item by index. |
|
|
397 |
|
* @brief Call function for an item and remove this item based on index. |
398 |
398 |
* |
* |
399 |
|
* Same function as darray::remove, but by index istead of pointer. |
|
|
399 |
|
* Same as darray::remove. |
|
400 |
|
* Removes an item, but based on index istead of pointer. |
400 |
401 |
* |
* |
401 |
402 |
* @param[in] index Ofset from darray::begin, |
* @param[in] index Ofset from darray::begin, |
402 |
|
* not greater or equal than darray::count. |
|
|
403 |
|
* must be less or equal to darray::count. |
403 |
404 |
* @see darray::remove |
* @see darray::remove |
404 |
405 |
*/ |
*/ |
405 |
406 |
template<typename P_FOO, typename ... Args> |
template<typename P_FOO, typename ... Args> |
|
... |
... |
struct jl::darray |
413 |
414 |
return *end(); |
return *end(); |
414 |
415 |
} |
} |
415 |
416 |
|
|
416 |
|
/// @brief Put last item to *p_dst, remove and return true, |
|
|
417 |
|
/// @brief Put last item to *p_dst, remove it and return true, |
417 |
418 |
/// if array is not empty, otherwise return false. |
/// if array is not empty, otherwise return false. |
418 |
419 |
[[nodiscard]] bool remove_last_if_exist(T *p_dst) { |
[[nodiscard]] bool remove_last_if_exist(T *p_dst) { |
419 |
420 |
if (count() > 0) |
if (count() > 0) |
|
... |
... |
struct jl::darray |
427 |
428 |
* |
* |
428 |
429 |
* @param[in] pfoo_cond Function or member function, must return bool. |
* @param[in] pfoo_cond Function or member function, must return bool. |
429 |
430 |
* Item will be removed if true is returned. Function |
* Item will be removed if true is returned. Function |
430 |
|
* must take item copy or refference in the |
|
|
431 |
|
* must take an item copy or refference in the |
431 |
432 |
* first argument, member function does not. |
* first argument, member function does not. |
432 |
433 |
* |
* |
433 |
434 |
* @param[in,out] args Argument pack to pass to function or member function. |
* @param[in,out] args Argument pack to pass to function or member function. |
|
... |
... |
struct jl::darray |
443 |
444 |
} |
} |
444 |
445 |
|
|
445 |
446 |
/** |
/** |
446 |
|
* @brief Get pointer to item, which is equal to value_to_search. |
|
|
447 |
|
* @brief Get pointer of an item, which is equal to value_to_search. |
447 |
448 |
* |
* |
448 |
449 |
* @tparam T_CMP T type must have overloaded "==" |
* @tparam T_CMP T type must have overloaded "==" |
449 |
|
* operator for value of type T_CMP |
|
450 |
|
* @param[in] value_to_search Value of type T_CMP for searching |
|
451 |
|
* @param[out] p_p_dst Pointer to variable, for placing pointer |
|
452 |
|
* to found item on success |
|
|
450 |
|
* operator for value of T_CMP type |
|
451 |
|
* @param[in] value_to_search Value of T_CMP type for searching |
|
452 |
|
* @param[out] p_p_dst Pointer to variable, for placing a pointer |
|
453 |
|
* on item found upon success |
453 |
454 |
* @return bool "is item found" |
* @return bool "is item found" |
454 |
455 |
*/ |
*/ |
455 |
456 |
template<typename T_CMP> |
template<typename T_CMP> |
|
... |
... |
struct jl::darray |
457 |
458 |
{ return search(begin(), end(), value_to_search, p_p_dst); } |
{ return search(begin(), end(), value_to_search, p_p_dst); } |
458 |
459 |
|
|
459 |
460 |
/** |
/** |
460 |
|
* @brief Get copy of item, which is equal to value_to_search. |
|
|
461 |
|
* @brief Get a copy of an item, which is equal to value_to_search. |
461 |
462 |
* |
* |
462 |
|
* Same as darray::find, but for getting found value copy, instead of pointer. |
|
|
463 |
|
* Same as darray::find. |
|
464 |
|
* but for getting found value copy, instead of pointer. |
463 |
465 |
* |
* |
464 |
|
* @param[out] p_dst Pointer to variable for placing copy |
|
465 |
|
* of found item on success |
|
|
466 |
|
* @param[out] p_dst Pointer to variable, for placing a copy |
|
467 |
|
* of found item upon success |
466 |
468 |
* @see darray::find |
* @see darray::find |
467 |
469 |
*/ |
*/ |
468 |
470 |
template<typename T_CMP> |
template<typename T_CMP> |
|
... |
... |
struct jl::darray |
474 |
476 |
} |
} |
475 |
477 |
|
|
476 |
478 |
/** |
/** |
477 |
|
* @brief Get pointer to the begin of memory where items are stored. |
|
478 |
|
* @return Pointer to the begin of memory. |
|
|
479 |
|
* @brief Get pointer to the beginning of memory where items are stored. |
|
480 |
|
* @return Pointer to the beginning of memory. |
479 |
481 |
*/ |
*/ |
480 |
482 |
[[nodiscard]] T* begin() |
[[nodiscard]] T* begin() |
481 |
483 |
{ return reinterpret_cast<T*>(p_begin_allocated); } |
{ return reinterpret_cast<T*>(p_begin_allocated); } |
482 |
484 |
/** |
/** |
483 |
|
* @brief Get pointer to the begin of memory where items are stored |
|
|
485 |
|
* @brief Get pointer to the beginning of memory where items are stored |
484 |
486 |
* with read-only access. |
* with read-only access. |
485 |
|
* @return Pointer to the begin of memory where items are stored |
|
|
487 |
|
* @return Pointer to the beginning of memory where items are stored |
486 |
488 |
* with read-only access. |
* with read-only access. |
487 |
489 |
*/ |
*/ |
488 |
490 |
[[nodiscard]] const T* begin() const |
[[nodiscard]] const T* begin() const |
489 |
491 |
{ return reinterpret_cast<T*>(p_begin_allocated); } |
{ return reinterpret_cast<T*>(p_begin_allocated); } |
490 |
492 |
|
|
491 |
493 |
/** |
/** |
492 |
|
* @brief Get pointer to first byte after the last item. |
|
493 |
|
* @return Pointer with read-only access to first byte after last item |
|
494 |
|
* in the array, or to the begin of memory where items are stored, |
|
|
494 |
|
* @brief Get pointer to the first byte after the last item. |
|
495 |
|
* @return Pointer with read-only access to the first byte after the last item |
|
496 |
|
* in the array, or to the beginning of memory where items are stored, |
495 |
497 |
* if item count is zero. |
* if item count is zero. |
496 |
498 |
*/ |
*/ |
497 |
499 |
[[nodiscard]] T* end() |
[[nodiscard]] T* end() |
498 |
500 |
{ return reinterpret_cast<T*>(p_end); } |
{ return reinterpret_cast<T*>(p_end); } |
499 |
501 |
|
|
500 |
502 |
/** |
/** |
501 |
|
* @brief Get pointer to first byte after the last item with read-only access. |
|
502 |
|
* @return Pointer with read-only access to first byte after last item |
|
503 |
|
* in the array, or to the begin of memory where items are stored, |
|
|
503 |
|
* @brief Get pointer to the first byte after the last item with read-only access. |
|
504 |
|
* @return Pointer with read-only access to the first byte after the last item |
|
505 |
|
* in the array, or to the begining of memory where items are stored, |
504 |
506 |
* if item count is zero. |
* if item count is zero. |
505 |
507 |
*/ |
*/ |
506 |
508 |
[[nodiscard]] const T* end() const |
[[nodiscard]] const T* end() const |
507 |
509 |
{ return reinterpret_cast<T*>(p_end); } |
{ return reinterpret_cast<T*>(p_end); } |
508 |
510 |
|
|
509 |
511 |
/** |
/** |
510 |
|
* @brief Get refference to item by index. |
|
|
512 |
|
* @brief Get a refference to item by index. |
511 |
513 |
* |
* |
512 |
514 |
* Must not be called if current item count is zero |
* Must not be called if current item count is zero |
513 |
515 |
* |
* |
514 |
516 |
* @param[in] i Index-offset, specified by item count, from begining |
* @param[in] i Index-offset, specified by item count, from begining |
515 |
517 |
* of the array, must be less than item count. |
* of the array, must be less than item count. |
516 |
|
* @return Refference to item, stored by index. |
|
|
518 |
|
* @return Refference to item by index. |
517 |
519 |
* |
* |
518 |
520 |
* @see darray::count |
* @see darray::count |
519 |
521 |
*/ |
*/ |
|
... |
... |
struct jl::darray |
529 |
531 |
* |
* |
530 |
532 |
* @param[in] i Index-offset, specified by item count, from begining |
* @param[in] i Index-offset, specified by item count, from begining |
531 |
533 |
* of the array, must be less than item count. |
* of the array, must be less than item count. |
532 |
|
* @return Read-only refference to item, stored by index. |
|
|
534 |
|
* @return Read-only refference to item by index. |
533 |
535 |
* |
* |
534 |
536 |
* @see darray::count |
* @see darray::count |
535 |
537 |
*/ |
*/ |
|
... |
... |
struct jl::darray |
555 |
557 |
* |
* |
556 |
558 |
* @param[in] count_to_add Count of items that must fit in the array |
* @param[in] count_to_add Count of items that must fit in the array |
557 |
559 |
* after resize. |
* after resize. |
558 |
|
* @return If true is returned, than array can fit count_to add, |
|
559 |
|
* else false is returned, signaling that reallocation failed. |
|
|
560 |
|
* @return If true is returned, array can fit count_to_add. |
|
561 |
|
* if false is returned, reallocation failed. |
560 |
562 |
* @see insert_no_resize_check |
* @see insert_no_resize_check |
561 |
563 |
*/ |
*/ |
562 |
564 |
[[nodiscard]] bool resize_if_full(size_t count_to_add = 0) { |
[[nodiscard]] bool resize_if_full(size_t count_to_add = 0) { |