//Excerpt from visionary.C. class closest_unoccupied_to { const terminal_t::iterator it; const terminal_t::value_type bg; //background character public: closest_unoccupied_to(const terminal_t::iterator& initial_it, terminal_t::value_type initial_bg) : it(initial_it), _bg(initial_bg) {} //Return true if it1 is a closer unoccupied location to it than it2 is. bool operator()(const terminal_t::iterator& it1, const terminal_t::iterator& it2) const { //If it1 is already occupied, return false. if (*it1 != bg) { return false; } /Arrive here is it1 is unoccupied. //If it2 is already occupied, return true. if (*it2 != bg) { return true; } //Arrive here if it1 and it2 are both unoccupied. return distance(it, it1) < distance(it, it2); } };