You didn't say C or C++.  It makes a difference.  A void pointer is
just a pointer that can point to any kind of data.  You convert it to
a specific type by using casts.  So just implement an exogenous list
the same  way you would if data had some type Foo.  The replace all
the Foo pointers with void*.  In C++ you can wrap the implementation
in a template so the list methods automatically do the casting.

In case you aren't familiar with the term, an exogenous list is just
one where list nodes _point to_ data rather than containing data.  For
example, this list node is exogenous:

typedef struct node_s {
  struct node_s *next;
  FOO *ptr_to_data;  // replace with void* to make this useful for any
data type.
} NODE;

This one is endogenous:

typedef struct node_s {
  struct node_s *next;
  FOO data;
} NODE;

On May 31, 12:19 am, mahendra sengar <sengar.m...@gmail.com> wrote:
> how to implement generioc linked list..using void pointer...i havent
> used void pointer much so, m not able to use it properly in linked
> list..please help asap !!!

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to