I am working on having some shapes floating around the screen at random. Eventually they will interact with each other, as well as have onclick functions. I can get the circles to render on screen, but I cannot get them to have motion. It seems that the .animate() function is not what I need here.
Does anyone know how I would go abou...
Hi
I have the following CPP code snippet and the associated error message:
Code snippet
struct node{
char charVal;
bool childNode;
struct node *leftChild;
struct node *rightChild;
};
vector<std::pair<int,struct node*> > nodeCountList;
struct node *nodePtr = new struct node;
nodeCountList.pus...
I could solve this using loops, but I am trying think in vectors so my code will be more R-esque.
I have a list of names. The format is firstname_lastname. I want to get out of this list a separate list with only the first names. I can't seem to get my mind around how to do this. Here's some example data:
t <- c("bob_smith","mary_jane...
TL;dr: "I am not sure how to calculate a smooth transition of thrust between one vector and another."
I am programming a simple game where an enemy chases after the player in an open space (no walls). I was calculating the enemy's x & y velocities independently, accelerating them if they were taking them in the direction of the player a...
Hey, In C++, I have a vector of type:
vector<BaseClass*> myVector;
In which, I insert (push_back) pointers of derived classes into it.
Now, I want to pop back its elements so I do this:
vector<ADlgcDev*>::iterator iter;
for (iter = myVector.rbegin(); iter != myVector.rend(); iter++)
{
// but before I pop it, I need to shutdown it ...
Just a conceptual question that I've been running into. In my current project it feels like I am over-using the boost smart_ptr and ptr_container libraries. I was creating boost::ptr_vectors
in many different objects and calling the transfer() method to move certain pointers from one boost::ptr_vector to another.
It is my understandin...
I have a data that looks like this. And my code below
simply compute some value and binds the output vector to the
original data frames.
options(width=200)
args<-commandArgs(trailingOnly=FALSE)
dat <- read.table("http://dpaste.com/89376/plain/",fill=T);
problist <- c();
for (lmer in 1:10) {
meanl <- lmer;
stdevl <- (0.17*sqrt(l...
Hi,
I've always been a bit confused about how STL containers (vector, list, map...) store values. Do they store references to the values I pass in, or do they copy/copy construct +store the values themselves?
For example,
int i;
vector<int> vec;
vec.push_back(i);
// does &(vec[0]) == &i;
and
class abc;
abc inst;
vector<abc> vec;
ve...
Why Java Vector is considered a legacy class, obsolete or deprecated?
Its use isn't valid when working with concurrency?
And if I don't want to manually synchronize objects and just want to use a thread-safe collection without needing to make fresh copies of the underlying array (as CopyOnWriteArrayList does), then it is fine to use Ve...
Is there a way to remove an item from a vector based on index as of now i am using subvec to split the vector and recreate it again. I am looking for the reverse of assoc for vectors?
...
Does anyone know where I could get a rundown of the vector math I'd need in order to program a raytracer? I could use a refresher of linear algebra and multivar calc since it's been a few years since I've taken those classes.
...
What is the correct (and efficient) way of attaching the contents of C buffer (char *) to the end of std::vector?
Thanks.
...
Is there a way to call send / recv passing in a vector ?
What would be a good practice to buffer socket data in c++ ? For ex: read until \r\n or until an upper_bound ( 4096 bytes )
...
Let's say I have a vector declared like this:
struct MYSTRUCT
{
float a;
float b;
};
std::vector<MYSTRUCT> v;
Now, I want to find all elements of v that share the same a, and average their b, i.e.
Say v contains these five elements {a, b}: {1, 1}, {1, 2}, {2, 1}, {1, 3}, {2, 2}
I want to get v[0], v[1], v[3] (where a is 1) and av...
I am trying to allocate space for a boost vector type in a class definition. I am not a good c++ programmer, but shown below is my best attempt. There are no error messages, but when I try to access the vector from my main function it believes that the vector has zero elements. I know this is because I did not tell the compiler how mu...
Why does the classic implementation of Vector (ArrayList for Java people) double its internal array size on each expansion instead of tripling or quadrupling it?
...
I need to find an element position in an std::vector to use it for referencing an element in another vector:
int find( const vector<type>& where, int searchParameter )
{
for( int i = 0; i < where.size(); i++ ) {
if( conditionMet( where[i], searchParameter ) ) {
return i;
}
}
return -1;
}
// caller:
c...
I have a program that needs to set the type of a vector as the program is executed (according to a value in a configuration file).
I have tried this:
int a = 1
if(a == 1) vector<int> test(6);
else vector<unsigned int> test(6);
test.push_back(3);
But this gives me:
Error 1 error C2065: 'test' : undeclared identifier
I'm not e...
I have a vector<int> container that has integers (e.g. {1,2,3,4}) and I would like to convert to a string of the form
"1,2,3,4"
What is the cleanest way to do that in C++?
In Python this is how I would do it:
>>> array = [1,2,3,4]
>>> ",".join(map(str,array))
'1,2,3,4'
...
Hello
Under scheme I want to generate a vector of random numbers, I have tried this like this:
(make-vector 10 (random 100))
and the output for this is such:
#(44 44 44 44 44 44 44 44 44 44)
so it seems like it uses the same seed for the generated items, how can I overcome this problem of generating n amount of randomly generated n...