Alright. As sort of an experiment I wanted to see if I could make a Vector (expandable array) in C, kinda like the Vector class in Java, only this one holds a specific type of structure. It appears to be fairly successful, although it is very simple at this point. Anyway, I was hoping someone could review it for me, tell me if there are any dangerous leaks, or if there are ways to make the code better. It can be found here:
Basically it functions similar to a linked-list, but instead of individual node holding a single struct, each VECTOR_NODE has an array of structs. This makes it quicker to jump through nodes to get the the item you need, if you have a lot of item.
Two other things I am interested in (though they might only be clear once you see the code):
The getItem(int n) function has an inner if statement in it because the initial node has a different capacity from added nodes. Even though it might be less efficient, I'd like to see if there's a way to linearize this function (thus getting rid of the inner if statement). I just have a facination with linearization.
Second, I didn't finish the removeItem() function because I can't think of the most efficient way to do it, although I reckon that the 'addItem()' function will also have to be changed.
So yeah, if someone could take a look at it for me, I'd appreciate it. Thanks for your time.
Basically it functions similar to a linked-list, but instead of individual node holding a single struct, each VECTOR_NODE has an array of structs. This makes it quicker to jump through nodes to get the the item you need, if you have a lot of item.
Two other things I am interested in (though they might only be clear once you see the code):
The getItem(int n) function has an inner if statement in it because the initial node has a different capacity from added nodes. Even though it might be less efficient, I'd like to see if there's a way to linearize this function (thus getting rid of the inner if statement). I just have a facination with linearization.
Second, I didn't finish the removeItem() function because I can't think of the most efficient way to do it, although I reckon that the 'addItem()' function will also have to be changed.
So yeah, if someone could take a look at it for me, I'd appreciate it. Thanks for your time.