-
Notifications
You must be signed in to change notification settings - Fork 0
/
List_interface.cpp
62 lines (61 loc) · 1.31 KB
/
List_interface.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "List_interface.h"
List_interface::List_interface(list_type e_type)
{
m_type = e_type;
switch (m_type)
{
case t_int: m_lst = new List <int>; break;
case t_double: m_lst = new List <double>; break;
case t_char: m_lst = new List <char>; break;
}
}
List_interface::~List_interface()
{
delete m_lst;
}
void List_interface::sort()
{
m_lst->sort();
}
void List_interface::reverse()
{
m_lst->reverse();
}
string List_interface::show()
{
return m_lst->show();
}
void List_interface::deleteAt(int pos)
{
m_lst->deleteAt(pos);
}
void List_interface::pop_back()
{
switch (m_type)
{
case t_int:
static_cast <List <int> * > (m_lst)->pop_back();
break;
case t_double:
static_cast <List <double> * > (m_lst)->pop_back();
break;
case t_char:
static_cast <List <char> * > (m_lst)->pop_back();
break;
}
}
void List_interface::pop_front()
{
switch (m_type)
{
case t_int:
static_cast <List <int> * > (m_lst)->pop_front();
break;
case t_double:
static_cast <List <double> * > (m_lst)->pop_front();
break;
case t_char:
static_cast <List <char> * > (m_lst)->pop_front();
break;
}
}