@Peter
What do you mean? All of my array indices must be pointing to something? If so, that's rather inconvenient for my program and I'll have to figure out something new. Or do you just mean I'm doing it wrong. If so; I get that much lol! I'm looking for advice on how to do it correctly :)
@Web
Well, the thing is I have different pointers pointing to similar arrays-of-pointers at different times. So your code assumes direct access to the array. I'd rather avoid the ugly hardcoding required to do that (in my case by detecting which array is the "active" array of pointers)
Feel free to post in response to this. I'll try to get around to fixing the segfault tomorrow and post results or more questions. However, if you understand the problem better now, more solutions/help can't hurt :D
I may try the reference code you posted (with "array" in place of "parray") as between the two comments that seems to be the implied solution.
That said, it won't be the same index.
(Long explanation below)
Essentially I'm mimicking list behavior to test speed vs. storage. There's more to it:
-to avoid copying information I'm using pointers
-to avoid allocating I'm using large permanent arrays of objects/pointers to objects
-to avoid walking over dead nodes very often I "optimize" the array by pointing "dead" positions to "alive" positions occasionally (utilizing a third array) and keeping a pointer to the newly optimized "end point" of the array.
If none of that makes sense; I can link the bitbucket if I get it working (as it explains it all long hand and is well commented.)
I'm basically building a bunch of data structures around the idea of managing *very* large amounts of objects that get frequently created/destroyed (100's per second being the first round of tests) and running them against each other (this being a custom one.) If all goes well then the arrays will sit in cache all day, never allocating or deallocating, with all of the positive properties of a list (except for efficient storage.)
Thanks thus far!
p.s. maybe to clarify how the array is initialized:
1 2 3 4
|
psuedocode:
for each index i in ARRAYSIZE
parray[i] = NULL
array = parray
|
It's not truly a null location, but a location int he array that points to NULL. It shouldn't be a NULL pointer that I'm dereferencing (I think) as it's a pointer to an array of pointers; by dereferencing I was hoping to access the indexed pointer and have THAT point to the permanent location.