blob: b2786992d815ed3465226d2d8bed7f4f938f12e7 [file] [log] [blame]
akmhoque298385a2014-02-13 14:13:09 -06001#include<iostream>
2#include<algorithm>
3
4#include "nlsr_npl.hpp"
5
6using namespace std;
7
8Npl::Npl(){
9
10}
11
12Npl::~Npl(){
13
14}
15
16static bool
17nameCompare(string& s1, string& s2){
18 return s1==s2;
19}
20
21int
22Npl::insertIntoNpl(string& name){
23 std::list<string >::iterator it = std::find_if( nameList.begin(),
24 nameList.end(),
25 bind(&nameCompare, _1 , name));
26
27 if( it != nameList.end() ){
28 return -1;
29 }
30
31 nameList.push_back(name);
32 return 0;
33
34}
35
36int
37Npl::removeFromNpl(string& name)
38{
39 std::list<string >::iterator it = std::find_if( nameList.begin(),
40 nameList.end(),
41 bind(&nameCompare, _1 , name));
42
43 if( it != nameList.end() ){
44 nameList.erase(it);
45 }
46
47 return -1;
48}
49
50void
51Npl::sortNpl()
52{
53 nameList.sort();
54}
55
56void
57Npl::printNpl(){
58 int i=1;
59 for( std::list<string>::iterator it=nameList.begin(); it != nameList.end(); it++){
60 cout<<"Name "<<i<<" : "<<(*it)<<endl;
61 i++;
62 }
63}