On Wed, 2009-11-25 at 15:21 -0800, Maura Monville wrote:
I dare ask for some guidelines as I am not a programmer and never came across glib before... Thasi may not be the right mailing list for such a question ....please, be linient At the time being I have to embed some code into a package (Galopps: a Genetic Algorithm) which is totally implemented in C language. To be consistent with Galopps style I have to use glib functions. I have just started to use the simplest glib primitives and data types. Now I am stuck with the following problem. I know there are a lot of experts out there who can give me a couples of hints. I have to generate a 2D array of structures which grows dynamically in both directions. The structure is defined as follows:
Make it a doubly linked list. Then you can add/remove anywhere in the list typedef struct _fasta_sequence { gchar *id; gchar *description; gchar *sequence; gint sequence_len; struct _fasta_sequence *next, *previous; } fasta_sequence; There are many discussions of manipulating double linked lists. The basic idea is you allocate the addition, and store it either as next or previous. There are details to watch. But google is your friend. If you were just adding to the end, you could use realloc(). But as you want to add to the beginning, this could be problematic. Also, with double linked lists, existing data never moves, so the pointers remain correct as new things are added on both directions. Same when you remove things anywhere in the list. -- You can't just ask customers what they want and then try to give that to them. By the time you get it built, they'll want something new. -- Steve Jobs Roger Oberholtzer Ramböll RST/OPQ Ramböll Sverige AB Krukmakargatan 21 P.O. Box 17009 SE-104 62 Stockholm, Sweden Office: Int +46 8-615 60 20 Mobile: Int +46 70-815 1696 -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org