Пример #1
0
void SearchFile::insertHashes( const HashSet& vHashes )
{
	Q_ASSERT( !vHashes.empty() );

	// TODO: hash collision detection
	const Hash* const * const pHashes = &vHashes[0];
	for ( quint8 i = 0, nSize = vHashes.size(); i < nSize; ++i )
	{
		if ( pHashes[i] && !manages( *pHashes[i] ) )
		{
			// Note: We cannot use the insert(CHash*) here as that takes control of the hash
			// (e.g. deletes it later)
			m_vHashes.insert( *pHashes[i] );
			( ( TreeRoot* )m_pParentItem )->registerHash( *pHashes[i], this );
		}
	}
}
Пример #2
0
void readFields
(
    const vtkMesh& vMesh,
    const typename GeoField::Mesh& mesh,
    const IOobjectList& objects,
    const HashSet<word>& selectedFields,
    PtrList<GeoField>& fields
)
{
    // Search list of objects for volScalarFields
    IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName));

    // Construct the vol scalar fields
    label nFields = fields.size();
    fields.setSize(nFields + fieldObjects.size());

    for
    (
        IOobjectList::iterator iter = fieldObjects.begin();
        iter != fieldObjects.end();
        ++iter
    )
    {
        if (selectedFields.empty() || selectedFields.found(iter()->name()))
        {
            fields.set
            (
                nFields,
                vMesh.interpolate
                (
                    GeoField
                    (
                        *iter(),
                        mesh
                    )
                )
            );
            nFields++;
        }
    }

    fields.setSize(nFields);
}
Пример #3
0
void syntaxTest_HashSet()
{
    {
        HashSet<int> s;
        s.insert(1);
        s.insert(2);
        s.insert(1);
        s.insert(3);
        s.insert(2);
        assert(s.size() == 3);
        s.erase(3);
        assert(s.size() == 2);
        s.erase(3);
        assert(s.size() == 2);
    }
    {
        int a[5] = {1, 3, 2, 4, 1};
        HashSet<int> s(a, a + 5);
        assert(s.size() == 4);
        {
            HashSet<int> s2(s);
            assert(s2.size() == 4);
        }
        {
            HashSet<int> s2;
            assert(s2.empty());
            s2 = s;
            assert(s2.size() == 4);
            assert(!s2.empty());
            assert(s2.contain(3));
            assert(s2.count(2) == 1);
            assert(s2 == s);
            assert(!(s2 != s));
        }
    }
    {
        std::vector<int> v(5, 0);
        HashSet<int> s;
        s.insert(v.begin(), v.end());
        assert(s.size() == 1);
        assert(s.find(1) == s.end());
        assert(s.find(0) != s.end());
        assert(s.find(0) == s.begin());
        s.erase(s.find(0));
        assert(s.empty());
        s.insert(5);
        assert(!s.empty());
        s.clear();
        assert(s.empty());

        HashSet<int> s2;
        s2.insert(5);
        std::swap(s, s2);
        assert(s2.empty());
        assert(s.find(5) != s.end());
    }
    {
        int a[4] = {1,2, 3, 1};
        const HashSet<int> s(a, a + 4);
        HashSet<int> b;
        for (HashSet<int>::ConstIterator iter = s.begin();
                iter != s.end();
                ++iter) {
            b.insert(*iter);
        }
        assert(b.size() == 3);
    }
}