vector

Std::vector is initialized to garbage. Weird behavior. Any ideas on what's up?

My class has this member. std::vector<AvaWrapper> m_controls; In my constructor I call m_controls.clear() Then I call a member function that does m_controls.clear() again but it blows up with an assert. The debugger shows that m_controls has a half million or more entries though none of them are valid cause the debugger shows ...

partially sort vector c++

Hello i Have a "vector of vectors" that looks something like this 3 1 2 0 77 0 3 1 2 44 1 0 3 2 29 3 0 1 2 49 I would like to sort them according to the last element in every row so that it would look like this in the end 1 0 3 2 29 0 3 1 2 44 3 0 1 2 49 3 1 2 0 77 Of course my real example is a lot more complex... but this is ba...

Which is better and why? RaphaelJS or HTML5 Canvas?

I found a vector library on the Internet that even works with IE6! http://raphaeljs.com/index.html It's amazing. Now my question is it better than the upcoming HTML5 <canvas>? The only reason I ask is that it could be years before Microsoft implements a <canvas> that doesn't require a plugin for it to run. And it will be even long...

Performance penalty for using C++ vector instead of C array.

Is there a performance penalty for working with a vector from the standard library in C++ instead of arrays in C? ...

MATLAB excluding data outside 1 standard deviation

I'm inexperienced with MATLAB, so sorry for the newbie question: I've got a large vector (905350 elements) storing a whole bunch of data in it. I have the standard deviation and mean, and now I want to cut out all the data points that are above/below one standard deviation from the mean. I just have no clue how. From what I gather I hav...

Efficiently comparing a vector to a series of numbers in Java

I have a series of numbers, i.e. 6, 5, 7, 8, 9, 1, which through some mathematical process I will eventually obtain through repetition. For this reason, I want to use a vector to store the last six numbers yielded by this process and then compare the contents of that vector to the series of numbers above. If it identically matches the se...

How to make elements of vector unique? (remove non adjacent duplicates)

I have a vector containing few non-adjacent duplicates. As a simple example, consider: 2 1 6 1 4 6 2 1 1 I am trying to make this vector unique by removing the non-adjacent duplicates and maintaining the order of elements. Result would be: 2 1 6 4 The solutions I tried are: Inserting into a std::set but the problem with this a...

Arraylist in Visual Basic .net

Can I get an example of how to make something like a Vector or an ArrayList in Visual Basic .NET? ...

Find a similarity of two vector shapes

Looking for any information/algorithms relating to comparing vector graphics. E.g. say there two point collections or vector files with two almost identical figures. I want to determine that a first figure is about 90% similar to the second one. ...

std::vector reserve() and push_back() is faster than resize() and array index, why?

I was doing a quick performance test on a block of code void ConvertToFloat( const std::vector< short >& audioBlock, std::vector< float >& out ) { const float rcpShortMax = 1.0f / (float)SHRT_MAX; out.resize( audioBlock.size() ); for( size_t i = 0; i < audioBlock.size(); i++ ) { out[i] = (float...

Java serialization of multidimensional array

Hey everyone, Is it possible to make a 2D array in java serializable? If not, i am looking to "translate" a 3x3 2D array into a Vector of Vectors. I have been playing around with vectors, and I am still unsure of how to represent that. Can anyone help me? Thanks! ...

Code Golf: Calculating the intersection between Box and Line

The challenge Given you have the coordinates of a rectangle and a line in 2D space, and they may or may not intersect, write a function that calculates the intersection. Here is an example of an intersection in glorious ASCII art: +-------------+ | | | | ----*------- | | | |...

Troubles: Matrices, Vectors and Arrays

As far as I understood, matrices are very inflexible to work with. Therefor, I'm trying to get an array of vectors do deal with. My needs are: to be able to add vectors and make arithmetical operations on their components. Writing the code below, require 'matrix' x = Matrix.rows( IO.readlines("input.txt").each {|line| line.split} ) p...

Accessing an array of vectors trouble

My code looks like this: a = IO.readlines("input.txt").map { |line| Vector.[](line.split) } Now I want to access a single component of the first vector within my a array. I'm writing the following to address a vector: puts a[0] The behavior is pretty much expected - I receive the following: Vector[1.2357, 2.1742, -5.4834, -2.0735...

Vector of ifstreams

How can I create and manipulate a vector of ifstreams? Something like this, except this doesn't work: vector<ifstream> Files(10, ifstream()); Files[0].open("File"); ...

Memory corrupt in adding string to vector<string> loop

This is on Visual Studio 2008 on a dual-core, 32 bit Vista machine. In the debug code this runs fine, but in Release mode this bombs: void getFromDB(vector<string>& dates) { ... sql::Resultset res = stmt->executeQuery("SELECT FROM ..."); while (res->next()) { string date = res->getString("date"); dates.push_bac...

How to convert vector from 1-row table in R

In R, I have a 1-row table. How do I convert that to a vector? Specifically, the table is this: 0 1 2 3 4 21 35 46 62 36 I've tried bracket notation but to no avail! ...

Reversing strings in a vector using for_each and bind

Hi! I was wandering how it's possible to reverese strings that are contained in a vector using a single for_each command just in one "simple" line. Yea, I know it is easy with a custom functor, but I can't accept, that it can't be done using bind (at least I couldn't do it). #include <vector> #include <string> #include <algorithm> std...

Translate vector by matrix

I have a 4*4 matrix and a 3d vector. I need to translate my vector by the matrix. Not too much crazy maths notation please because i dont understand it. An example in something close to java would be fab! Thanks ...

Is there a way to output a .eps or vector file using FPDF?

I'm trying to layout a business card on a PDF with the FPDF class using a form field that the user fills out. I have been able to create the text needed for the card, but I have a logo that I want to output as well. The problem I am facing is that I can only find a way to add an Image as a JPEG and it looks pixelated when the user zooms...