Hi Kenton,

thank you for the explanation.  Due to the complex nature of my structs I 
guess it'd be a better approach to sort the entries before actual creation.

All the best, Stefan

Am Mittwoch, 25. September 2019 20:51:42 UTC+2 schrieb Kenton Varda:
>
> Hi Stefan,
>
> So, a List of structs is actually not encoded as a list of pointers. 
> Instead, the struct bodies appear contiguously. So, to swap two elements in 
> a list of structs, you would need to swap each field value within the two 
> structs. For pointer fields, you could use 
> target.adoptField(source.disownField()) to avoid performing a deep copy. 
> You could write some code based on AnyStruct (capnp/any.h) that does such a 
> swap in a schema-agnostic way, but there's no built-in code for this at 
> present.
>
> List(Text), List(Data), and List(List(T)) are actually encoded as lists of 
> pointers. In those cases the List builders have adopt() and disown() 
> methods that operate on whole elements which you could use to implement 
> swapping pretty easily.
>
> -Kenton
>
> On Wed, Sep 25, 2019 at 5:09 AM Stefan Kaps <[email protected] 
> <javascript:>> wrote:
>
>> Hi @all,
>>
>> during serialization I need to reorder the contents of a list after 
>> creation.  How would I do that?  As far as I understood, it's all 
>> pointers.  So are there capnp::List<> - operators to swap 2 items?
>>
>> All the best,
>> Stefan
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Cap'n Proto" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/capnproto/8fbf6664-fbfc-4aa2-b054-894a8f01137e%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/capnproto/8fbf6664-fbfc-4aa2-b054-894a8f01137e%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/capnproto/22e99464-f811-49ec-86a4-8f0d7dde26ce%40googlegroups.com.

Reply via email to