Skip to content

Commit 7361819

Browse files
authored
Merge pull request #33 from kimkulling/feature/add_algo
Feature/add algo
2 parents d13d7be + 2764d84 commit 7361819

24 files changed

+605
-533
lines changed

CMakeLists.txt

+14-7
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ SET ( cppcore_container_src
110110
SOURCE_GROUP( code FILES ${cppcore_src} )
111111
SOURCE_GROUP( code\\common FILES ${cppcore_common_src} )
112112
SOURCE_GROUP( code\\container FILES ${cppcore_container_src} )
113-
SOURCE_GROUP( code\\IO FILES ${cppcore_io_src} )
113+
SOURCE_GROUP( code\\io FILES ${cppcore_io_src} )
114114
SOURCE_GROUP( code\\memory FILES ${cppcore_memory_src} )
115115
SOURCE_GROUP( code\\random FILES ${cppcore_random_src} )
116116

@@ -139,27 +139,33 @@ IF( CPPCORE_BUILD_UNITTESTS )
139139

140140
SET( cppcore_container_test_src
141141
test/container/TArrayTest.cpp
142+
test/container/TAlgorithmTest.cpp
142143
test/container/THashMapTest.cpp
143144
test/container/TListTest.cpp
144145
test/container/TQueueTest.cpp
145146
test/container/TStaticArrayTest.cpp
146147
)
147148

149+
SET( cppcore_io_test_src
150+
test/io/FileSystemTest.cpp
151+
)
152+
148153
SET( cppcore_memory_test_src
149154
test/memory/TStackAllocatorTest.cpp
150155
test/memory/TPoolAllocatorTest.cpp
151156
test/memory/TScratchAllocatorTest.cpp
152157
)
153158

154159
SET( cppcore_random_test_src
155-
test/Random/RandomGeneratorTest.cpp
160+
test/random/RandomGeneratorTest.cpp
156161
)
157162

158-
SOURCE_GROUP( code FILES ${cppcore_test_src} )
159-
SOURCE_GROUP( code\\common FILES ${cppcore_common_test_src} )
160-
SOURCE_GROUP( code\\container FILES ${cppcore_container_test_src} )
161-
SOURCE_GROUP( code\\memory FILES ${cppcore_memory_test_src} )
162-
SOURCE_GROUP( code\\random FILES ${cppcore_random_test_src} )
163+
SOURCE_GROUP(code FILES ${cppcore_test_src} )
164+
SOURCE_GROUP(code\\common FILES ${cppcore_common_test_src} )
165+
SOURCE_GROUP(code\\io FILES ${cppcore_io_test_src} )
166+
SOURCE_GROUP(code\\container FILES ${cppcore_container_test_src} )
167+
SOURCE_GROUP(code\\memory FILES ${cppcore_memory_test_src} )
168+
SOURCE_GROUP(code\\random FILES ${cppcore_random_test_src} )
163169

164170
# Prevent overriding the parent project's compiler/linker
165171
# settings on Windows
@@ -179,6 +185,7 @@ IF( CPPCORE_BUILD_UNITTESTS )
179185
ADD_EXECUTABLE( cppcore_unittest
180186
${cppcore_test_src}
181187
${cppcore_common_test_src}
188+
${cppcore_io_test_src}
182189
${cppcore_memory_test_src}
183190
${cppcore_random_test_src}
184191
${cppcore_container_test_src}

code/Random/RandomGenerator.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,15 @@ unsigned int mersenne_twister() {
9191
}
9292

9393
RandomGenerator::RandomGenerator( GeneratorType type ) noexcept :
94-
m_type( type ) {
95-
::srand(static_cast<unsigned int>(time(nullptr)));
94+
mType( type ) {
95+
::srand( static_cast<unsigned int>(time(nullptr)));
9696
}
9797

9898
int RandomGenerator::get( int lower, int upper ) {
9999
int ret( 0 );
100-
if ( GeneratorType::Standard == m_type ) {
100+
if ( GeneratorType::Standard == mType ) {
101101
ret = ::rand() % upper + lower;
102-
} else if (GeneratorType::MersenneTwister == m_type) {
102+
} else if (GeneratorType::MersenneTwister == mType) {
103103
ret = mersenne_twister() % upper + lower;
104104
}
105105

contrib/googletest-1.15.2/googletest/generated/gmock.pc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
libdir=C:/Program Files (x86)/osre/lib
2-
includedir=C:/Program Files (x86)/osre/include
1+
libdir=C:/Program Files (x86)/cppcore/lib
2+
includedir=C:/Program Files (x86)/cppcore/include
33

44
Name: gmock
55
Description: GoogleMock (without main() function)

contrib/googletest-1.15.2/googletest/generated/gmock_main.pc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
libdir=C:/Program Files (x86)/osre/lib
2-
includedir=C:/Program Files (x86)/osre/include
1+
libdir=C:/Program Files (x86)/cppcore/lib
2+
includedir=C:/Program Files (x86)/cppcore/include
33

44
Name: gmock_main
55
Description: GoogleMock (with main() function)

contrib/googletest-1.15.2/googletest/generated/gtest.pc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
libdir=C:/Program Files (x86)/osre/lib
2-
includedir=C:/Program Files (x86)/osre/include
1+
libdir=C:/Program Files (x86)/cppcore/lib
2+
includedir=C:/Program Files (x86)/cppcore/include
33

44
Name: gtest
55
Description: GoogleTest (without main() function)

contrib/googletest-1.15.2/googletest/generated/gtest_main.pc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
libdir=C:/Program Files (x86)/osre/lib
2-
includedir=C:/Program Files (x86)/osre/include
1+
libdir=C:/Program Files (x86)/cppcore/lib
2+
includedir=C:/Program Files (x86)/cppcore/include
33

44
Name: gtest_main
55
Description: GoogleTest (with main() function)

contrib/googletest-1.15.2/googletest/gtest.dir/Debug/gtest.lib.recipe

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project>
33
<ProjectOutputs>
44
<ProjectOutput>
5-
<FullPath>C:\develop\projects\osre\x64\Debug\ZERO_CHECK</FullPath>
5+
<FullPath>C:\develop\projects\cppcore\x64\Debug\ZERO_CHECK</FullPath>
66
</ProjectOutput>
77
</ProjectOutputs>
88
<ContentFiles />

contrib/googletest-1.15.2/googletest/gtest_main.dir/Debug/gtest_main.lib.recipe

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project>
33
<ProjectOutputs>
44
<ProjectOutput>
5-
<FullPath>C:\develop\projects\osre\x64\Debug\ZERO_CHECK</FullPath>
5+
<FullPath>C:\develop\projects\cppcore\x64\Debug\ZERO_CHECK</FullPath>
66
</ProjectOutput>
77
</ProjectOutputs>
88
<ContentFiles />
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*-----------------------------------------------------------------------------------------------
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2014-2025 Kim Kulling
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
this software and associated documentation files (the "Software"), to deal in
8+
the Software without restriction, including without limitation the rights to
9+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10+
the Software, and to permit persons to whom the Software is furnished to do so,
11+
subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
-----------------------------------------------------------------------------------------------*/
23+
#pragma once
24+
25+
#include <cstddef>
26+
#include <cassert>
27+
28+
namespace cppcore {
29+
30+
/// @brief Function to calulate the distance between two iterators.
31+
/// @tparam TIt The container iterator
32+
/// @param begin The first container iterator
33+
/// @param end The second container iterator
34+
/// @return The distance between the two iterators.
35+
template<class TIt>
36+
inline size_t distance(TIt begin, TIt end) {
37+
assert(begin < end);
38+
const size_t distance = end - begin;
39+
return distance;
40+
}
41+
42+
} // namespace cppcore

0 commit comments

Comments
 (0)