Skip to content

Commit f701b3a

Browse files
authored
Merge pull request #1 from petergjoel/move_semantics
Move semantics
2 parents 2d99694 + d381232 commit f701b3a

File tree

16 files changed

+37
-27
lines changed

16 files changed

+37
-27
lines changed

CMakeLists.txt

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
66
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
77
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
88

9+
option(PTRIE_BuildTests "Build the unit tests when BUILD_TESTING is enabled." ON)
910

1011
project(ptrie VERSION 1.0.0 LANGUAGES CXX)
1112
if(NOT CMAKE_BUILD_TYPE)
@@ -18,14 +19,16 @@ set(CMAKE_CXX_STANDARD 17)
1819
#actual library
1920
add_subdirectory(src)
2021

21-
#benchmark
22-
add_subdirectory(benchmark)
22+
if(BUILD_TESTING AND PTRIE_BuildTests)
23+
#benchmark
24+
add_subdirectory(benchmark)
2325

24-
#testing
25-
add_subdirectory(test)
26-
enable_testing()
27-
add_test(NAME Wrapper COMMAND Wrapper)
28-
add_test(NAME Set COMMAND Set)
29-
add_test(NAME Delete COMMAND Delete)
30-
add_test(NAME StableSet COMMAND StableSet)
31-
add_test(NAME Map COMMAND Map)
26+
#testing
27+
add_subdirectory(test)
28+
enable_testing()
29+
add_test(NAME Wrapper COMMAND Wrapper)
30+
add_test(NAME Set COMMAND Set)
31+
add_test(NAME Delete COMMAND Delete)
32+
add_test(NAME StableSet COMMAND StableSet)
33+
add_test(NAME Map COMMAND Map)
34+
endif()

benchmark/benchmark.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
// Created by Peter G. Jensen on 12/9/16.
1818

1919
#include <iostream>
20-
#include <ptrie.h>
20+
#include <ptrie/ptrie.h>
2121
#include <stdlib.h>
2222
#include <sparsehash/sparse_hash_set>
2323
#include <sparsehash/dense_hash_set>
2424
#include <tbb/concurrent_unordered_set.h>
2525
#include <random>
26-
#include <ptrie_stable.h>
26+
#include <ptrie/ptrie_stable.h>
2727
#include <chrono>
2828
#include <unordered_set>
2929
#include "MurmurHash2.h"
@@ -261,4 +261,4 @@ int main(int argc, const char** argv)
261261
}
262262

263263
return 0;
264-
}
264+
}

benchmark/int_benchmark.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
// Created by Peter G. Jensen on 24/12/16.
1818

1919
#include <iostream>
20-
#include <ptrie.h>
20+
#include <ptrie/ptrie.h>
2121
#include <stdlib.h>
2222
#include <sparsehash/sparse_hash_set>
2323
#include <sparsehash/dense_hash_set>
2424
#include <tbb/concurrent_unordered_set.h>
2525
#include <random>
26-
#include <ptrie.h>
26+
#include <ptrie/ptrie.h>
2727
#include <chrono>
2828
#include <unordered_set>
2929
#include <vector>

src/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ set(CMAKE_CXX_STANDARD 17)
44
set(CMAKE_INCLUDE_CURRENT_DIR ON)
55

66

7-
add_library(ptrie binarywrapper.h binarywrapper.cpp ${HEADER_FILES})
7+
add_library(ptrie ptrie/binarywrapper.h ptrie/binarywrapper.cpp ${HEADER_FILES})
88
target_include_directories (ptrie PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
99

1010
install(TARGETS ptrie
1111
LIBRARY DESTINATION lib
1212
ARCHIVE DESTINATION lib)
13-
install (FILES binarywrapper.h linked_bucket.h ptrie.h ptrie_map.h ptrie_stable.h DESTINATION include/ptrie)
13+
install (FILES ptrie/binarywrapper.h ptrie/linked_bucket.h ptrie/ptrie.h ptrie/ptrie_map.h ptrie/ptrie_stable.h DESTINATION include/ptrie)
1414

src/ptrie.h renamed to src/ptrie/ptrie.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,16 @@ namespace ptrie {
176176
returntype_t exists(const uchar* data, size_t length);
177177
bool erase (binarywrapper_t wrapper);
178178
bool erase (const uchar* data, size_t length);
179-
179+
set(set&&) = default;
180+
set& operator=(set&&) = default;
180181

181182
};
182183

183184
template<PTRIETPL>
184185
set<HEAPBOUND, SPLITBOUND, ALLOCSIZE, T, I>::~set() {
185186
std::stack<fwdnode_t*> stack;
186-
stack.push(_root.get());
187+
if(_root != nullptr)
188+
stack.push(_root.get());
187189
while(!stack.empty())
188190
{
189191
fwdnode_t* next = stack.top();

src/ptrie_map.h renamed to src/ptrie/ptrie_map.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ namespace ptrie {
4343
#endif
4444
public:
4545
using pt::set_stable;
46+
map(map&&) = default;
47+
map& operator=(map&&) = default;
4648
T& get_data(I index);
4749

4850
};
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ namespace ptrie {
4848
{
4949
this->_entries = std::make_unique<linked_bucket_t<typename pt::entry_t, ALLOCSIZE>>(1);
5050
}
51-
51+
52+
set_stable(set_stable&&) = default;
53+
set_stable& operator=(set_stable&&) = default;
54+
5255
size_t size() const {
5356
return this->_entries->size();
5457
}

0 commit comments

Comments
 (0)