File tree Expand file tree Collapse file tree
tasks/bruskova_v_char_frequency/seq/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- #include " .. /include/ops_seq.hpp"
1+ #include " bruskova_v_char_frequency/seq /include/ops_seq.hpp"
22
3- namespace bruskova_v_char_frequency {
3+ #include < algorithm>
4+ #include < string>
5+ #include < vector>
46
5- BruskovaVCharFrequencySEQ::BruskovaVCharFrequencySEQ (const InType &in) : BaseTask() {
6- this ->GetInput () = in;
7- }
7+ namespace bruskova_v_char_frequency {
88
99bool BruskovaVCharFrequencySEQ::ValidationImpl () {
10- return true ;
10+ return taskData-> inputs_count [ 0 ] > 0 && taskData-> outputs_count [ 0 ] == 1 ;
1111}
1212
1313bool BruskovaVCharFrequencySEQ::PreProcessingImpl () {
14- const auto &in = this -> GetInput ( );
15- input_str_ = in. first ;
16- target_char_ = in. second ;
14+ auto *input_ptr = reinterpret_cast < char *>(taskData-> inputs [ 0 ] );
15+ input_str_ = std::string (input_ptr, taskData-> inputs_count [ 0 ]) ;
16+ target_char_ = * reinterpret_cast < char *>(taskData-> inputs [ 1 ]) ;
1717 return true ;
1818}
1919
2020bool BruskovaVCharFrequencySEQ::RunImpl () {
21- result_count_ = 0 ;
22- for (char c : input_str_) {
23- if (c == target_char_) {
24- result_count_++;
25- }
26- }
21+ result_count_ = static_cast <int >(std::count (input_str_.begin (), input_str_.end (), target_char_));
2722 return true ;
2823}
2924
3025bool BruskovaVCharFrequencySEQ::PostProcessingImpl () {
31- this -> GetOutput () = result_count_;
26+ reinterpret_cast < int *>(taskData-> outputs [ 0 ])[ 0 ] = result_count_;
3227 return true ;
3328}
3429
You can’t perform that action at this time.
0 commit comments