コード例 #1
0
ファイル: hashset.cpp プロジェクト: rusingineer/quazaa
/**
 * @brief HashVector::conflicts Allows to check whether the specified hash conflicts with a hash
 * already present in the vector.
 * @param rHash
 * @return
 */
bool HashSet::conflicts( const Hash& rHash ) const
{
	const quint8 type = rHash.type();

	if ( m_pHashes[type] && *m_pHashes[type] != rHash )
	{
		return true;
	}

	return false;
}
コード例 #2
0
ファイル: hashset.cpp プロジェクト: rusingineer/quazaa
/**
 * @brief HashVector::remove Allows to remove the specified hash from the vector.
 * @param rHash A hash.
 * @return true if the hash was found and removed; false if it was not present in the vector.
 */
bool HashSet::remove( const Hash& rHash )
{
	const quint8 type = rHash.type();

	if ( m_pHashes[type] && *m_pHashes[type] == rHash )
	{
		delete m_pHashes[type];
		m_pHashes[type] = NULL;
		return true;
	}

	return false;
}
コード例 #3
0
ファイル: hashset.cpp プロジェクト: rusingineer/quazaa
/**
 * @brief HashVector::insert Adds a new CHash to the vector. If an equal CHash or a conflicting
 * CHash is present within the vector, no changes are made to the vector.
 * @param rHash Reference to the CHash to insert.
 * @return true if the Hash was added or an equal Hash was already present; false if a conflicting
 * Hash is present in the vector.
 */
bool HashSet::insert( const Hash& rHash )
{
	Hash::Type t = rHash.type();

	if ( !m_pHashes[t] )
	{
		m_pHashes[t] = new Hash( rHash );
		return true;
	}
	else if ( *m_pHashes[t] == rHash )
	{
		return true;
	}
	else
	{
		return false;
	}
}