vector

Optimizing bit array accesses

Hi all, I'm using Dipperstein's bitarray.cpp class to work on bi-level (black and white) images where the image data is natively stored as simply as one pixel one bit. I need to iterate through each and every bit, on the order of 4--9 megapixels per image, over hundreds of images, using a for loop, something like: for( int i = 0; i < i...

stl vector.push_back() abstract class doesn't compile

Hi, Let's say I have an stl vector containing class type "xx". xx is abstract. I have run into the issue where the compiler won't let me "instantiate" when i do something like the following: std::vector<xx> victor; void pusher(xx& thing) { victor.push_back(thing); } void main() { ; } I assume this is because the copy constru...

error C2719: '_Val': formal parameter with __declspec(align('16')) won't be aligned?

I'm trying to create a vector for D3DXMATRIXA16 like so: vector<D3DXMATRIXA16> matrices; and am getting the error: d:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(717) : error C2719: '_Val': formal parameter with __declspec(align('16')) won't be aligned e:\projects\emuntitled\em\emscratch\emshadow.h(...

Java Encrypt And Save Vector to File

I have a vector of user passwords. I would like to save this vector to a file and encrypt it. Then load and decrypt the file to get the passwords. I would like my users to enter a pass phrase to decrypt the files. Which algorithm should i choose? and How can i encrypt the vector before writing the file? ...

Adding values to a 3-d vector in c++

Hello, I would like to use a 3-d Vector to store and add values between some calculations in c++. I'm having problems adding the third dimension to my vector. What I would like to achieve is a vector that for each iteration puts in a 2-D vector and here only the first values for each vector... So The input would look something like this ...

Evaluate Expression in RAD Studio 2007's Watch

I know that most of you might have noticed now. When you try to evaluate an expression using watch on RAD Studio 2007, it does not evaluate. For example, if I had a vector, I could not do "vecData.size()", if I do "vecData.size", it just gives an address. Is there any other way to watch the size and view each element of the vector in R...

Help constructing an OBB, trying to Represent a matrix with 3 vectors

I am presently trying to construct an OBB (Oriented Bounding Box) using the source and math contained in the book "Real Time Collision Detection". One problem with the code contained in this book is that it does very little to explain what the parameters mean for the methods. I am trying to figure out what I need to feed my setOBB() me...

Java Vector or ArrayList for Primitives

Is there an expandable array class in the Java API equivalent to the Vector or ArrayList class that can be used with primitives (int, char, double, etc)? I need a quick, expandable array for integers and it seems wasteful to have to wrap them in the Integer class in order to use them with Vector or ArrayList. My google-fu is failing ...

Any built-in function to test if 4 is in [1,2,3,4] (vector)

In Ruby I can do: [1,2,3,4].include?(4) #=>True In Haskell I can do : 4 `elem` [1,2,3,4] #=> True What should I do in C++? ...

How do I make a QVector of widgets?

How do I make a QVector (or some other container class) of a dynamic number of widgets, such as QPushButton or QComboBox in Qt 4? I've used the following in my window class's constructor: QVector<QComboBox*> foo; // Vector of pointers to QComboBox's And now I want to fill it with some number of controls which can change dynamically: ...

Matrix/Vector Preference: Return copy or transform internally?

Just a quickie to get a feel for the community in general's preference: When working with objects like Vectors (mathematical, not STL) and Matrices do you prefer a library that: A) Doesn't alter the objects but returns copies instead: Vec2 Vec2::Add(float x, float y) { return Vec2(this.x + x, this.y + y); } B) Alters the objects ...

sum of square of each elements in the vector using for_each

Hi, As the function accepted by for_each take only one parameter (the element of the vector), I have to define a static int sum = 0 somewhere so that It can be accessed after calling the for_each . I think this is awkward. Any better way to do this (still use for_each) ? #include <algorithm> #include <vector> #include <iostream> us...

The behavior of overlapped vector::insert.

Where does the C++ standard declare that the pair of iterators passed to std::vector::insert must not overlap the original sequence? Edit: To elaborate, I'm pretty sure that the standard does not require the standard library to handle situations like this: std::vector<int> v(10); std::vector<int>::iterator first = v.begin() + 5; std::v...

how to pass a stl vector to a function which takes a const [] (c++)

i have a 3d stl vector, vector<vector<vector<double> > > mdata; i also have a function myfun(const double ya[]); to be more precise, it's a function from the GNU Scientific Library, gsl_spline_init(gsl_spline * spline, const double xa[], const double ya[], size_t size); but this is not related to my problem. so now i want to pa...

what's the correct way of writing this code?

typedef boost::shared_ptr<config_value_c> config_value_ptr; typedef std::vector<config_value_ptr> config_value_vec; config_value_vec config; typeof (config.iterator ()) it = config.iterator (); I want to extract an iterator to an array of boost pointers to class config_value_c. I know I can specify the iterator as std::vector<config...

completely removing a vector c++

Hi , I'm having problems removing a vector from a "multidimensional vector" I would like to achieve this: 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 4 4 4 4 4 4 4 4 for example vector<vector<int>>vec; for i...//give vec values... vec[3].erase(vec.begin(),vec.end()); It seems like us...

pointer arithmetic on vectors in c++

i have a std::vector, namely vector<vector<vector> > > mdata; i want pass data from my mdata vector to the GSL function gsl_spline_init(gsl_spline * spline, const double xa[], const double ya[], size_t size); as ya. i already figured out that i can do things like gsl_spline_init(spline, &(mgrid.front()), &(mdata[i][j][k].front()),...

Is a relational database well suited for vector calculations?

The basic table schema looks something like this (I'm using MySQL BTW): integer unsigned vector-id integer unsigned fk-attribute-id float attribute-value primary key (vector-id,fk-attribute-id) The vector is represented as multiple records in the table with the same vector-id I need to build a separate table with the dot product (al...

How to get the address of the std::vector buffer start most elegantly?

I want to use std::vector for dynamically allocating memory. The scenario is: int neededLength = computeLength(); // some logic here // this will allocate the buffer std::vector<TCHAR> buffer( neededLength ); // call a function that accepts TCHAR* and the number of elements callFunction( &(buffer[0]), buffer.size() ); The code ...

Calculate a vector from the center of a square to edge based on radius

Given a square (described by x, y, width, height) and an angle (in radians) I need to calculate a vector that originates at the squares centre and terminates at the point that collides with the edge of the square at the given angle. I'm really most interested in the point it collides at so if that would make calculation more efficient l...