OK. I'm confused.
I'm developing a 3D game using SDL and OpenGL on Ubuntu 9.04 using Eclipse CDT. I've got a class to hold the mesh data in vectors for each type. Such as Vertex, Normal, UVcoord (texture coordinates), as well as a vector of faces. Each face has 3 int vectors which hold indexes to the other data. So far my game has b...
Coming from a C# Background I never used any pointers.
I'm creating a vector of contacts objects. What is the best way to create a separate vector which references to elements in the big vector?
...
Greetings,
I am trying to perform a copy from one vector (vec1) to another vector (vec2) using the following 2 abbreviated lines of code (full test app follows):
vec2.reserve( vec1.size() );
copy(vec1.begin(), vec1.end(), vec2.begin());
While the call to vec2 sets the capacity of vector vec2, the copying of data to vec2 seems to not ...
What are the pros and contras of using a Vector.<> instead of array?
...
Hello,
I am trying to create a vector that contains pointers, each pointer points to another vector of a type Cell which I have made using a struct.
The for loop below allows me to let the user define how many elements there are in the vector of pointers. Here's my code:
vector< vector<Cell>* > vEstore(selection);
for (int t=0; t<selec...
I'd like a generic method for retrieving the data from a vector.
I have a the following class and vector:
class myClass
{
public:
myClass(int myX, float myZ, std::string myFoo)
: x ( myX )
, z ( myZ )
, foo ( myFoo )
{
}
myClass()
{
}
int x;
float z;
std::string foo;
} ;
std::...
I have a vector of booleans. I need to set its elements from n-th to m-th to true. Is there an elegant way to do this without using a loop?
Edit: Tanks to all those who pointed out the problems with using vector<bool>. However, I was looking for a more general solution, like the one given by jalf.
...
I'm trying to optimize the following code below to avoid having to copy and paste and just use SlaveForce and SlavePos properly, which are float[6] type, and baseForce and basePos are vector type:
typedef struct _NodeCoord
{
float coords[6];
} NodeCoord;
int main()
{
...
memcpy(tempNodeCoord.coords, SlaveForce, 6*sizeof(flo...
I read that Vectors are not seqs, but Lists are. I'm not sure what the rationale is for using one over the other. It seems that vectors are used the most, but is there a reason for that? Any answers are appreciated, thanks!
...
the C++ standard seems to make no statement regarding side-effects on capacity by either
resize(n), with n < size(), or clear().
It does make a statement about amortized cost of push_back and pop_back - O(1)
I can envision an implementation that does the usual sort of capacity changes
ala CLRS Algorithms (eg double when enlarging, ha...
Consider a vector V riddled with noisy elements. What would be the fastest (or any) way to find a reasonable maximum element?
For e.g.,
V = [1 2 3 4 100 1000]
rmax = 4;
I was thinking of sorting the elements and finding the second differential {i.e. diff(diff(unique(V)))}.
EDIT: Sorry about the delay.
I can't post any representati...
I have a struct:
struct OutputStore
{
int myINT;
string mySTRING;
}
If I create an array of type OutputStore as follows:
OutputStore *OutputFileData = new OutputStore[100];
then I can address it with:
OutputFileData[5].myINT = 27;
But if I use a vector instead of an array:
vector<OutputStore> *OutputFileData = new vect...
In R, how do you test a vector to see if it contains a given element?
...
Suppose I have the following vector:
> x <- sample(1:10,20,replace=TRUE)
> x
[1] 8 6 9 9 7 3 2 5 5 1 6 8 5 2 9 3 5 10 8 2
How can I find which elements are either 8 or 9?
...
I have a base class with several classes extending it. I have some generic library utilities that creates a vector containing pointers to the base class so that any of the subclasses will work. How can I cast all of the elements of the vector to a specific child class?
// A method is called that assumes that a vector containing
// Dogs ...
I wonder if it is possible (and if it is then how) to re-present an arbitrary M3 matrix transformation as a sequence of simpler transformations (such as translate, scale, skew, rotate)
In other words: how to calculate MTranslate, MScale, MRotate, MSkew matrices from the MComplex so that the following equation would be true:
MComplex = ...
In information retrieval, the words in the documents were represented as a "Term Vector", they did it primarily to check the angle between two vectors. When have you represented something as a vector in your work and what is the common heuristic that you use to represent an entity as a vector?
...
Ok... I have this struct and comparison function-
struct Edge
{
char point1;
char point2;
int weight;
bool operator<( const Edge& rhs ) const
{
return( weight < rhs.weight );
}
}; //end Edge
bool compareEdge( const Edge& lhs, const Edge& rhs )
{
return...
Hi,
Been a few years since I've written C/C++, and now I'm facing a problem I just cannot seem to solve on my own.
Given the following struct:
struct InputData
{
float diameter;
float length;
int vertIndex;
struct InputData *parent;
vector<InputData*> children;
bool deadEnd;
InputData(float dia, float lngt...
Hi, I'm having a problem with my looping over a vector, and deleting values from another vector sometimes crashes my program. I have this vector of int's to keep track of which elements should be removed.
std::vector<int> trEn;
Then I loop through this vector:
struct enemyStruct {
float x, y, health, mhealth, speed, turnspeed;
...