vector

c++ std::copy with type cast to derived class possible?

Hi, I am pretty sure that there is no way around doing this explicitly but I would like to ask nontheless in case there is a better way. I have a base class A and a derived class B, now I have a std::list of A* which point to B*'s and I want to copy this list of A*'s to a std::vector of B*'s so basically I want to do this: std::list<A*>...

where is the ublas::vector push_back ?

hi may i know where is the ublass::vector push_back or what ever does the same ? p.s (i'm not talking about std::vector) ...

Why I'm allowed to assign a new address to a vector containing constant pointers?

Hi, I think the title is clear on explaining my problem.... consider the following snippet: class Critter { int m_Age; }; int main() { vector<Critter* const> critters; for(int i = 0; i < 10; ++i) critters.push_back(new Critter()); critters[2] = new Critter(); return 0; } Shouldn't the line critters[2] =...

How to determine a vector using 2 Points in Android map?

Hi there everyone. I'm trying to do some advanced features with android maps and to do that I need to do some operations on vectors. Now - I read the answer from this and it gave me some hints and tips. However, there is a part which I don't understand. Please allow me to quote this: Now that we have the ray with its start and end co...

Is it possible to get the pointer the continous memory fragment in a std::vector<char> in C++?

I moved my code to use std::vector<char> instead of char *mem = malloc(...) but now I am facing a problem that I can only access the vector data through operator [] but not via a pointer. I can't write stuff like: std::vector<char> data; fill_data(data); char *ptr = data; Before I could do this: char *data = malloc(100); fill_data2(...

Java: What object is more appropriate?

Hi, I am writing an application similar to a chat server-client pair. I am planning on having a central Object which will hold new messages received from clients until they are dealt with by the main thread. My application is multi-threaded. Each client will be on its own thread, so multiple threads will be adding messages to this cen...

initialize a vector from an existing array

const int NUMB = 4; int n[] = {5,6,7,8}; // create a vector of strings using the n[] array vector<int> partnums(n, n + NUMB); The class functions vector name(src.begin, src.end) Create a vector initialized with elements from a source container beginning at src.begin and ending at scr.end According to the book, The vec...

return vector from servlet

I have to do an HTML page with 2 text boxes, one for name and the other one for ammount, then theres a widget that let me choose which type of account im creating, savings or checking, then a send button, this information is going to be sent to the servlet. The servlet have to create an object depending on the type of account, then save ...

Is there a better way to do this?

I'm drawing 2D, concave, sometimes multicontoured, sometimes self intersecting polygons with OpenGL. Here is a sample: Right now, I take the points which if connected would result in the polygon's outline. Then I put these into the GLUTesselator where triangles come out. I then make texture coordinates and texture the polygon. The abs...

c++ can't insert values in vector

ok i when it try to insert two values in two different vectors it won't work the first one will work but the second won't be setted. // Xstrike.cpp : Defines the entry point for the application. // #include "stdafx.h" #include "Xstrike.h" #include <vector> #define MAX_LOADSTRING 100 // Global Variables: HINSTANCE hInst; ...

c++ vector problem

i have to event that should insert values in two vectors but when event get called for the first time it inserts the values successfully but when it get called again it will insert the values in the first vector but not in the second vector than when another event get called the second vector's values will be deleted. here is the full co...

Nested STL vector using way too much memory

I have an STL vector My_Partition_Vector of Partition objects, defined as struct Partition // the event log data structure { int key; std::vector<std::vector<char> > partitions; float modularity; }; The actual nested structure of Partition.partitions varies from object to object but in the total number of chars stored in P...

c++ vectors erase check

Is there a way in C++ to check that erase succeeds? I have two pieces of code that erase the same object. The first erased the object, then the second tries to erase it but doesn't find the object. Any ideas? for(long indexs=0; indexs < (long)Enemie1.vS2Enemie1.size(); indexs++) { if((vRegularShots[index].x>=Enemie1.vS2Enemie1[inde...

Direct3D vector output?

Is there any means to interpret Direct3D output as a series of vectors instead of a raster image? I am hoping I could use such a feature to generate a PDF file containing the rendered Direct3D output. Am I being too optimistic? ...

skipping vector position when pushing_back

Hi there, I'm reading data from a file into a vector of strings called data. And to this data vector I push_back a new string through my main called output_string. Output_string is just a combination of the arguments passed in through command line. After doing all that I write back to my file(update the file with the new string). However...

what to use in multithreaded environment; Vector or ArrayList

I have this situation: web application with cca 200 concurent requests (Threads) are in need to log something to local filesystem. I have one class to which all threads are placing their calls, and that class internally stores messages to one Array (Vector or ArrayList) which then in turn will be written to filesystem. Idea is to retu...

SVG - Cut out one path out of another one

I have several SVG paths looking like this: M204.21121687607624,196.94037184487675L329.92080751248244,195.46306542867487A130,130,0,0,0,244.46261863233696,77.83995929783192Z M198.39145828733604,195.04941765207442L235.83285625620988,75.03597952801854A130,130,0,0,0,97.55860203112616,119.9640082076644Z I now want to add another path, ...

How would i call a intent and put it into my vector?

b = this.getIntent().getExtras(); s = this.getIntent().getStringExtra("DEFAULTTEXT"); public void onClick(View v) { String a = "http://152.226.152.156:1010/jsp-examples/test1"; URL url = null; HttpURLConnection httpurlconnection = null; try { ...

STL library function to partition an interval

Hi, I'd like to partition an interval such as [-1.0, 1.0] into a discrete set of equally spaced points with a specified distance or step-size between each point. For example if the step-size is 0.1 my function would return an array: -1.0, -0.9, -0.8,...., 0.9, 1.0. Now a way of doing using a vector container is a follows: vector...

XNA: adding a force to a vector

i do have 2 points on a 2d plane. one has already an vector that does determine in which direction it will move. now i want to add a vector to this existing vector. so he accelerates in the direction of the other point. to be a bit more clear, it is about 2 asteroids flying in space (only 2d) and gravitation should move them a bit clo...