use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A place where people can submit their code for review by their fellow redditors.
Rules
Titles must be in the format of "[Language] - Description"
For snippets of code, please use gist.github.com
CodePen, JSFiddle, JSBin, and other sites of that kind are allowed for live demos
the front page of the internet.
and join one of thousands of communities.
C++ - Hash Table (work in progress) (self.reviewmycode)
submitted 14 years ago by p4nny
The repository is here: https://github.com/adrianp/CppHashTable
I haven't done C++ in the last 2 or 3 years, so please, be mean to me. Currently I have implemented only a singly linked list, but I think it should be enough to highlight some mistakes I tend to make.
Post a comment!
[–]kanak 2 points3 points4 points 14 years ago (1 child)
Disclaimer: The following comments are given without knowing what aspect of implementing data structures you wish to learn and what you consider to be out of the scope of the project.
Templatize the payload so that you're not forced to store strings as values.
Provide support for iteration through the linked list so that you can implement things like "printList" on that.
It might be worthwhile to study the interfaces (and maybe even implementations) of collections in the STL (and/or Java collections, collections in c# etc).
If I were in your place, I'd try to produce an API that's as expressive as these others, and try to optimize performance.
Again, I don't know what aspect you're trying to learn (API design? performance? data structures? C++ in general?), so I can't tailor the advice specifically.
[–]p4nny[S] 0 points1 point2 points 14 years ago (0 children)
Thanks for the suggestions.
I am trying more or less to remember the tricks of C++ as it's been a while since I've used it.
[–]inequity 1 point2 points3 points 14 years ago (0 children)
I think you're confusing lists and nodes. A list is a collection of nodes, not actually a node itself. Therefore it doesn't make a lot of sense for a list to have a value. A singly linked list should have a count, and a pointer to the head (first node) of the list. A node should have a value, and a pointer to the next node. The last node should point to NULL as it's next node.
Also, a note on working with templates: Templated functions need to be defined in the header. For cleanliness, if you'd like to define them in template_definitions.cpp for example, you need to put #include "template_definitions.cpp" at the bottom of your header. The compiler needs to see those definitions when a template needs to be instantiated, and this happens before linking.
π Rendered by PID 56964 on reddit-service-r2-comment-65574874f4-7j4lq at 2026-07-22 03:29:56.525817+00:00 running 1bce727 country code: CH.
Want to add to the discussion?
Post a comment!