I've always wondered the reasoning behind why we must always define D3DVERTEX. Is it because Microsoft wants to allow the opportunity to put this in a class and overload operators, or is there another reason?
Thanks
...
I am interested if creating a new std::vector (or calling its assign method) creates a copy of the data?
For example,
void fun(char *input) {
std::vector<char> v(input, input+strlen(input));
// is it safe to assume that the data input points to was COPIED into v?
}
Thanks, Boda Cydo.
...
I am trying to generate random pairs from 34 subjects for an experiment. Subjects will be assigned ID #'s 1-34. To generate the random ordered numbers (1-34) I used the following code:
### Getting a vector of random ordered numbers 1-34###
pairs<-sample(1:34,34,replace=F)
pairs
[1] 16 22 8 13 4 25 18 12 17 5 6 31 29 27 30 ...
What are the good ways of finding the sum of all the elements in a std::vector?
Suppose I have a vector std::vector<int> vector with a few elements in it. Now I want to find the sum of all the elements. What are the different ways for the same?
...
I have a class roughly designed as such:
class Vector3
{
float X;
float Y;
float Z;
public Vector3(float x, float y, float z)
{
this.X = x;
this.Y = y;
this.Z = z;
}
}
I have other classes implementing it as properties, for example:
class Entity
{
Vector3 Position { get; set; }
}
...
Here is what I'm doing.
I have a class which I instance and it has a std::vector.
when I first instance the class this std::vector is empty.
The way I use it is I exponentially add to it and clear. Ex:
Add a number, clear the vector:
Add 2 numbers, clear the vector:
Add 3 numbers, clear the vector,
Add 4 numbers, clear the vector...
Ok, I'm coming from vb.net to c++. Im trying to use vectors in a structure, but the compiler yells at at me for it. What is wrong with the current statement?
#include <vector>
struct FactorSet
{
vector<long long> UpperFactor(0);
vector<long long> LowerFactor(0);
};
Output error (Visual Studio 2008):
Error 1 error C2059: syntax e...
Here is what I'm doing. My application takes points from the user while dragging and in real time displays a filled polygon.
It basically adds the mouse position on MouseMove. This point is a USERPOINT and has bezier handles because eventually I will do bezier and this is why I must transfer them into a vector.
So basically MousePos ->...
I was wondering if it was faster to have a std::vector<std::vector<double>>where the nested vector always has 2 elements, or is it faster to have a std::vector<MyPoint>where MyPoint is defined like:
struct MyPoint {
double Point[2];
};
Thanks
...
I have a std::vector<DOUBLEPOINT> I'm making an application with bezier curves and the results are shown in real time. I convert bezier points into a bunch of short lines. I store the coordinates for the small lines in the vector above. Here is my issue:. When the size of my vector exceeds a cache line, things get very slow very fast. I...
I'm looking for a way to make my application produce smoother results in freehand mode. Right now it simply adds each mousemove points and makes a polygon out of this. I noticed modern vector applications produce bezier curves to make it look much smoother and im wondering how this is done? So how can I get the 4 points to do bezier inte...
Hi,
I have 2 synchronized methods in a class say method1() and method2(). A thread say "Thread 1" holds the lock on that object of the class by executing the synchronized method1().Can another thread say "Thread 2" , access the lock via method2() at the same time while "Thread 1" holding the lock.
This case is analogs to java.util.Vect...
Is possible mapping vector types on nhibernate?
I have a property like this...
string[] myDesc
and I would map every vector value to a specific column of my table...for example:
myDesc[0] --> myDbColumn01
myDesc[1] --> myDbColumn02
myDesc[2] --> myDbColumn03
...
Is there any way to do it?
...
Here is my issue. I have a std::vector<POINTFLOAT> Which stores verticies. The issue is that Vertex buffer objects take in a pointer to an array of float. Therein lies my problem. I cannot give it an array of pointfloat. Is there a way that I could instead push pointers to the individual components of each vertex without pushing in copie...
Title basically says it all. Given a bounding box, with definitions like bounds.min.(x/y/z), bounds.max.(x/y/z), and two points in 3D space (expressed as Vector3 objects), how can I determine if the line made by the two points intersects the bounding box?
The language is C#, v2.0.
...
I'm trying to output a vector of string objects to a file. However, my code only
outputs the first two elements of each string.
The piece of code below writes:
1
1
to a file. Rather then:
01-Jul-09
01-Jul-10
which is what I need.
ofstream file("dates.out");
vector<string> Test(2);
Test[0] = "01-Jul-09";
Test[1...
Hi!
In the following code:
using namespace std;
//ostream& operator<< (ostream& out,const string & str)
//{
// out << str.c_str();
// return out;
//}
int _tmain(int argc, _TCHAR* argv[])
{
ofstream file("file.out");
vector<string> test(2);
test[0] = "str1";
test[1] = "str2";
ostream_...
I'm trying to use Vector. in a Flash Professional Project, Person being a custom class. Eclipse keep saying it cannot find the type in brackets, even if I try with basic types like int or String:
public interface IRenderer
{
function init(persons : Vector.<int>) : void;
function render() : void;
}
Type 1046: Type was not fo...
I am trying to use a large 2D vector which I want to allocate with new (because it is large).
if I say:
vector< vector<int> > bob;
bob = vector< vector<int> >(16, vector<int>(1<<12,0));
bob[5][5] = 777;
it works. But if I say:
std::vector< std::vector<int> > *mary;
mary = new vector< vector<int> >(16, vector<int>(1<<12, 0));
mary[5]...
Hello!
Does anyone know how to speed up boost::numeric::ublas::vector?
I am using typedef ublas::vector<float, ublas::bounded_array<float, 3> > MYVECTOR3 and compare it's speed to D3DXVECTOR3 on plain operations.
The test look the following way:
#include <d3dx9.h>
#pragma comment(lib, "d3dx9.lib")
static const size_t kRuns = static_...