algorithms

algorithms Commit Details


Date:2013-02-16 17:51:00 (11 years 10 months ago)
Author:Natalie Adams
Branch:default
Commit:019f5c4964fc
Parents: 6c891dee9ea8
Message:Updating code

Changes:
Acpp/algorithms/src/InsertSort.h (full)
Acpp/algorithms/src/SearchAlgorithm.h (full)
Acpp/algorithms/src/SortAlgorithm.h (full)
Acpp/algorithms/src/vector_helper.h (full)
Mcpp/algorithms/algorithms.vcxproj (2 diffs)
Mcpp/algorithms/algorithms.vcxproj.filters (1 diff)
Mcpp/algorithms/src/Algorithm.h (1 diff)
Mcpp/algorithms/src/main.cpp (1 diff)

File differences

cpp/algorithms/algorithms.vcxproj
1010
1111
1212
13
14
15
16
17
18
19
20
21
22
1323
1424
1525
......
7383
7484
7585
76
77
78
79
80
81
8286
8387
8488
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\Algorithm.h" />
<ClInclude Include="src\InsertSort.h" />
<ClInclude Include="src\SearchAlgorithm.h" />
<ClInclude Include="src\SortAlgorithm.h" />
<ClInclude Include="src\vector_helper.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{38F1CE1E-AAA8-47A6-9C6E-3540FD29CA70}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Algorithm.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
cpp/algorithms/algorithms.vcxproj.filters
1515
1616
1717
18
18
1919
2020
2121
2222
23
23
24
25
26
27
28
29
30
31
32
33
34
35
2436
2537
2638
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<ClCompile Include="src\main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Algorithm.h">
<ClInclude Include="src\Algorithm.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\SortAlgorithm.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\SearchAlgorithm.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\InsertSort.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\vector_helper.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
cpp/algorithms/src/Algorithm.h
33
44
55
6
67
78
8
9
910
10
11
1112
1213
13
14
15
16
17
1418
15
19
20
21
22
23
24
25
26
27
28
29
30
1631
1732
#include <vector>
#include <string>
#include <sstream>
template <class T>
class DataAlgorithm
class Algorithm
{
private:
protected:
std::vector<T> _container;
public:
std::string toString();
void initContainer(std::vector<T> arr)
{
this->_container = arr;
}
}
std::string ToString()
{
std::stringstream ss;
ss << "[ ";
for(size_t i = 0; i < this->_container.size(); i++)
{
ss << this->_container.at(i) << " ";
}
ss << "] ";
return ss.str();
}
};
#endif
cpp/algorithms/src/InsertSort.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#ifndef INSERTSORT_H
#define INSERTSORT_H
#include "SortAlgorithm.h"
template <class T>
class InsertSort : public SortAlgorithm<T>
{
virtual void Sort()
{
}
};
#endif
cpp/algorithms/src/SearchAlgorithm.h
1
2
3
4
5
6
7
8
9
10
11
12
13
#ifndef SEARCHALGORITHM_H
#define SEARCHALGORITHM_H
#include "Algorithm.h"
template <class T>
class SearchAlgorithm : public Algorithm
{
public:
virtual void Search() = 0;
};
#endif
cpp/algorithms/src/SortAlgorithm.h
1
2
3
4
5
6
7
8
9
10
11
12
13
#ifndef SORTALGORITHM_H
#define SORTALGORITHM_H
#include "Algorithm.h"
template <class T>
class SortAlgorithm : public Algorithm<T>
{
public:
virtual void Sort() = 0;
};
#endif
cpp/algorithms/src/main.cpp
11
2
3
4
25
36
47
58
69
7
10
11
12
13
14
815
#include <iostream>
#include "InsertSort.h"
#include "vector_helper.h"
#include <vector>
using namespace std;
int main()
{
InsertSort<int> sort1;
//cout << sort1.ToString();
//vector<int> arr1 = create_vector<int>(
sort1.initContainer(create_vector<int>(1)(2)(3));
cout << sort1.ToString() << endl;
}
cpp/algorithms/src/vector_helper.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
#ifndef VECTOR_HELPER_H
#define VECTOR_HELPER_H
#include <string>
#include <vector>
template <typename T>
class create_vector
{
private:
std::vector<T> vect;
public:
create_vector(const T& val)
{
vect.push_back(val);
}
create_vector<T>& operator()(const T& val)
{
vect.push_back(val);
return *this;
}
operator std::vector<T>()
{
return vect;
}
};
#endif

Archive Download the corresponding diff file

Branches

Tags

Page rendered in 0.44725s using 14 queries.