Search Results

Search found 3677 results on 148 pages for 'concurrent vector'.

Page 5/148 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • C++ vector pointer/reference problem

    - by sub
    Please take a look at this example: #include <iostream> #include <vector> #include <string> using namespace std; class mySubContainer { public: string val; }; class myMainContainer { public: mySubContainer sub; }; void doSomethingWith( myMainContainer &container ) { container.sub.val = "I was modified"; } int main( ) { vector<myMainContainer> vec; /** * Add test data */ myMainContainer tempInst; tempInst.sub.val = "foo"; vec.push_back( tempInst ); tempInst.sub.val = "bar"; vec.push_back( tempInst ); // 1000 lines of random code here int i; int size = vec.size( ); myMainContainer current; for( i = 0; i < size; i ++ ) { cout << i << ": Value before='" << vec.at( i ).sub.val << "'" << endl; current = vec.at( i ); doSomethingWith( current ); cout << i << ": Value after='" << vec.at( i ).sub.val << "'" << endl; } system("pause");//i suck } A hell lot of code for an example, I know. Now so you don't have to spend years thinking about what this [should] do[es]: I have a class myMainContainer which has as its only member an instance of mySubContainer. mySubContainer only has a string val as member. So I create a vector and fill it with some sample data. Now, what I want to do is: Iterate through the vector and make a separate function able to modify the current myMainContainer in the vector. However, the vector remains unchanged as the output tells: 0: Value before='foo' 0: Value after='foo' 1: Value before='bar' 1: Value after='bar' What am I doing wrong? doSomethingWith has to return void, I can't let it return the modified myMainContainer and then just overwrite it in the vector, that's why I tried to pass it by reference as seen in the doSomethingWith definition above.

    Read the article

  • overloaded stream insertion operator with a vector

    - by Julz
    hi, i'm trying to write an overloaded stream insertion operator for a class who's only member is a vector. i dont really know what i'm doing. (lets make that clear) it's a vector of "Points" which is a struct containing two doubles. i figure what i want is to insert user input (a bunch of doubles) into a stream that i then send to a modifier method? i keep working off other stream insertion examples such as... std::ostream& operator<< (std::ostream& o, Fred const& fred) { return o << fred.i_; } but when i try a similar..... istream & operator >> (istream &inStream, Polygon &vertStr) { inStream >> ws; inStream >> vertStr.vertices; return inStream; } i get an error "no match for operator etc etc. if i leave off the .vertices it compiles but i figure it's not right? (vertices is the name of my vector ) and even if it is right, i dont actually know what syntax to use in my driver to use it? also not %100 on what my modifier method needs to look like. here's my Polygon class //header #ifndef POLYGON_H #define POLYGON_H #include "Segment.h" #include <vector> class Polygon { friend std::istream & operator >> (std::istream &inStream, Polygon &vertStr); public: //Constructor Polygon(const Point &theVerts); //Default Constructor Polygon(); //Copy Constructor Polygon(const Polygon &polyCopy); //Accessor/Modifier methods inline std::vector<Point> getVector() const {return vertices;} //Return number of Vector elements inline int sizeOfVect() const {return (int) vertices.capacity();} //add Point elements to vector inline void setVertices(const Point &theVerts){vertices.push_back (theVerts);} private: std::vector<Point> vertices; }; #endif //Body using namespace std; #include "Polygon.h" // Constructor Polygon::Polygon(const Point &theVerts) { vertices.push_back (theVerts); } //Copy Constructor Polygon::Polygon(const Polygon &polyCopy) { vertices = polyCopy.vertices; } //Default Constructor Polygon::Polygon(){} istream & operator >> (istream &inStream, Polygon &vertStr) { inStream >> ws; inStream >> vertStr; return inStream; } any help greatly appreciated, sorry to be so vague, a lecturer has just kind of given us a brief example of stream insertion then left us on our own thanks. oh i realise there are probably many other problems that need fixing

    Read the article

  • overloaded stream insetion operator with a vector

    - by julz666
    hi, i'm trying to write an overloaded stream insertion operator for a class who's only member is a vector. i dont really know what i'm doing. (lets make that clear) it's a vector of "Points" which is a struct containing two doubles. i figure what i want is to insert user input (a bunch of doubles) into a stream that i then send to a modifier method? i keep working off other stream insertion examples such as... std::ostream& operator<< (std::ostream& o, Fred const& fred) { return o << fred.i_; } but when i try a similar..... istream & operator >> (istream &inStream, Polygon &vertStr) { inStream >> ws; inStream >> vertStr.vertices; return inStream; } i get an error "no match for operator etc etc. if i leave off the .vertices it compiles but i figure it's not right? (vertices is the name of my vector ) and even if it is right, i dont actually know what syntax to use in my driver to use it? also not %100 on what my modifier method needs to look like. here's my Polygon class //header #ifndef POLYGON_H #define POLYGON_H #include "Segment.h" #include <vector> class Polygon { friend std::istream & operator >> (std::istream &inStream, Polygon &vertStr); public: //Constructor Polygon(const Point &theVerts); //Default Constructor Polygon(); //Copy Constructor Polygon(const Polygon &polyCopy); //Accessor/Modifier methods inline std::vector<Point> getVector() const {return vertices;} //Return number of Vector elements inline int sizeOfVect() const {return (int) vertices.capacity();} //add Point elements to vector inline void setVertices(const Point &theVerts){vertices.push_back (theVerts);} private: std::vector<Point> vertices; }; #endif //Body using namespace std; #include "Polygon.h" // Constructor Polygon::Polygon(const Point &theVerts) { vertices.push_back (theVerts); } //Copy Constructor Polygon::Polygon(const Polygon &polyCopy) { vertices = polyCopy.vertices; } //Default Constructor Polygon::Polygon(){} istream & operator >> (istream &inStream, Polygon &vertStr) { inStream >> ws; inStream >> vertStr; return inStream; } any help greatly appreciated, sorry to be so vague, a lecturer has just kind of given us a brief example of stream insertion then left us on our own thanks. oh i realise there are probably many other problems that need fixing

    Read the article

  • STL vector reserve() and copy()

    - by natersoz
    Greetings, I am trying to perform a copy from one vector (vec1) to another vector (vec2) using the following 2 abbreviated lines of code (full test app follows): vec2.reserve( vec1.size() ); copy(vec1.begin(), vec1.end(), vec2.begin()); While the call to vec2 sets the capacity of vector vec2, the copying of data to vec2 seems to not fill in the values from vec1 to vec2. Replacing the copy() function with calls to push_back() works as expected. What am I missing here? Thanks for your help. vectest.cpp test program followed by resulting output follows. Compiler: gcc 3.4.4 on cygwin. Nat /** * vectest.cpp */ #include <iostream> #include <vector> using namespace std; int main() { vector<int> vec1; vector<int> vec2; vec1.push_back(1); vec1.push_back(2); vec1.push_back(3); vec1.push_back(4); vec1.push_back(5); vec1.push_back(6); vec1.push_back(7); vec2.reserve( vec1.size() ); copy(vec1.begin(), vec1.end(), vec2.begin()); cout << "vec1.size() = " << vec1.size() << endl; cout << "vec1.capacity() = " << vec1.capacity() << endl; cout << "vec1: "; for( vector<int>::const_iterator iter = vec1.begin(); iter < vec1.end(); ++iter ) { cout << *iter << " "; } cout << endl; cout << "vec2.size() = " << vec2.size() << endl; cout << "vec2.capacity() = " << vec2.capacity() << endl; cout << "vec2: "; for( vector<int>::const_iterator iter = vec2.begin(); iter < vec2.end(); ++iter ) { cout << *iter << endl; } cout << endl; } output: vec1.size() = 7 vec1.capacity() = 8 vec1: 1 2 3 4 5 6 7 vec2.size() = 0 vec2.capacity() = 7 vec2:

    Read the article

  • Windows 8 / IIS 8 Concurrent Requests Limit

    - by OWScott
    IIS 8 on Windows Server 2012 doesn’t have any fixed concurrent request limit, apart from whatever limit would be reached when resources are maxed. However, the client version of IIS 8, which is on Windows 8, does have a concurrent connection request limitation to limit high traffic production uses on a client edition of Windows. Starting with IIS 7 (Windows Vista), the behavior changed from previous versions.  In previous client versions of IIS, excess requests would throw a 403.9 error message (Access Forbidden: Too many users are connected.).  Instead, Windows Vista, 7 and 8 queue excessive requests so that they will be handled gracefully, although there is a maximum number of requests that will be processed simultaneously. Thomas Deml provided a concurrent request chart for Windows Vista many years ago, but I have been unable to find an equivalent chart for Windows 8 so I asked Wade Hilmo from the IIS team what the limits are.  Since this is controlled not by the IIS team itself but rather from the Windows licensing team, he asked around and found the authoritative answer, which I’ll provide below. Windows 8 – IIS 8 Concurrent Requests Limit Windows 8 3 Windows 8 Professional 10 Windows RT N/A since IIS does not run on Windows RT Windows 7 – IIS 7.5 Concurrent Requests Limit Windows 7 Home Starter 1 Windows 7 Basic 1 Windows 7 Premium 3 Windows 7 Ultimate, Professional, Enterprise 10 Windows Vista – IIS 7 Concurrent Requests Limit Windows Vista Home Basic (IIS process activation and HTTP processing only) 3 Windows Vista Home Premium 3 Windows Vista Ultimate, Professional 10 Windows Server 2003, Windows Server 2008, Windows Server 2008 R2 and Windows Server 2012 allow an unlimited amount of simultaneously requests.

    Read the article

  • Rendering a big game universe - bitmaps or vector graphics?

    - by user1641923
    I am new to an Android development, though I have much experience with Java, C++, PHP programming and a bit experience with vector graphics too (basic 3d Studio Max, Flash, etc). I am starting to work on an Android game. It is going to be a 2D space shooter/RPG, and I am not going to use any game engines and any 3D party libs. I really want to create a very large game universe, or even pseudo-infinite (without visible borders, as if it were a 2D projection of a sphere). It should include 10-12 clusters of 7-8 planets/other space objects and random amount of single asteroids/comets, which player can interact with and also not interactive background. I am looking for a least complicated aproach to create such a universe. My current ideas are: Simply create bitmaps with space scenery background so that they can be tiled seamlessly repeated and construct my 2D universe of this tiles, then place interactive objects (planets, other spaceships) on it. Using vector graphics. I would have a solid color background, some random background objects and gradients here and there. My problems here: Lack of knowledge of how well vector graphics is integrated in Android. Performance? Memory usage? Does Android manage big bitmaps well? Do all of the bitmaps have to be in memory during all game process? I am interested in technical details regarding each of the ideas and a suggestion, which I should go with.

    Read the article

  • How to reduce java concurrent mode failure and excessive gc

    - by jimx
    In Java, the concurrent mode failure means that the concurrent collector failed to free up enough memory space form tenured and permanent gen and has to give up and let the full stop-the-world gc kicks in. The end result could be very expensive. I understand this concept but never had a good comprehensive understanding of A) what could cause a concurrent mode failure and B) what's the solution?. This sort of unclearness leads me to write/debug code without much of hints in mind and often has to shop around those performance flags from Foo to Bar without particular reasons, just have to try. I'd like to learn from developers here how your experience is. If you had previous encountered such performance issue, what was the cause and how you addressed it? If you have coding recommendations, please don't be too general. Thanks!

    Read the article

  • Vector is pointing to uninitialized bytes when used in recvfrom call

    - by Adam A.
    In a function that I am writing I am trying to return a pointer to a vector of unsigned chars. The relevant code is below. std::vector<unsigned char> *ret = new std::vector<unsigned char>(buffSize,'0'); int n = recvfrom(fd_, &((*ret)[0]) ,buffSize, &recvAddress, &sockSize); //This should work too... recvfrom(fd_, ret ,buffSize, &recvAddress, &sockSize); // display chars somehow just for testing for(std::vector<unsigned char>::iterator it=ret->begin(); it<it->end();i++) { std::cout<<*it; } std::cout<<std::endl; ... return ret; When I run this through valgrind I get errors talking about how the buffer in recvfrom is pointing to uninitialized bytes. I've narrowed this down to the vector since I swapped it out for an unsigned char array and everything works fine. Any suggestions?

    Read the article

  • AS3 serialization of Vector of custom objects

    - by aaaidan
    What is serialization support like for the new Vector class. I have a Vector.<GameMove> which I'd like to serialize into a ByteArray. GameMove is a custom class. I presume it's necesssary to call registerClassAlias() on GameMove, but do I also have to register Vector.<GameMove>? It's it it's own distinctive type, or is it kinda composed of those two types?

    Read the article

  • vector::erase with pointer member

    - by matt
    I am manipulating vectors of objects defined as follow: class Hyp{ public: int x; int y; double wFactor; double hFactor; char shapeNum; double* visibleShape; int xmin, xmax, ymin, ymax; Hyp(int xx, int yy, double ww, double hh, char s): x(xx), y(yy), wFactor(ww), hFactor(hh), shapeNum(s) {visibleShape=0;shapeNum=-1;}; //Copy constructor necessary for support of vector::push_back() with visibleShape Hyp(const Hyp &other) { x = other.x; y = other.y; wFactor = other.wFactor; hFactor = other.hFactor; shapeNum = other.shapeNum; xmin = other.xmin; xmax = other.xmax; ymin = other.ymin; ymax = other.ymax; int visShapeSize = (xmax-xmin+1)*(ymax-ymin+1); visibleShape = new double[visShapeSize]; for (int ind=0; ind<visShapeSize; ind++) { visibleShape[ind] = other.visibleShape[ind]; } }; ~Hyp(){delete[] visibleShape;}; }; When I create a Hyp object, allocate/write memory to visibleShape and add the object to a vector with vector::push_back, everything works as expected: the data pointed by visibleShape is copied using the copy-constructor. But when I use vector::erase to remove a Hyp from the vector, the other elements are moved correctly EXCEPT the pointer members visibleShape that are now pointing to wrong addresses! How to avoid this problem? Am I missing something?

    Read the article

  • C# Vector maths questions

    - by Mark
    Im working in a screen coordinate space that is different to that of the classical X/Y coordinate space, where my Y direction goes down in the positive instead of up. Im also trying to figure out how to make a Circle on my screen always face away from the center point of the screen. If the center point of my screen is at x(200) y(300) and the point of my circle's center is at x(150) and y(380) then I would like to calculate the angle that the circle should be facing. At the moment I have this: Point centerPoint = new Point(200, 300); Point middleBottom = new Point(200, 400); Vector middleVector = new Vector(centerPoint.X - middleBottom.X, centerPoint.Y - middleBottom.Y); Vector vectorOfCircle = new Vector(centerPoint.X - 150, centerPoint.Y - 400); middleVector.Normalize(); vectorOfCircle.Normalize(); var angle = Math.Acos(Vector.CrossProduct(vectorOfCircle, middleVector)); Console.WriteLine("Angle: {0}", angle * (180/Math.PI)); Im not getting what I would expect. I would say that when I enter in x(150) and y(300) of my circle, I would expect to see the rotation of 90 deg, but Im not getting that... Im getting 180!! Any help here would be greatly appreciated. Cheers, Mark

    Read the article

  • Using read() directly into a C++ std:vector

    - by Joe
    I'm wrapping up user space linux socket functionality in some C++ for an embedded system (yes, this is probably reinventing the wheel again). I want to offer a read and write implementation using a vector. Doing the write is pretty easy, I can just pass &myvec[0] and avoid unnecessary copying. I'd like to do the same and read directly into a vector, rather than reading into a char buffer then copying all that into a newly created vector. Now, I know how much data I want to read, and I can allocate appropriately (vec.reserve). I can also read into &myvec[0], though this is probably a VERY BAD IDEA. Obviously doing this doesn't allow myvec.size to return anything sensible. Is there any way of doing this that 1) Doesn't completely feel yucky from a safety/C++ perspective and 2) Doesn't involve two copies of the data block - once from kernel to user space and once from a C char * style buffer into a C++ vector. Any thoughts collective?

    Read the article

  • C++ Operator overloading - 'recreating the Vector'

    - by Wallter
    I am currently in a collage second level programing course... We are working on operator overloading... to do this we are to rebuild the vector class... I was building the class and found that most of it is based on the [] operator. When I was trying to implement the + operator I run into a weird error that my professor has not seen before (apparently since the class switched IDE's from MinGW to VS express...) (I am using Visual Studio Express 2008 C++ edition...) Vector.h #include <string> #include <iostream> using namespace std; #ifndef _VECTOR_H #define _VECTOR_H const int DEFAULT_VECTOR_SIZE = 5; class Vector { private: int * data; int size; int comp; public: inline Vector (int Comp = 5,int Size = 0) : comp(Comp), size(Size) { if (comp > 0) { data = new int [comp]; } else { data = new int [DEFAULT_VECTOR_SIZE]; comp = DEFAULT_VECTOR_SIZE; } } int size_ () const { return size; } int comp_ () const { return comp; } bool push_back (int); bool push_front (int); void expand (); void expand (int); void clear (); const string at (int); int operator[ ](int); Vector& operator+ (Vector&); Vector& operator- (const Vector&); bool operator== (const Vector&); bool operator!= (const Vector&); ~Vector() { delete [] data; } }; ostream& operator<< (ostream&, const Vector&); #endif Vector.cpp #include <iostream> #include <string> #include "Vector.h" using namespace std; const string Vector::at(int i) { this[i]; } void Vector::expand() { expand(size); } void Vector::expand(int n ) { int * newdata = new int [comp * 2]; if (*data != NULL) { for (int i = 0; i <= (comp); i++) { newdata[i] = data[i]; } newdata -= comp; comp += n; delete [] data; *data = *newdata; } else if ( *data == NULL || comp == 0) { data = new int [DEFAULT_VECTOR_SIZE]; comp = DEFAULT_VECTOR_SIZE; size = 0; } } bool Vector::push_back(int n) { if (comp = 0) { expand(); } for (int k = 0; k != 2; k++) { if ( size != comp ){ data[size] = n; size++; return true; } else { expand(); } } return false; } void Vector::clear() { delete [] data; comp = 0; size = 0; } int Vector::operator[] (int place) { return (data[place]); } Vector& Vector::operator+ (Vector& n) { int temp_int = 0; if (size > n.size_() || size == n.size_()) { temp_int = size; } else if (size < n.size_()) { temp_int = n.size_(); } Vector newone(temp_int); int temp_2_int = 0; for ( int j = 0; j <= temp_int && j <= n.size_() && j <= size; j++) { temp_2_int = n[j] + data[j]; newone[j] = temp_2_int; } //////////////////////////////////////////////////////////// return newone; //////////////////////////////////////////////////////////// } ostream& operator<< (ostream& out, const Vector& n) { for (int i = 0; i <= n.size_(); i++) { //////////////////////////////////////////////////////////// out << n[i] << " "; //////////////////////////////////////////////////////////// } return out; } Errors: out << n[i] << " "; error C2678: binary '[' : no operator found which takes a left-hand operand of type 'const Vector' (or there is no acceptable conversion) return newone; error C2106: '=' : left operand must be l-value As stated above, I am a student going into Computer Science as my selected major I would appreciate tips, pointers, and better ways to do stuff :D

    Read the article

  • c++ : list(vector) definition with array

    - by Meloun
    I have Class Email, there is parameter "bcc" in her construktor. Its actually list of emails for copies. There is no fixed number of these emails and later i have to have possibility to extend this list. //construktor prototype Email::Email(vector<string> bcc) So i want to use type vector or list for that and function push_back(). How can i make a new instance with bcc emails? I need actually declaration with definition for my list. I've found this definition with iterator for integer type: int myints[] = {16,2,77,29}; Email myEmail(vector<int> (myints, myints + sizeof(myints) / sizeof(int) )); , but its not very user friend and i need it with strings. Is there something like this? Email myEmail(vector<string> ("first","second","third"));

    Read the article

  • How to call a method withgin a vector?

    - by Mike Dooley
    Hi! How do I call a method of an object which is stored within a vector? The following code fails... ClassA* class_derived_a = new ClassDerivedA; ClassA* class_another_a = new ClassAnotherDerivedA; vector<ClassA*> test_vector; test_vector.push_back(class_derived_a); test_vector.push_back(class_another_a); for (vector<ClassA*>::iterator it = test_vector.begin(); it != test_vector.end(); it++) it->printOutput(); The code retrieves the following error: test3.cpp:47: error: request for member ‘printOutput’ in ‘* it.__gnu_cxx::__normal_iterator<_Iterator, _Container::operator- with _Iterator = ClassA**, _Container = std::vector ’, which is of non-class type ‘ClassA*’ The problem seems to be it->printOutput(); but at the moment I don't know how to call the method properly, does anyone know? regards mikey

    Read the article

  • Using std::ifstream to load in an array of struct data type into a std::vector

    - by Sent1nel
    I am working on a bitmap loader in C++ and when moving from the C style array to the std::vector I have run into an usual problem of which Google does not seem to have the answer. 8 Bit and 4 bit, bitmaps contain a colour palette. The colour palette has blue, green, red and reserved components each 1 byte in size. // Colour palette struct BGRQuad { UInt8 blue; UInt8 green; UInt8 red; UInt8 reserved; }; The problem I am having is when I create a vector of the BGRQuad structure I can no longer use the ifstream read function to load data from the file directly into the BGRQuad vector. // This code throws an assert failure! std::vecotr quads; if (coloursUsed) // colour table available { // read in the colours quads.reserve(coloursUsed); inFile.read( reinterpret_cast(&quads[0]), coloursUsed * sizeof(BGRQuad) ); } Does anyone know how to read directly into the vector without having to create a C array and copy data into the BGRQuad vector?

    Read the article

  • Finding if all elements in a vector<string> are in a string

    - by devin
    I have a vector and I need to see if all the strings in that vector are substrings of another given string. eg vector<string> v; v.push_back("str1"); v.push_back("str2"); string s1 = "str1, str2, str3"; string s2 = "str1, str3"; Is there a way to get true from s1 and false from s2 without looping over the vector? Also, note that due to my environment, I can't use boost. I think if I had boost, I could do this.

    Read the article

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

    - by Jacob
    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?

    Read the article

  • Vector does reallocation on every push_back

    - by Amrish
    IDE - Visual Studio 2008, Visual C++ I have a custom class Class1 with a copy constructor to it. I also have a vector Data is inserted using the following code Class1* objClass1; vector<Class1> vClass1; for(int i=0;i<1000;i++) { objClass1 = new Class1(); vClass1.push_back(*objClass1); delete objClass1; } Now on every insert, the vector gets re-allocated and all the existing contents are copied to new locations. For example, if the vector has 5 elements and if I insert the 6th one, the previous 5 elements along with the new one gets copied to a new location (I figured it out by adding log statements in the copy constructors.) On using reserve(), this however does not happen as expected! I have the following questions Is it mandatory to always use the reserve statement? Does vector does a reallocation every time I do a push_back; or does it happen because I am debugging?

    Read the article

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

    - by Crystal
    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_iterator it = input.begin(); std::vector<T>::const_reverse_iterator rit = input.rbegin(); for (int i = 0; i < input.size()/2; i++, it++, rit++) { if (!(*it == *rit)) { return false; } } return true; } template <class T> static void showVector(const std::vector<T> &input) { for (std::vector<T>::const_iterator it = input.begin(); it != input.end(); it++) { std::cout << *it << " "; } } #endif Regarding the above code, can you have more than one iterator declared in the first part of the for loop? I tried defining both the "it" and "rit" in the palindrome() method, and I kept on getting an error about needing a "," before rit. But when I cut and paste outside the for loop, no errors from the compiler. (I'm using VS 2008). Second question, I pretty much just brain farted on this one. But is the way I have my return statements in the palindrome() method ok? In my head, I think it works like, once the *it and *rit do not equal each other, then the function returns false, and the method exits at this point. Otherwise if it goes all the way through the for loop, then it returns true at the end. I totally brain farted on how return statements work in if blocks and I tried looking up a good example in my book and I couldn't find one. Finally, I get this warnings: \palindrome.h(14) : warning C4018: '<' : signed/unsigned mismatch Now is that because I run my for loop until (i < input.size()/2) and the compiler is telling me that input can be negative? Thanks!

    Read the article

  • Vector.erase(Iterator) causes bad memory access

    - by xon1c
    Hi, I am trying to do a Z-Index reordering of videoObjects stored in a vector. The plan is to identify the videoObject which is going to be put on the first position of the vector, erase it and then insert it at the first position. Unfortunately the erase() function always causes bad memory access. Here is my code: testApp.h: vector<videoObject> videoObjects; vector<videoObject>::iterator itVid; testApp.cpp: // Get the videoObject which relates to the user event for(itVid = videoObjects.begin(); itVid != videoObjects.end(); ++itVid){ if(videoObjects.at(itVid - videoObjects.begin()).isInside(ofPoint(tcur.getX(), tcur.getY()))){ videoObjects.erase(itVid); } } This should be so simple but I just don't see where I'm taking the wrong turn. Thx, xonic

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >