Re: dynamically growing 2D aray of structues



You can always map a 2d coordinate intto 1d:
(i, j) -> i * w + j
where w is the width of the matrix

Ian L.

On Thu, Nov 26, 2009 at 3:04 PM, <mauede alice it> wrote:

As far as I know a GArray grows an array of pointers in 1D not 2D.
I thought of a GArray myself but my question, although not clear, is
how can I use a GArray to grow a 2D array of structures ?
Can you please provide an example ?



Thank you in advance,
Maura

-----Messaggio originale-----
Da: tristan van berkom gmail com per conto di Tristan Van Berkom
Inviato: gio 26/11/2009 6.31
A: mauede alice it
Cc: gtk-list gnome org
Oggetto: Re: dynamically growing 2D aray of structues


On Wed, Nov 25, 2009 at 9:17 PM,  <mauede alice it> wrote:
> I dare ask for some guidelines as I am not a programmer and never came
> across glib before.
> 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:
>
> typedef struct {
>         gchar *id;
>         gchar *description;
>         gchar *sequence;
>         gint sequence_len;
>  } fasta_sequence;
>

Use a GArray:
   http://library.gnome.org/devel/glib/stable/glib-Arrays.html

Cheers,
      -Tristan

>
> Any suggestion is welcome.
> Thank you in advance,
> Maura
>
>
>
>
> Alice Messenger ;-) chatti anche con gli amici di Windows Live Messenger e
> tutti i telefonini TIM!
> Vai su http://maileservizi.alice.it/alice_messenger/index.html?pmk=footer
>
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list
>
>


_______________________________________________
gtk-list mailing list
gtk-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]