-#include <msp/algo.h>
+/* $Id$
+
+This file is part of builder
+Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
#include "buildinfo.h"
using namespace Msp;
+/**
+Adds another BuildInfo to the end of this one.
+*/
void BuildInfo::add(const BuildInfo &bi)
{
cflags.insert(cflags.end(), bi.cflags.begin(), bi.cflags.end());
libs.insert(libs.end(), bi.libs.begin(), bi.libs.end());
}
+/**
+Makes sure there are no duplicate entries in the lists.
+*/
void BuildInfo::unique()
{
unique(cflags);
unique(libs);
}
+/**
+Removes any duplicate entries from a list, leaving only the first one. The
+order of other elements is preserved. O(n²) efficiency.
+*/
void BuildInfo::unique(StringList &l)
{
StringList l2;
for(StringList::iterator i=l.begin(); i!=l.end(); ++i)
- if(!contains(l2, *i))
+ if(find(l2.begin(), l2.end(), *i)==l2.end())
l2.push_back(*i);
swap(l, l2);
}