vector

How can I sort the vector elements using members as the key in C++

suppose we have a vector<student> allstudent Now I would like to sort the students using different memebers,such as name, age, address, like that. How can I do that? ...

STL: writing "where" operator for a vector.

Hello, I need to find the indexes in the vector based on several boolean predicates. ex: vector<float> v; vector<int> idx; idx=where( bool_func1(v), bool_func2(v), ... ); What is the way to declare **where** function, in order to use the several user defined boolean functions over the vector? thanks Arman. Edit after one week I...

Resize Columnvector in .Oct file

Does anyone know the correct syntax to resize a ColumnVector in a compiled .Oct function written for Octave? The ColumnVector will typically be 10 to 50 elements in length and will be passed to a feval call in a loop. After evaluation, in the next loop iteration, the ColumnVector will need to be resized, filled with new data and again pa...

C++: vector to stringstream

I want to know if it is possible to transform a std::vector to a std::stringstream using generic programming and how can one accomplish such a thing? ...

Vector iterators in for loops, return statements, warning, c++

Had 3 questions regarding a hw assignment for C++. The goal was to create a simple palindrome method. Here is my template for that: #ifndef PALINDROME_H #define PALINDROME_H #include <vector> #include <iostream> #include <cmath> template <class T> static bool palindrome(const std::vector<T> &input) { std::vector<T>::const_iterat...

How to print all values of Vector[]

I have a Vector of Object[] type that stores my data. How to print all it's objects ? The code: private static Vector<Object[]> vector = new Vector<Object[]>(); int event=0; for(int i=0; i<10; i++){ vector.add( this.addToObject(System.currentTimeMillis(), event , "String") ); event++; } private Object[] addToObject(long ...

WPF 3D extrude "a bitmap"

Hi, I'm looking for a way to simulate a projector in wpf 3D : i've these "in" parameters : beam shape : a black and white bitmap file beam size ( ex : 30 °) beam color beam intensity ( dimmer ) projector position (x,y,z) beam position (pan(x),tilt(y) relative to projector) First i was thinking of using light object but it seem tha...

How do I specify non-scalar parameters in a Slim table?

I want to test functions that have non-scalar parameters and return types, e.g., "given a matrix M, check that M times its inverse is the appropriate identity" or "given a row vector V, check that transpose(V) is the correct column vector. Do I need a clever use of TableTable? ...

Best way in Python to determine all possible intersections in a matrix?

So if I have a matrix (list of lists) where each column represents a unique word, each row represents a distinct document, and every entry is a 1 or 0, indicating whether or not the word for a given column exists in the document for a given row. What I'd like to know is how to determine all the possible combinations of words and documen...

Bank angle from up vector and look at vector?

Hi all. I can't figure out the formula to compute the bank (roll) angle from the up and lookat vectors, though I feel this angle must be measured in tha plan normal to the lookat vector. Any hint appreciated. FYI I use WPF. I have posted another question here, which is the same problem, but expressed only using math. ...

Why did I get this error : java.lang.Exception: XMLEncoder: discarding statement Vector.add() ?

My Java program look like this : public class Biz_Manager { static Contact_Info_Setting Customer_Contact_Info_Panel; static XMLEncoder XML_Encoder; ...... void Get_Customer_Agent_Shipping_Company_And_Shipping_Agent_Net_Worth_Info() { try { XML_Encoder=new XMLEncoder(new BufferedOutputStream(n...

How can i convert simple shape bitmap to vector ( geometry)

I would to know if it's possible to convert a simple bitmap to a geometry object ...

C++ vector and struct problem win32

I have a structure defined in my header file: struct video { wchar_t* videoName; std::vector<wchar_t*> audio; std::vector<wchar_t*> subs; }; struct ret { std::vector<video*> videos; wchar_t* errMessage; }; struct params{ HWND form; wchar_t* cwd; wchar_t* disk; ret* returnData; }; When I try to add my video structure to a vecto...

C++ template function compiles in header but not implementation

I'm trying to learn templates and I've run into this confounding error. I'm declaring some functions in a header file and I want to make a separate implementation file where the functions will be defined. Here's the code that calls the header (dum.cpp): #include <iostream> #include <vector> #include <string> #include "dumper2.h" int ...

Mapping Vectors

Is there a good way to map vectors? Here's an example of what I mean: vec0 = [0,0,0,0,0,0,0,0,0,0,0] vec1 = [1,4,2,7,3,2] vec2 = [0,0,0,0,0,0,0,0,0] vec2 = [7,2,7,9,9,6,1,0,4] vec4 = [0,0,0,0,0,0] mainvec = [0,0,0,0,0,0,0,0,0,0,0,1,4,2,7,3,2,0,0,0,0,0,0,0,0,0,7,2,7,9,9,6,1,0,4,0,0,0,0,0,0] Lets say mainvec doesn't exist (I'm just sho...

push_back private vectors with 2 methods, one isn't working

I have a class with a private vector of doubles. To access or modify these values, at first I used methods such as void classA::pushVector(double i) { this->vector.push_back(i); } double classA::getVector(int i) { return vector[i]; } This worked for a while until I found I would have to overload a lot of operators for what I needed, s...

Java and Different Types of Stacks

Currently the only stack I know anything about is Vector, I normally use this in place of an array but I understand that there is other types of stacks and they all suit different jobs. The project I am currently working on requires me to be inserting objects in a certain position inside a stack, not always the front of the stack and I ...

How to use a "vector of vector" ?

Hi! I allready searched on the web for it but I didn't get satisfying results. I want to create something like vector< vector<int*> > test_vector; How do i fill this vector of vector? How to acces it's members? Maybe someone knows some nice tutorials on the web? kind regards mikey ...

Given vector of one axis, how do I find vectors of other two axes?

This is a maths problem I am not exactly sure how to do. The vector is not aligned to an axis, so just rotating 90 degrees around x, y or z won't necessarily give me the other axes. ...

"Right" way to deallocate an std::vector object

The first solution is: std::vector<int> *vec = new std::vector<int>; assert(vec != NULL); // ... delete vec; An alternative is: std::vector<int> v; //... vec.clear(); vec.swap(std::vector<int>(vec)); The second solution's a bit of a trick --- what's the "right" way to do it? Update: I'm aware that the destructor will be called on...