T
toton
Hi,
I have a STL vector of of characters and the character class has a
Boost array of points.
The things are vector<Character> chars; and
class Character{
private:
array<Point,N> points;
};
Now are the memory layout is contiguous? i.e all the character resides
side by side just like array, and all Points side by side insede the
character?
My intension is NOT to access them with memory location, but as I do
lots of operation on them, it is better if they resides near by places
(preferably in cache)
And during operation, I want to reuse the existing memory, when a new
character gets added or old character gets deleted rather than
allocating some extra memory & deallocating some.
Now I have large amount of data which gets processed like this. How
much this scheme improves speed? rather than having vector<Character*>
Also, as u can note, the boost array is static one, thus size have to
be given at compile time to a safe value, which is not very good design
as the no of points in a character is not known ...
Now if I allocate memory dynamically at runtime, will the priximity get
lost? Note I need to perform some operaton within character points as
well as between two adjacent character also.
I had developed a Matlab version of the program where a array was for
all characters, and another array was for all points. character array
was pointing to the start & end location in the points array.
Now this is not very good OO design, as there is risk to modify points
for other character, as I am sending only start & end points in the
point array, and there is no way to restrict the receivng end to use
points within this section.
Any idea about how to make it a good oo design? to use contained
relationship or use pointer in the points buffer?
In the second case, is it possible to to return a portion of the array
to work with (that is, the points within range only) as reference (no
copy of data) ratuer than the whole array?
any suggestion is welcome...
abir
I have a STL vector of of characters and the character class has a
Boost array of points.
The things are vector<Character> chars; and
class Character{
private:
array<Point,N> points;
};
Now are the memory layout is contiguous? i.e all the character resides
side by side just like array, and all Points side by side insede the
character?
My intension is NOT to access them with memory location, but as I do
lots of operation on them, it is better if they resides near by places
(preferably in cache)
And during operation, I want to reuse the existing memory, when a new
character gets added or old character gets deleted rather than
allocating some extra memory & deallocating some.
Now I have large amount of data which gets processed like this. How
much this scheme improves speed? rather than having vector<Character*>
Also, as u can note, the boost array is static one, thus size have to
be given at compile time to a safe value, which is not very good design
as the no of points in a character is not known ...
Now if I allocate memory dynamically at runtime, will the priximity get
lost? Note I need to perform some operaton within character points as
well as between two adjacent character also.
I had developed a Matlab version of the program where a array was for
all characters, and another array was for all points. character array
was pointing to the start & end location in the points array.
Now this is not very good OO design, as there is risk to modify points
for other character, as I am sending only start & end points in the
point array, and there is no way to restrict the receivng end to use
points within this section.
Any idea about how to make it a good oo design? to use contained
relationship or use pointer in the points buffer?
In the second case, is it possible to to return a portion of the array
to work with (that is, the points within range only) as reference (no
copy of data) ratuer than the whole array?
any suggestion is welcome...
abir