vector

weird compile errors - vector & templates

I'm writing a "PersonalVec" template class - a vector with other qualities. As a template class, i've implemented everything in the .hpp, as follows: #ifndef PERSONALVEC_HPP_ #define PERSONALVEC_HPP_ #include <vector> #include <iostream> #include <string> #include <algorithm> #include <ctime> #include <cstdlib> #include <cassert> usi...

Vectors and dynamic arrays in D

I was thinking that dynamic arrays were a replacement for vectors in D, but it seems they have no remove function (only associative arrays do) which is rather a limitation for a vector so I'm wondering if I've got that right. If a have an array like follows, uint[] a; a.length = 3; a[0] = 1; a[1] = 2; a[2] = 3; Then the only way I've ...

Photoshop - copy vector mask from a document to another

I "vectorized" a raster image using vector masks made with the pen tool. Now I need these masks (on separate layers) in another document. How could I copy them, to secure their vector-ness, and have them as resize-able objects? I am using Photoshop CS5. ...

Vectors with fixed dimension and values (C++)

Hello everybody, I would like to know the best solution in terms of performances for storing vectors/arrays of data (int or double), whose dimension is not available at compile time (it depends on the input from the user) but, once intialized, they will never change their dimensions, neither their values. In other words I was wondering ...

Re-inserting NAs into a vector

I have a vector of values which include NAs. The values need to be processed by an external program that can't handle NAs, so they are stripped out, its written to a file, processed, then read back in, resulting in a vector of the length of the number of non-NAs. Example, suppose the input is 7 3 4 NA 5 4 6 NA 1 NA, then the output would...

Accessing variables of objects stored within a vector.

I have a class called Coordinate, and am building a vector of these coordinate objects. Here's what the Coordinate class looks like - it's pretty simple: class Coordinate { public int x; public int y; // constructor public Coordinate(int x, int y) { this.x = x; this.y = y; } } My que...

Is java.util.Vector serialization thread-safe?

I know the Vector class is thread-safe for adding and removing elements [reference]. If I serialize a Vector using an ObjectOutputStream am I guaranteed a consistent (and non-corrupt) state when I deserialize it even if other threads are adding and removing objects during the seralization? ...

Object Oriented way to iterate through a std::vector?

I have a class which has a std::vector of child control pointer. For obvious reasons, I do not want the user of the class to have direct access to the std::vector. All I would want is a way to give the caller the pointers. What would be a good OO way to do this? (this function will be called often) Thanks ...

How to partition a set of values (vector) in R

I'm programming in R. I've got a vector containing, let's say, 1000 values. Now let's say I want to partition these 1000 values randomly into two new sets, one containing 400 values and the other containing 600. How could I do this? I've thought about doing something like this... firstset <- sample(mydata, size=400) ...but this doesn'...

Vector of Vector in a Java webservice

I am writing a webservice method to return the values of a table.I am using two Vectors one for the column and another for the values of the table.The Vector used for Values of the table contain each row as a Vector.These methods are written inside an EJB and the webservice is deployed in Weblogic 10.3. I am able to hit the webservice an...

Bad memory allocation C++ for a vector

I get std_bad_alloc error in the following code. It seems the problems is when I add the matrix to the vector, the program crashes when I get to that line in the debugger. The problem is that only the first two matrices are read from the file, the other two aren't because the program crashes with the above error. ...

Iterator for vector of pointers not dereferencing correctly

Here is my issue: I have a std::vector<AguiWidgetBase*> which is used to keep track of child controls. I have these two functions to return iterators: std::vector<AguiWidgetBase*>::const_iterator AguiWidgetBase::getChildBeginIterator() const { return children.begin(); } std::vector<AguiWidgetBase*>::const_iterator AguiWidgetBase:...

[R] Extract Column from data.frame as a Vector

I'm new to R. I have a a Data.frame with a column called "Symbol". Symbol 1 "IDEA" 2 "PFC" 3 "RPL" 4 "SOBHA" I need to store its values as a vector(x = c("IDEA","PFC","RPL","SOBHA")). Which is the most concise way of doing this? Thanks in Advance ...

c++ array to vector issue

Hi, Im trying to copy an array to a vector, however, when the data is copied to the vector its different from that of the original array. int arraySize = 640000; std::vector<unsigned char> vector_buffer; unsigned char buffer[arraySize]; populateArray(&buffer); for(int i = 0; i < arraySize; i++) cout << buffer[i]; // this pri...

creating a std::vector of a templated class?

I currently have a class that uses template arguments. I need an array of these. How could I do this (without boost). ex: template <typename RET, typename T> class AguiTimedEvent { RET (*onEvent)(T arg); double timeStamp; public: RET call(T arg); bool expired(); AguiTimedEvent(); AguiTimedEvent(RET (*Timefunc)(T ...

How to get vectors working in a created tree - root

Hi, This is a Root question, but I thought I'd try my luck in-case anyone has experience! I have created a piece of code that will filter out final particles from a sample into a new tree. I have succeeded in doing so by creating a tree with repeated fields ie. event number, but am trying to make it better for analysis by using vectors ...

Vector handling bullets in DirectX

I have a vector to hold objects of a bullet class. Is this the correct way to add bullets to the vector structure? std::vector<Bullet> bullets; Bullet newbullet(thisPlayer.x+PLAYERSPRITEWIDTH,(thisPlayer.y-(PLAYERSPRITEHEIGHT/2))); bullets.push_back(newbullet); I don't think the bullets get added this way. ...

SVG to SWF on Linux?

Any application or method can export SVG or any vector format to SWF from Ubuntu Linux? ...

Erasing from a std::vector while doing a for each?

The proper way to iterate is to use iterators. However, I think by erasing, the iterator is invalidated. Basically what I want to do is: for(iterator it = begin; it != end; ++it) { if(it->somecondition() ) { erase it } } How could I do this without v[i] method? Thanks struct RemoveTimedEvent { bool operator()(...

Removing something from a STL container without deconstructing it.

Ok, I'm using C++ STL containers (currently vector<customType*>). Now I need to remove elements from the container, but using erase deconstructs the object, which is bad, since I'm taking it off one, and putting it onto a variable doing some processing then onto another one. At the moment my code is quite nasty, and I'm just putting NUL...