Exemplo n.º 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);
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
  }
Exemplo n.º 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";
}
Exemplo 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();
 }
Exemplo n.º 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;
  }
Exemplo n.º 7
0
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);
    }
}
Exemplo n.º 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
        }
    }
Exemplo n.º 9
0
 void zero(container_t & vv)
 {
   std::fill(vv.begin(), vv.end(), 0);
 }
Exemplo n.º 10
0
	const_iterator_t begin() const { return &*__container.begin(); }
Exemplo n.º 11
0
 const_iterator begin() const    { return m_contents.begin(); }