Liste des Groupes | Revenir à cl c |
On 24.08.24 19:49, Bonita Montero wrote:Not stupid because in C++ you've got a tenth of the work.Am 18.08.2024 um 10:03 schrieb Mark Summerfield:Ultra stupid. This is a c newsgroup.
>void vec_insert(vec* v, size_t index, void* value) {>
if (v->_size == v->_cap) {
vec_grow(v);
}
for (size_t i = v->_size - 1; i >= index; --i) {
v->_values[i + 1] = v->_values[i];
if (!i) // if i == 0, --i will wrap!
break;
}
v->_values[index] = value;
v->_size++;
}
Ultra-ugly, better use C++ and std::vector<>::emplace_back()/emplace().
>
Date | Sujet | # | Auteur | |
18 Aug 24 | size_t best practice | 23 | Mark Summerfield | |
18 Aug 24 | Re: size_t best practice | 3 | Ike Naar | |
18 Aug 24 | Re: size_t best practice | 2 | Mark Summerfield | |
20 Aug 24 | Re: size_t best practice | 1 | Andrey Tarasevich | |
18 Aug 24 | Re: size_t best practice | 1 | Michael S | |
18 Aug 24 | Re: size_t best practice | 1 | Tim Rentsch | |
18 Aug 24 | Re: size_t best practice | 6 | Stefan Ram | |
18 Aug 24 | Re: size_t best practice | 4 | Michael S | |
19 Aug 24 | Re: size_t best practice | 3 | Tim Rentsch | |
19 Aug 24 | Re: size_t best practice | 2 | Michael S | |
19 Aug 24 | Re: size_t best practice | 1 | Tim Rentsch | |
18 Aug 24 | Re: size_t best practice | 1 | Tim Rentsch | |
20 Aug 24 | Re: size_t best practice | 7 | Andrey Tarasevich | |
20 Aug 24 | Re: size_t best practice | 3 | Andrey Tarasevich | |
20 Aug 24 | Re: size_t best practice | 2 | Andrey Tarasevich | |
22 Aug 24 | Re: size_t best practice | 1 | Tim Rentsch | |
22 Aug 24 | Re: size_t best practice | 3 | Tim Rentsch | |
22 Aug 24 | Re: size_t best practice | 2 | Ike Naar | |
22 Aug 24 | Re: size_t best practice | 1 | Tim Rentsch | |
24 Aug 24 | Re: size_t best practice | 3 | Bonita Montero | |
25 Aug 24 | Re: size_t best practice | 2 | Bonita Montero | |
26 Aug 24 | Re: size_t best practice | 1 | Vir Campestris | |
27 Aug 24 | Re: size_t best practice | 1 | Bonita Montero |
Les messages affichés proviennent d'usenet.