Are you ever going to have "empty" spots?
Are you linking all directions when you add a node?
Code:
struct foo
{
struct foo *north, *east, *south, *west;
type value;
};
Given a single node, are you linking it to everything in every direction? If I write an insert function:
Code:
int insertatxy( struct foo *n, size_t x, size_t y );
...
insertatxy( n, 3, 4 );
Are you properly linking all of your directions? Assuming I'm understanding what you think you're trying to do. If so, are you sure? What happens if:
Code:
a b c d e
f g h i j
k l m n o
p q r s t
u v w x y
If you were inserting m, you would need to link m->north to h, and h->south to m; m->east to n, and n->west to m; m->south to r, and r->north to m; and finally, m->west to l, and l->east to m.
Are you doing all of that? Are you treating this as if it were really a 2D array of nodes that you're linking, or are you really thinking it's still just a list of lists? If you allow for empty nodes, what happens:
Code:
insertatxy( a,0,0 );
insertatxy( g,1,1 );
How are you checking to see if you can do that?
Quzah.