-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtaskHost.h
55 lines (52 loc) · 1016 Bytes
/
taskHost.h
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
#pragma once
#include "basic_list.h"
#include "list_node.h"
#include <iostream>
class taskHost
{
public:
/// <summary>
/// Ïîâòîðÿþùèåñÿ ÷èñëà ïåðåíåñòè â êîíåö ìàññèâà
/// </summary>
/// <typeparam name="T">Òèï óçëà</typeparam>
/// <param name="list">Ýêçåìïëÿð ñïèñêà</param>
template <typename T>
void static task1(basic_list<T> &list) {
int len = list.length();
for (int i(0); i < len; i++) {
auto tmp = list.getByNumber(i);
//åñëè íàéä¸ì, òî îáìåíÿåì çíà÷åíèÿ, ñîêðàòèâ len
bool find = false;
for (int j(0); j < list.length() && !find; j++) {
if (tmp->value == list.getByNumber(j)->value) {
list.swap(tmp, list.getByNumber(j));
find = true;
len--;
i = 0;
}
}
}
}
};
//struct A {
// A() { a = 0; }
// int a;
// A* next;
//};
//
//struct B
//{
// B() { a = 100; }
// int a;
// int next;
//};
//template <typename T>
//int test(T* ptr) {
// std::cout << ptr->a << std::endl;
// return -1;
//}
//
//void test2() {
// test<A>(new A);
// test<B>(new B);
//}