vector instead of set in storing classes
This commit is contained in:
24
main.cpp
24
main.cpp
@@ -272,11 +272,12 @@ pair<vector<FiniteFunction<BASE>>, bool> extend_function_class(
|
|||||||
const vector<FiniteFunction<BASE>>& base_class,
|
const vector<FiniteFunction<BASE>>& base_class,
|
||||||
size_t max_size
|
size_t max_size
|
||||||
) {
|
) {
|
||||||
if ( base_class.size() >= max_size )
|
if ( base_class.size() >= max_size ) {
|
||||||
return make_pair(
|
return make_pair(
|
||||||
vector<FiniteFunction<BASE>>(base_class.begin(), base_class.end()),
|
vector<FiniteFunction<BASE>>(base_class),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
FiniteFunction<CUR_BASE> identical_x(string("000 111 222"));
|
FiniteFunction<CUR_BASE> identical_x(string("000 111 222"));
|
||||||
FiniteFunction<CUR_BASE> identical_y(string("012 012 012"));
|
FiniteFunction<CUR_BASE> identical_y(string("012 012 012"));
|
||||||
@@ -321,8 +322,10 @@ pair<vector<FiniteFunction<BASE>>, bool> extend_function_class(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
vector<FiniteFunction<BASE>> res(func_class.begin(), func_class.end());
|
||||||
|
res.shrink_to_fit();
|
||||||
return make_pair(
|
return make_pair(
|
||||||
vector<FiniteFunction<BASE>>(func_class.begin(), func_class.end()),
|
res,
|
||||||
is_finished
|
is_finished
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -343,7 +346,7 @@ bool is_bad_class(
|
|||||||
size_t total_possible_functions;
|
size_t total_possible_functions;
|
||||||
atomic<long> completed_tasks;
|
atomic<long> completed_tasks;
|
||||||
atomic<long> tasks_to_extend; // количество тасков, которые не обработаны
|
atomic<long> tasks_to_extend; // количество тасков, которые не обработаны
|
||||||
list< set<FiniteFunction<CUR_BASE>> > shared_function_classes;
|
list< vector<FiniteFunction<CUR_BASE>> > shared_function_classes;
|
||||||
mutex shared_functions_mutex;
|
mutex shared_functions_mutex;
|
||||||
|
|
||||||
|
|
||||||
@@ -481,10 +484,7 @@ void process_task_lists() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( is_need_append ) {
|
if ( is_need_append ) {
|
||||||
shared_function_classes.push_back(set<FiniteFunction<CUR_BASE>>(
|
shared_function_classes.push_back(func_class);
|
||||||
func_class.begin(),
|
|
||||||
func_class.end()
|
|
||||||
));
|
|
||||||
for (auto&& func: func_class)
|
for (auto&& func: func_class)
|
||||||
bad_functions.insert(func);
|
bad_functions.insert(func);
|
||||||
}
|
}
|
||||||
@@ -503,7 +503,9 @@ void process_task_lists() {
|
|||||||
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
cout << sizeof(FiniteFunction<CUR_BASE>) << " " << sizeof(FunctionTask) << endl;
|
cout << "sizeof FiniteFunction<" << (int)CUR_BASE << "> = "
|
||||||
|
<< sizeof(FiniteFunction<CUR_BASE>) << endl;
|
||||||
|
cout << "sizeof FunctionTask = "<< sizeof(FunctionTask) << endl;
|
||||||
auto FiniteFunctionHasher = [](const FiniteFunction<CUR_BASE> &f) -> uint32_t {
|
auto FiniteFunctionHasher = [](const FiniteFunction<CUR_BASE> &f) -> uint32_t {
|
||||||
return f.get_hash();
|
return f.get_hash();
|
||||||
};
|
};
|
||||||
@@ -552,7 +554,7 @@ int main() {
|
|||||||
vector< thread > thread_pool;
|
vector< thread > thread_pool;
|
||||||
thread task_processer(process_task_lists);
|
thread task_processer(process_task_lists);
|
||||||
|
|
||||||
for (size_t i = 0; i < THREADS_COUNT - 1; ++i)
|
for (int i = 0; i < THREADS_COUNT - 1; ++i)
|
||||||
thread_pool.push_back(thread(do_work));
|
thread_pool.push_back(thread(do_work));
|
||||||
|
|
||||||
for (auto&& t: thread_pool)
|
for (auto&& t: thread_pool)
|
||||||
@@ -562,7 +564,7 @@ int main() {
|
|||||||
|
|
||||||
cout << "Shared " << shared_function_classes.size() << " functions!" << endl;
|
cout << "Shared " << shared_function_classes.size() << " functions!" << endl;
|
||||||
// перегоняем список с классами в массив с классами
|
// перегоняем список с классами в массив с классами
|
||||||
vector< set<FiniteFunction<CUR_BASE>> > vector_classes(
|
vector< vector<FiniteFunction<CUR_BASE>> > vector_classes(
|
||||||
shared_function_classes.begin(),
|
shared_function_classes.begin(),
|
||||||
shared_function_classes.end()
|
shared_function_classes.end()
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user