:: Re: [DNG] Experiencing with GtkBuil…
Inizio della pagina
Delete this message
Reply to this message
Autore: Roger Leigh
Data:  
To: dng
Oggetto: Re: [DNG] Experiencing with GtkBuilder
On 23/11/2015 11:49, Nate Bargmann wrote:
> * On 2015 23 Nov 00:53 -0600, aitor_czr wrote:
>> In my opinion, using C with lists will be the most suitable.
>
> Have you looked at what glib provides? It is an underlying library of
> GTK and seems to contain many such solutions.


Using GLib for structures like linked lists (GList) etc. is a much
better solution than reinventing them unnecessarily. That said, many of
them are poorly implemented--e.g. GList appending is O(n) rather than
O(1) if you only keep track of the first element; there's no "list head"
to manage this (a major omission on their part). So then you need to
keep track of both ends by hand and keep them both up-to-date... and it
ends up creating additional overhead on your part. So it's far cruder
than e.g. C++ std::vector<T> or std::list<T>. If you're going to do a
lot of insertion/deletion/traversal then you'll find the C++ containers
both simpler and more efficient in most cases, not to mention more
robust. If you use e.g. std::vector<T> you can still use it with C
functions which want a T[] or T* via its data() method.


Regards,
Roger