示例#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
std::string class_name(peer_class_t id, peer_class_pool const& p)
{
	peer_class const* c = p.at(id);
	TEST_CHECK(c != NULL);
	if (c == NULL) return "";
	peer_class_info i;
	c->get_info(&i);
	return i.label;
}
示例#3
0
	void peer_class_set::add_class(peer_class_pool& pool, peer_class_t c)
	{
		if (std::find(m_class.begin(), m_class.begin() + m_size, c)
			!= m_class.begin() + m_size) return;
		if (m_size >= m_class.size() - 1)
		{
			TORRENT_ASSERT_FAIL();
			return;
		}
		m_class[m_size] = c;
		pool.incref(c);
		++m_size;
	}
示例#4
0
	void peer_class_set::add_class(peer_class_pool& pool, peer_class_t c)
	{
		if (std::find(m_class.begin(), m_class.begin() + m_size, c)
			!= m_class.begin() + m_size) return;
		if (m_size >= m_class.size() - 1)
		{
			assert(false);
			return;
		}
		m_class[m_size] = c;
		pool.incref(c);
		++m_size;
	}
示例#5
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);
	}
示例#6
0
	void peer_class_set::add_class(peer_class_pool& pool, peer_class_t c)
	{
		if (std::find(m_class.begin(), m_class.end(), c) != m_class.end()) return;
		m_class.push_back(c);
		pool.incref(c);
	}