blob: 326b00108041398da386148df463796351eec60a [file] [log] [blame]
akmhoque298385a2014-02-13 14:13:09 -06001#include<iostream>
2#include<algorithm>
3
4#include "nlsr_npl.hpp"
5
akmhoque1fd8c1e2014-02-19 19:41:49 -06006namespace nlsr
akmhoque298385a2014-02-13 14:13:09 -06007{
akmhoque298385a2014-02-13 14:13:09 -06008
akmhoque1fd8c1e2014-02-19 19:41:49 -06009 using namespace std;
akmhoque298385a2014-02-13 14:13:09 -060010
akmhoque1fd8c1e2014-02-19 19:41:49 -060011 Npl::Npl()
12 {
akmhoque298385a2014-02-13 14:13:09 -060013
akmhoque1fd8c1e2014-02-19 19:41:49 -060014 }
akmhoque298385a2014-02-13 14:13:09 -060015
akmhoque1fd8c1e2014-02-19 19:41:49 -060016 Npl::~Npl()
17 {
18
19 }
20
21 static bool
22 nameCompare(string& s1, string& s2)
23 {
24 return s1==s2;
25 }
26
27 int
28 Npl::insertIntoNpl(string& name)
29 {
30 std::list<string >::iterator it = std::find_if( nameList.begin(),
31 nameList.end(),
32 bind(&nameCompare, _1 , name));
33
34 if( it != nameList.end() )
35 {
36 return -1;
37 }
38
39 nameList.push_back(name);
40 return 0;
41
42 }
43
44 int
45 Npl::removeFromNpl(string& name)
46 {
47 std::list<string >::iterator it = std::find_if( nameList.begin(),
48 nameList.end(),
49 bind(&nameCompare, _1 , name));
50
51 if( it != nameList.end() )
52 {
53 nameList.erase(it);
54 }
55
56 return -1;
57 }
58
59 void
60 Npl::sortNpl()
61 {
62 nameList.sort();
63 }
64
65 void
66 Npl::printNpl()
67 {
68 int i=1;
69 for( std::list<string>::iterator it=nameList.begin(); it != nameList.end();
70 it++)
71 {
72 cout<<"Name "<<i<<" : "<<(*it)<<endl;
73 i++;
74 }
75 }
akmhoqueb1710aa2014-02-19 17:13:36 -060076
77}//namespace nlsr