MCPcopy Create free account
hub / github.com/creatale/node-dv / icvDeleteNode

Function icvDeleteNode

deps/opencv/modules/core/src/array.cpp:738–786  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

736
737
738static void
739icvDeleteNode( CvSparseMat* mat, const int* idx, unsigned* precalc_hashval )
740{
741 int i, tabidx;
742 unsigned hashval = 0;
743 CvSparseNode *node, *prev = 0;
744 assert( CV_IS_SPARSE_MAT( mat ));
745
746 if( !precalc_hashval )
747 {
748 for( i = 0; i < mat->dims; i++ )
749 {
750 int t = idx[i];
751 if( (unsigned)t >= (unsigned)mat->size[i] )
752 CV_Error( CV_StsOutOfRange, "One of indices is out of range" );
753 hashval = hashval*ICV_SPARSE_MAT_HASH_MULTIPLIER + t;
754 }
755 }
756 else
757 {
758 hashval = *precalc_hashval;
759 }
760
761 tabidx = hashval & (mat->hashsize - 1);
762 hashval &= INT_MAX;
763
764 for( node = (CvSparseNode*)mat->hashtable[tabidx];
765 node != 0; prev = node, node = node->next )
766 {
767 if( node->hashval == hashval )
768 {
769 int* nodeidx = CV_NODE_IDX(mat,node);
770 for( i = 0; i < mat->dims; i++ )
771 if( idx[i] != nodeidx[i] )
772 break;
773 if( i == mat->dims )
774 break;
775 }
776 }
777
778 if( node )
779 {
780 if( prev )
781 prev->next = node->next;
782 else
783 mat->hashtable[tabidx] = node->next;
784 cvSetRemoveByPtr( mat->heap, node );
785 }
786}
787
788
789/****************************************************************************************\

Callers 1

cvClearNDFunction · 0.85

Calls 1

cvSetRemoveByPtrFunction · 0.85

Tested by

no test coverage detected