7 ms·
The & isn't needed if you're returning a pointer and no longer need a pointer to pointer to return the list as an argument. Also, if you get rid of the struct c
by ajarmst 6y ago
The & isn't needed if you're returning a pointer and no longer need a pointer to pointer to return the list as an argument. Also, if you get rid of the struct containing a single pointer and just use pointers, you can have the following instead…
` p=p->next
As for the API, returning the pointer allows a function to be an argument for another function, which I find more flexible.
` p= remove(p,find(p,value))//
I also like the option to be able to do stuff like:
` p=remove(remove(p,t),t); //remove two
or:
` if (!remove(p,t)) {//that was my last node }
But that may be an artifact of my preference for functional programming.
- xpe 6y agoNod, nod, nod. Thanks for clarifying :)