MCPcopy Create free account
hub / github.com/boostorg/compute / find_end

Function find_end

include/boost/compute/algorithm/find_end.hpp:99–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97///
98template<class TextIterator, class PatternIterator>
99inline TextIterator find_end(TextIterator t_first,
100 TextIterator t_last,
101 PatternIterator p_first,
102 PatternIterator p_last,
103 command_queue &queue = system::default_queue())
104{
105 BOOST_STATIC_ASSERT(is_device_iterator<TextIterator>::value);
106 BOOST_STATIC_ASSERT(is_device_iterator<PatternIterator>::value);
107
108 const context &context = queue.get_context();
109
110 // there is no need to check if pattern starts at last n - 1 indices
111 vector<uint_> matching_indices(
112 detail::iterator_range_size(t_first, t_last)
113 + 1 - detail::iterator_range_size(p_first, p_last),
114 context
115 );
116
117 detail::search_kernel<PatternIterator,
118 TextIterator,
119 vector<uint_>::iterator> kernel;
120
121 kernel.set_range(p_first, p_last, t_first, t_last, matching_indices.begin());
122 kernel.exec(queue);
123
124 using boost::compute::_1;
125
126 vector<uint_>::iterator index =
127 detail::find_end_helper(
128 matching_indices.begin(),
129 matching_indices.end(),
130 _1 == 1,
131 queue
132 );
133
134 // pattern was not found
135 if(index == matching_indices.end())
136 return t_last;
137
138 return t_first + detail::iterator_range_size(matching_indices.begin(), index);
139}
140
141} //end compute namespace
142} //end boost namespace

Callers 3

BOOST_AUTO_TEST_CASEFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 7

iterator_range_sizeFunction · 0.85
find_end_helperFunction · 0.85
get_contextMethod · 0.45
set_rangeMethod · 0.45
beginMethod · 0.45
execMethod · 0.45
endMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.68