コード例 #1
0
ファイル: peer_table.cpp プロジェクト: epidemian/concu-2010
void PeerTable::add(const Peer& peer)
{
	if (containsName(peer.getName()))
		throw ModelError("A peer with the same name already exists");
	if (containsId(peer.getId()))
		throw ModelError("A peer with the same id already exists");

	_peers.push_back(peer);
}
コード例 #2
0
        ExpiryTimerImpl::Id ExpiryTimerImpl::generateId()
        {
            Id newId = m_dist(m_mt);

            std::lock_guard< std::mutex > lock{ m_mutex };

            while (newId == INVALID_ID || containsId(newId))
            {
                newId = m_dist(m_mt);
            }
            return newId;
        }
コード例 #3
0
bool MutableStylePropertySet::removePropertiesInSet(const CSSPropertyID* set, unsigned length)
{
    if (m_propertyVector.isEmpty())
        return false;

    CSSProperty* properties = m_propertyVector.data();
    unsigned oldSize = m_propertyVector.size();
    unsigned newIndex = 0;
    for (unsigned oldIndex = 0; oldIndex < oldSize; ++oldIndex) {
        const CSSProperty& property = properties[oldIndex];
        if (containsId(set, length, property.id()))
            continue;
        // Modify m_propertyVector in-place since this method is performance-sensitive.
        properties[newIndex++] = properties[oldIndex];
    }
    if (newIndex != oldSize) {
        m_propertyVector.shrink(newIndex);
        return true;
    }
    return false;
}