Possible Duplicates:
reduce the capacity of an stl vector
Is this normal behavior for a std::vector?
I know that std::vectors do not 'free' the memory when you call vector.clear(), but how can I do this? I want it to release all of its resources once I clear it but I don't want to destroy it.
Here is what is happening rig...
I have a std::vector of a class called OGLSHAPE.
each shape has a vector of SHAPECONTOUR struct which has a vector of float and a vector of vector of double. it also has a vector of an outline struct which has a vector of float in it.
Initially, my program starts up using 8.7 MB of ram. I noticed that when I started filling these these...
I have been trying to create a 2D array of vector for a game. Here is an example of what I am doing.
struct TILE {
int a;
char b;
bool c;
};
TILE temp_tile;
std::vector<TILE> temp_vec_tile;
std::vector<std::vector<TILE>> tile;
for (int x = 0; x < 10; x++) {
for (int y = 0; y < 10; y++) {
temp_tile.a = x;
tem...
I have a class here that is defined like this:
struct USERFPOINT
{
POINTFLOAT UserPoint;
POINTFLOAT LeftHandle;
POINTFLOAT RightHandle;
bool isBezier;
};
struct SHAPEOUTLINE {
GLuint OutlineVBO;
int OutlineSize;
int OutlineWidth;
ARGBCOLORF OutlineColor;
};
struct SHAPECONTOUR{
std::vector<USERFPOI...
Let's say I have a class FOO.
I want to have a std::vector of FOO.
Is it better if I do something like this:
FOO foo;
foo.init();
foo.prop = 1;
std::vector<FOO> myvec;
myvec.push_back(foo);
foo.prop = 2;
myvect.push_back(foo);
or is it better practice to do:
std::vector<FOO> myvec;
FOO foo;
myvec.push_back(foo);
myvec.back().init(...
I'm using multitreading and want to merge the results.
ex:
std::vector<int> A;
std::vector<int> B;
std::vector<int> AB;
I want AB to have to contents of A and the contents of B in that order. What's the most efficient way of doing something like this?
Thanks
...
Hi everyone,
it occurred to me that it would be a good idea to manage a range of mapped memory (from glMapBuffer) with a std::vector.
// map data to ptr
T* dataPtr = (T*)glMapBuffer(this->target, access);
[... debug code ...]
// try to construct a std::vector from dataPtr
T* dataPtrLast = dataPtr + size;
mappedVector = new std::vecto...
How to display a vector graphics file in iPhone? Any guide or tuts? thanks.
I have here the ff. file formats: .pdf, .eps., .ai
Thanks
...
According to Daniel, in his answer, there is no easy way to modify the below function so I bit the bullet and started from scratch. Solution is below (as an answer). Actually, ignore my answer. See Tom Sirgedas' answer it's a lot shorter.
I need to modify the solution found here: http://stackoverflow.com/questions/1343346/calculate-a...
I'm wondering what would be the best approach to render vector objects (e.g. box, rocket) as if they are drawn with a pencil/crayon? Looking for a dynamic rendering approach like RIA/JS here, not Photoshop etc.
EDIT: perfect would be sth. close to http://bootb.com/en/
Cheers,
stephanos
...
Is it possible to use std::next_permutation() to permutate the elements of a vector of a class i created?
How does the comparison parameter in next_permutation() work?
...
I have a program which fetches records from database (using Hibernate) and fills them in a Vector. There was an issue regarding the performance of the operation and I did a test with the Vector replaced by a HashSet. With 300000 records, the speed gain is immense - 45 mins to 2 mins!
So my question is, what is causing this huge differe...
I'm trying to do the following:
I have:
std::vector<std::vector<GLdouble[2]>> ThreadPts(4);
then I try to do:
GLdouble tmp[2];
while(step--)
{
fx += dfx;
fy += dfy;
dfx += ddfx;
dfy += ddfy;
ddfx += dddfx;
ddfy += dddfy;
tmp[0] = fx;
tmp[1] = fy;
ThreadPts[currentvector].push_back(tmp);
}
...
Here is what I'm doing:
I'm taking in bezier points and running bezier interpolation then storing the result in a std::vector<std::vector<POINT>.
The bezier calculation was slowing me down so this is what I did.
I start with a std::vector<USERPOINT> which is a struct with a point and 2 other points for bezier handles.
I divide these ...
Right now I calculate it like this:
double dx1 = a.RightHandle.x - a.UserPoint.x;
double dy1 = a.RightHandle.y - a.UserPoint.y;
double dx2 = b.LeftHandle.x - a.RightHandle.x;
double dy2 = b.LeftHandle.y - a.RightHandle.y;
double dx3 = b.UserPoint.x - b.LeftHandle.x;
double dy3 = b.UserPoint.y - b.LeftHandle.y;
...
Hello.... I'm having a very weird problem with a vector in my application.
Details...
I have the following classes.
Person,Player,PlayerController.
Player extends Person. Person extends ObjectProxy in order to enable binding.
So the Player class has the [Bindable] tag.
The PlayerController class contains a remote object calling a ph...
I'm trying to remove an element from a vector.
vector<Foo> vecFoo;
Foo f1;
Foo f2;
Foo f3;
vecFoo.push_back(f1);
vecFoo.push_back(f2);
vecFoo.push_back(f3);
Foo* pF1 = &f1;
vecFoo.erase(std::remove(vecFoo.begin(), vecFoo.end(), *pF1), vecFoo.end());
That last line produces a huge amount of C2784 errors. What am I doing wrong?
(Ye...
I was looking at this vector drawing application called Creative Docs .Net . I noticed that I can have hundreds of shapes and moving, rotating and scaling do not lag at all. Given that all verticies must be modified, how do applications generally do these transformations as quickly as possible?
Thanks
...
Hello!
How should I handle the following situation :
I am writing my own 2D vector class and have the following code:
class Vector2 : public (...)
public:
Vector2(float x, float y) {
local_vector_storage_[0] = x;
local_vector_storage_[1] = y;
}
template <typename Iterator> Vector2(Iterator begin, Iterator end) ...
Hi!
I'm familiar with OpenGL. I want something like OpenGL, except with the final output as a vector image rather than a bitmap image. Is there anything like this?
Thanks!
EDIT clarifications:
I have a picure rendered in OpenGL. I want to render it as an image in a paper. I want the image to be vector rather than bitmap.
...