コード例 #1
0
	void peer_class_set::remove_class(peer_class_pool& pool, peer_class_t c)
	{
		std::vector<peer_class_t>::iterator i = std::find(m_class.begin(), m_class.end(), c);
		if (i == m_class.end()) return;
		m_class.erase(i);
		pool.decref(c);
	}
コード例 #2
0
	void peer_class_set::remove_class(peer_class_pool& pool, peer_class_t c)
	{
		std::array<peer_class_t, 15>::iterator i = std::find(m_class.begin()
			, m_class.begin() + m_size, c);
		int idx = i - m_class.begin();
		if (idx == m_size) return; // not found
		if (idx < m_size - 1)
		{
			// place the last element in the slot of the erased one
			m_class[idx] = m_class[m_size - 1];
		}
		--m_size;
		pool.decref(c);
	}