Game Programming III – Blog Post 2
|
Late as usual, here’s my post about this week.
There’s been a lot of progress and new things in the network programming. Actually too much for me to write about here on a whim, but I’ll get right to it when I start on the second assignment which will be all about network programming.
Anyway, I’m pretty much done with my linked list, meaning that the very first assignment is halfway done. It took a little longer than I thought mainly because I was being lazy most of the time.
The linked list is built from Nodes which are in turn built from an item with a value (in the form of a template) and two pointers to other nodes, Next and Prev (for the next and previous nodes in the sequence). Arguably, you don’t need the Prev pointer and I was thinking about omitting it entirely but I included it anyway, if I cannot find a use for it I will rewrite the code to remove it. Also, the linked list class holds a pointer that keeps track of which Node is in first, this pointer is called Begin. Anyway, using these pointers the methods in the list is able to make a list of nodes, like pearls on a string.
Most methods work using the Begin pointer as a starting point and then going through every single Node in order until they find one that isn’t pointing at anything, this is the last one. Using another pointer that keeps track of which Node is in the last place of the list could save some effort when the list is longer.
Finally, I moved most of my methods associated with templates to the .h files. After having some trouble with templates I looked online and found that it is generally frowned upon to do this… unless you are dealing with templates. And so, I’ll have my declarations and definitions of methods and classes associated with templates in .h files. This does still feel a little bit weird to do so if somebody would know of a better way of doing this, please let me know.
Well, I didn’t have much else to go over this time around, next week I’ll try to complete the second part of the first assignment; to make a binary search tree.
~♪
|