Re: [PATCH 6/9] oid-array: provide a for-loop iterator
On Fri, Dec 04, 2020 at 02:18:45PM -0500, Eric Sunshine wrote:
Show 18 quoted lines
> > + * Find the next unique oid in the array after position "cur". You
> > + * can use this to iterate over unique elements, like:
> > + *
> > + * size_t i;
> > + * oid_array_sort(array);
> > + * for (i = 0; i < array->nr; i = oid_array_next_unique(array, i))
> > + * printf("%s", oid_to_hex(array->oids[i]);
> > + *
> > + * Non-unique iteration can just increment with "i++" to visit each element.
> > + */
>
> Minor: I see that the example code sorts the array first -- which is
> necessary, as explained in the commit message -- but I wonder if it is
> worth calling out explicitly in the prose:
>
> Find the next unique oid in the array after position `cur`.
> The array must be sorted for this to work. You can use
> this to iterate over unique elements like this:Thanks, that makes sense; I picked up your wording here.
-Peff