From: Joe Buck Date: 2010-01-02T05:11:40+09:00 Subject: Re: Delete elements in array, break, and keep changes? Sorry for the terrible formatting. As another example, here is C++ code that would do what I want using iterators. typedef std::vector spots_t; spots_t cSpots; // Fill cSpots here ... CLatLngBox cLatLngBox; for(int i=0; i<72; i++) { // Move cLatLngBox to the next block .. // Our new cluster. CCluster cCluster; // Iterate points. spots_t::iterator itr = cSpots.begin (); for(itr; itr!=cSpots.end();) { if(cLatLngBox.is_in_box(*itr)) { // Add to cluster. // This is where we remove the spot. itr = cSpots.erase(itr); } else { if((*itr).lng > cLatLngBox.lng) { // Done with the inner loop. break; } // Next spot. itr++; } } } -- Posted via http://www.ruby-forum.com/.