Skip to main content

Timeline for Singly-linked list library

Current License: CC BY-SA 3.0

5 events
when toggle format what by license comment
Jun 1, 2013 at 23:42 history edited William Morris CC BY-SA 3.0
Removed incorrect (stupid) use of abs
Jun 1, 2013 at 23:40 comment added William Morris oops! Yes, abs is clearly wrong. You could use (unsigned) index >= sllist->size but that will provoke a conversion warning. I will change the answer...
Jun 1, 2013 at 18:28 comment added oddlogic The condition if (abs(index) >= sllist->size) treats negative values greater than or equal to -index as acceptable, but if I change it to if ((abs(index) >= sllist->size) || (index < 0) then I believe we've created a statement that more clearly expresses my intent than if ( ((sllist->size - index - 1) < 0 ) || (index < 0) ) On the other hand, I then have to include cmath.h. I don't believe this is much of a problem, however. What are your thoughts? Everything else you've said I more or less totally agree with.
Jun 1, 2013 at 18:18 comment added oddlogic All solid advice. I'll start with the "nits": I believe my rationale for 'index' is that the user conceivably have their own reasons for accessing a particular index. For example, if the list is created with some kind of order, say a list of prime numbers or something, index 6 would contain the 7th prime number. I think I am going to add some accessor functions and move the structs into the implementation. This would make current more sensible because it would provide an opaque way to move through the list, via sllist_step.
Jun 1, 2013 at 2:57 history answered William Morris CC BY-SA 3.0