fixed a few compile problems in SparseMat code; fixed iteration over an empty sparse matrix (ticket #1587)

This commit is contained in:
Vadim Pisarevsky
2012-03-27 14:43:24 +00:00
parent f262651465
commit af8e5696f0
3 changed files with 118 additions and 3 deletions

View File

@@ -3506,6 +3506,28 @@ SparseMat::operator CvSparseMat*() const
return m;
}
uchar* SparseMat::ptr(int i0, bool createMissing, size_t* hashval)
{
CV_Assert( hdr && hdr->dims == 1 );
size_t h = hashval ? *hashval : hash(i0);
size_t hidx = h & (hdr->hashtab.size() - 1), nidx = hdr->hashtab[hidx];
uchar* pool = &hdr->pool[0];
while( nidx != 0 )
{
Node* elem = (Node*)(pool + nidx);
if( elem->hashval == h && elem->idx[0] == i0 )
return &value<uchar>(elem);
nidx = elem->next;
}
if( createMissing )
{
int idx[] = { i0 };
return newNode( idx, h );
}
return 0;
}
uchar* SparseMat::ptr(int i0, int i1, bool createMissing, size_t* hashval)
{
CV_Assert( hdr && hdr->dims == 2 );