#include<iostream>
#include<algorithm>

#include "nlsr_npl.hpp"

namespace nlsr
{

    using namespace std;

    Npl::Npl()
    {
    }

    Npl::~Npl()
    {
    }

    static bool
    nameCompare(string& s1, string& s2)
    {
        return s1==s2;
    }

    int
    Npl::insertIntoNpl(string& name)
    {
        std::list<string >::iterator it = std::find_if( nameList.begin(),
                                          nameList.end(),
                                          bind(&nameCompare, _1 , name));
        if( it != nameList.end() )
        {
            return -1;
        }
        nameList.push_back(name);
        return 0;
    }

    int
    Npl::removeFromNpl(string& name)
    {
        std::list<string >::iterator it = std::find_if( nameList.begin(),
                                          nameList.end(),
                                          bind(&nameCompare, _1 , name));
        if( it != nameList.end() )
        {
            nameList.erase(it);
        }
        return -1;
    }

    void
    Npl::sortNpl()
    {
        nameList.sort();
    }

    void
    Npl::printNpl()
    {
        int i=1;
        for( std::list<string>::iterator it=nameList.begin(); it != nameList.end();
                it++)
        {
            cout<<"Name "<<i<<" : "<<(*it)<<endl;
            i++;
        }
    }

}//namespace nlsr
