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. Advertising

  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. Advertising

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:
    491
    emerth
    Jul 10, 2003
  2. Chris Ritchey

    Generating a char* from a linked list of linked lists

    Chris Ritchey, Jul 9, 2003, in forum: C Programming
    Replies:
    7
    Views:
    488
    emerth
    Jul 10, 2003
  3. fool
    Replies:
    14
    Views:
    525
    Barry Schwarz
    Jul 3, 2006
  4. joshd
    Replies:
    12
    Views:
    683
    John Carson
    Oct 2, 2006
  5. jawdoc
    Replies:
    9
    Views:
    777
    Chris Thomasson
    Mar 10, 2008
Loading...

Share This Page