linked list

Discussion in 'C Programming' started by MJK, Jan 31, 2008.

  1. MJK

    MJK Guest

    Hello all,

    When I am using array in structure to read a pedigree, I can simply
    call an index to see how old is the dad of individual 'i':

    Individual[ individual.dad_id ].Age

    The above example is in a coded pedigree (pedigree starts from
    individual '0').

    I am wondering how I can do the same as above when I am using the
    linked list.

    Thanks,
    MJ
     
    MJK, Jan 31, 2008
    #1
    1. Advertisements

  2. In article <>,
    MJK <> wrote:

    >When I am using array in structure to read a pedigree, I can simply
    >call an index to see how old is the dad of individual 'i':


    >Individual[ individual.dad_id ].Age


    >The above example is in a coded pedigree (pedigree starts from
    >individual '0').


    >I am wondering how I can do the same as above when I am using the
    >linked list.


    If you transform individual into a linked list instead of an
    array, then NO, C does not provide any operations to traverse
    from the head of a list to the i'th node. On the other hand, you
    can easily write your own routine that returns a pointer to
    the i'th node, and then use:

    find_ith( individual, find_ith( individual, i)->dad_id )->Age
    --
    'Roberson' is my family name; my given name is 'Walter'.
     
    Walter Roberson, Jan 31, 2008
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Ritchey
    Replies:
    7
    Views:
    709
    emerth
    Jul 10, 2003
  2. Captn Japan
    Replies:
    2
    Views:
    499
    Karl Heinz Buchegger
    Dec 3, 2003
  3. Chris Ritchey

    Generating a char* from a linked list of linked lists

    Chris Ritchey, Jul 9, 2003, in forum: C Programming
    Replies:
    7
    Views:
    718
    emerth
    Jul 10, 2003
  4. fool
    Replies:
    14
    Views:
    803
    Barry Schwarz
    Jul 3, 2006
  5. joshd
    Replies:
    12
    Views:
    953
    John Carson
    Oct 2, 2006
  6. jawdoc
    Replies:
    9
    Views:
    1,049
    Chris Thomasson
    Mar 10, 2008
  7. mac
    Replies:
    1
    Views:
    1,955
    Jens Thoms Toerring
    May 27, 2008
  8. Angus
    Replies:
    16
    Views:
    1,013
    hanukas
    Mar 18, 2009
Loading...