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