예제 #1
0
 void insert(const KEY &key, const VALUE &value)
 {
     erase(key);
     const pair_t p(key, value);
     auto it = std::lower_bound(m_contents.begin(), m_contents.end(), p);
     m_contents.insert(it, p);
 }
예제 #2
0
 const_iterator findKey(const KEY& key) const
 {
     // binary search for key
     const_iterator it(std::lower_bound(m_contents.begin(), m_contents.end(), key, KeyCmp()));
     if (it != m_contents.end() && CMP()(key, it->first)) // it > it-1, check ==
         it = m_contents.end();
     return it;
 }
예제 #3
0
  bool compare(container_t const & lhs, container_t const & rhs, typename container_t::value_type precision)
  {
    if (&lhs == &rhs) {
      return true;
    }
    if (lhs.size() != rhs.size()) {
      return false;
    }
    typename container_t::const_iterator il(lhs.begin());
    typename container_t::const_iterator ir(rhs.begin());
    typename container_t::const_iterator il_end(lhs.end());
    for (/**/; il != il_end; ++il, ++ir) {
      if (fabs(*il - *ir) > precision) {
	return false;
      }
    }
    return true;
  }
예제 #4
0
void write(const std::string& name, const container_t& cont)
{
	std::cout << name << ": ";

	for( container_t::const_iterator it = cont.begin(); it != cont.end(); ++it )
		std::cout << *it << " ";

	std::cout << "\n";
}
예제 #5
0
 const_iterator findValue(const VALUE& value) const
 {
     for (auto&& it = m_contents.begin(); it != m_contents.end(); ++it)
     {
         if (it->second == value)
             return it;
     }
     return m_contents.end();
 }
예제 #6
0
  inline void
  pointmesh2d<point_t>::add_row(container_t const& c)
  {
    std::size_t oldsize(_points.size());

    std::copy(c.begin(), c.end(), std::back_inserter(_points));

    _width = _points.size() - oldsize;
    ++_height;
  }
예제 #7
0
파일: main.cpp 프로젝트: adkozlov/cpp-2014
void set_add(container_t& container, typename container_t::value_type value)
{
    auto it = container.begin();
    while (it != container.end() && *it < value)
    {
        ++it;
    }

    if (*it != value)
    {
        container.insert(it, value);
    }
}
예제 #8
0
    void erase(const KEY& key)
    {
        const_iterator it = findKey(key);
        if (it != m_contents.end())
        {
            // Avoid std::vector.erase here due to bug in libstdc++ < v4.9
#if PONDER_WORKAROUND_GCC_N2350
            std::size_t pos = it - m_contents.begin();
            const std::size_t sz = m_contents.size() - 1;
            while (pos < sz)
                m_contents[pos] = m_contents[pos + 1], ++pos;
            m_contents.resize(sz);
#else
            m_contents.erase(it);
#endif
        }
    }
예제 #9
0
 void zero(container_t & vv)
 {
   std::fill(vv.begin(), vv.end(), 0);
 }
예제 #10
0
파일: solution.cpp 프로젝트: cvalka4/cupt
	const_iterator_t begin() const { return &*__container.begin(); }
예제 #11
0
 const_iterator begin() const    { return m_contents.begin(); }