示例#1
0
typename TContainer::iterator erase_if_impl(TContainer& cont, TPred pred, associative_tag)
{
  auto ret = cont.end();
  for (auto it = begin(cont); it != end(cont); /* */) {
    if (pred(*it)) {
      ret = cont.erase(it++);
    } else {
      ++it;
    }
  }
  return ret;
}
示例#2
0
文件: main.cpp 项目: CCJY/coliru
void uniform_random(TContainer& container, 
const typename TContainer::value_type min, 
const typename TContainer::value_type max) {
    using uniform_distribution = typename uniform_distribution_helper<typename TContainer::value_type>::type;
    std::cout << typeid(uniform_distribution).name() << '\n';
    std::random_device rd;
    std::mt19937 gen(rd());

    // Below line does not work with integers container
    uniform_distribution distribution(min, max);

    auto lambda_norm_dist = [&](){ return distribution(gen); };
    std::generate(container.begin(), container.end(), lambda_norm_dist);
}
示例#3
0
inline
std::vector<std::shared_ptr<TContainer> >
split(TContainer & container, std::size_t const PARTS)
{
  std::vector<std::shared_ptr<TContainer> > split_container;
  split_container.resize(PARTS);
  std::size_t const container_original_size = container.size();

  for (long i = static_cast<long>(PARTS) - 1; i >= 0; --i)
  {
    std::size_t const part_size = container_original_size / PARTS +
                                  (container_original_size % PARTS > static_cast<std::size_t>(i));
    split_container[i] =
      std::make_shared<TContainer>(std::make_move_iterator(std::next(container.end(), -part_size)),
                                   std::make_move_iterator(container.end())
                                   );

    // Make sure the container is smaller now
    if (container.size() > i * (container_original_size / PARTS + 1))
      container.resize(i * (container_original_size / PARTS + 1));
  }

  return split_container;
}
示例#4
0
typename TContainer::value_type JoinStrings(TContainer const & container,
                                            TDelimiter const & delimiter)
{
  return JoinStrings(container.begin(), container.end(), delimiter);
}
示例#5
0
文件: yal.hpp 项目: nikitoz/cpp_linq
	rrange_insert(TContainer& container, TIt it)
		: container_(container) , it_(it), previous_(container.end())
	{ }
示例#6
0
	void sort(TContainer & source, const TCmp & cmp)
	{
		std::sort(source.begin(), source.end(), cmp);
	}
示例#7
0
文件: spells.hpp 项目: 0xmono/openmw
 bool hasSpell(const std::string& spell) { return mSpells.find(Misc::StringUtils::lowerCase(spell)) != mSpells.end(); }