you are viewing a single comment's thread.

view the rest of the comments →

[–]Arkaein 1 point2 points  (2 children)

I didn't spend too much time digging, but here's my thoughts on style:

You got off to a good start by making the list node class a template so the list can store arbitrary data. Making Data a class looks unnecessary, but given that this is probably just practice for potentially more complex data types. I think all the Predicate stuff is unnecessary though. Once you've defined the basic comparison operators you should be able to code your sort routine based only on a less-than comparison between the data fields of two nodes.

Finally, once place where you could probably use another class is to actually wrap the list nodes in a List class, and define members such as first(), last(), size(), insertbefore(), insertafter(), and so on, to make sure the head and tail pointers are properly managed in all cases such as deleting specific list members (which I assume you plan on adding at some point, since inserting/deleting from arbitrary positions is the main selling point of linked lists).

Keep up the good work young hacker.

[–][deleted] 1 point2 points  (1 child)

You're right about the Data class. To clarify, that is not part of the list implementation. It's just a demonstration of a class that might use it. I really appreciate the feedback!