Added the thrust like for_each_n API's