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