CStringList から重複したエントリを削除する方法はありますか?
ありがとう、
void RemoveDuplicates(CStringList &lst)
{
for (POSITION pos=lst.GetHeadPosition(); pos; )
{
const CString &strValue = lst.GetNext(pos);
// check next hits in the list
for (POSITION pos2=pos; pos2; )
{
// Save current pointer
POSITION posToDelete = pos2;
const CString &strValue2 = lst.GetNext(pos2);
if (strValue==strValue2)
{
// remove duplicate
lst.RemoveAt(posToDelete);
// There is a chance that we just deleted the follower from the outer loop
if (posToDelete==pos)
pos = pos2;
}
}
}
}