Exemple #1
0
//-----------------------------------------------------------------------------------------
void filter_unique(XmlElement::XmlSet& fldlist)
{
	using UniqueFieldMap = map<string, const XmlElement *>;
	UniqueFieldMap ufm;
	unsigned dupls(0);
	for(const auto *pp : fldlist)
	{
		string name;
		pp->GetAttr("name", name);
		if (!ufm.insert({name, pp}).second)
			++dupls; // cerr << "Duplicate field: " << name << endl;
	}

	fldlist.clear();
	for(const auto& pp : ufm)
		fldlist.insert(pp.second);
}
Exemple #2
0
//-----------------------------------------------------------------------------------------
void filter_unique(XmlElement::XmlSet& fldlist)
{
	typedef map<string, const XmlElement *> UniqueFieldMap;
	UniqueFieldMap ufm;
	unsigned dupls(0);
	for(XmlElement::XmlSet::const_iterator itr(fldlist.begin()); itr != fldlist.end(); ++itr)
	{
		string name;
		(*itr)->GetAttr("name", name);
		if (!ufm.insert(UniqueFieldMap::value_type(name, *itr)).second)
			++dupls; // cerr << "Duplicate field: " << name << endl;
	}

	fldlist.clear();
	for(UniqueFieldMap::const_iterator itr(ufm.begin()); itr != ufm.end(); ++itr)
		fldlist.insert(itr->second);
}