すべてのポイントを他のすべてのポイントと比較したいので、次のようなアルゴリズムを実行できます。次のようなデータ構造を想定します。
struct Data {
    double x_, y_, z_;
    bool skip;
    const std::pair<double, double> & xy () const {
        return std::pair<double, double>(x, y);
    }
};
std::vector<Data> file;
typedef std::multimap<std::pair<double, double>, unsigned> PointMap;
PointMap xyline;
次に、ファイルを読み込むときに、を検索しxylineて、現在のポイントが既に存在するかどうかを確認します。その場合は、それに応じて現在のポイントとベクトルを更新しfileます (一致するすべてのポイントの行番号がわかっているため、すべての一致または最新の一致のみを選択して変更できます)。次に、現在の行に関連付けられている現在のポイントを挿入し、ファイルの次の行まで繰り返します。
ファイルが処理された後、 の内容を書き出しますfile。次に、必要に応じて、出力を使用して既存のファイルを置き換えることができます。
void update (PointMap::iterator first, PointMap::iterator last, Data &d) {
    //... revisit all matching points and decide which to keep
}
Data d;
std::ifstream ifile;
std::ofstream ofile;
ifile.open("input.dat");
while (ifile >> d.x_ >> d.y_ >> d.z_) {
    PointMap::iterator i = xyline.find(d.xy());
    if (i != xyline.end()) {
        update(i, xyline.upper_bound(d.xy(), d);
    }
    xyline.insert(i, std::pair<d.xy(), file.size());
    file.push_back(d);
}
ofile.open("output.dat");
for (size_t i = 0; i < file.size(); ++i) {
    d = file[i];
    if (!d.skip)
        ofile << d.x_ << " " << d.y_ << " " << d.z_ << "\n";
}