Return TypeFunction nameArguments
hzEcodehzArray::Add(const OBJ&,)

Declared and defined in file: hzTmplArray.h

Function Logic:

0:START 1:!mx 2:mx 3:hzArray::_array_ca::Lock 4:!mx->m_pRoot 5:mx pDN pDN mx mx mx hzArray::_array_ca::Unlock 6:Return E_OK 7:mx->m_nCount 8:pDN pDN items hzArray::_array_ca::Unlock 9:Return E_OK 10:mx->m_nCount==(mx->m_nFactor*HZ_ARRAY_NODESIZE) 11:items pIdx pIdx mx items mx 12:pIdx mx x 13:f>=(HZ_ARRAY_NODESIZE*HZ_ARRAY_NODESIZE); 14:n x f 15:!pIdx->m_Ptrs[n] 16:items pIdx 17:pIdx 18:dnAddr 19:!pIdx->m_Ptrs[dnAddr] 20:items pIdx 21:pDN nSlot pDN items hzArray::_array_ca::Unlock 22:Return E_OK

Function body:

hzEcode hzArray::Add (const OBJ& obj)
   {
       _hzfunc("hzArray::Add") ;
       _hz_ar_data*    pDN ;
       _hz_ar_indx*    pIdx ;
       uint32_t    x ;
       uint32_t    n ;
       uint32_t    f ;
       uint32_t    dnAddr ;
       uint32_t    nSlot ;
       if (!mx)
           mx = new _array_ca() ;
       mx->Lock() ;
       if (!mx->m_pRoot)
       {
           mx->m_nNoDN = 1;
           pDN = new _hz_ar_data() ;
           pDN->m_Objs[0]= obj ;
           mx->m_pRoot = pDN ;
           mx->m_nLevel = 1;
           mx->m_nCount = 1;
           mx->Unlock() ;
           return E_OK ;
       }
       if (mx->m_nCount < HZ_ARRAY_NODESIZE)
       {
           pDN = (_hz_ar_data*) mx->m_pRoot ;
           pDN->m_Objs[mx->m_nCount] = obj ;
           mx->m_nCount++ ;
           mx->Unlock() ;
           return E_OK ;
       }
       if (mx->m_nCount == (mx->m_nFactor * HZ_ARRAY_NODESIZE))
       {
           mx->m_nNoIN++ ;
           pIdx = new _hz_ar_indx() ;
           pIdx->m_Ptrs[0]= mx->m_pRoot ;
           mx->m_pRoot = pIdx ;
           mx->m_nLevel++ ;
           mx->m_nFactor *= HZ_ARRAY_NODESIZE ;
       }
       pIdx = (_hz_ar_indx*) mx->m_pRoot ;
       for (x = mx->m_nCount, f = mx->m_nFactor ; f >&eq; (HZ_ARRAY_NODESIZE * HZ_ARRAY_NODESIZE) ;)
       {
           n = x/f ; x %= f ; f /= HZ_ARRAY_NODESIZE ;
           if (!pIdx->m_Ptrs[n])
               { mx->m_nNoIN++ ; pIdx->m_Ptrs[n] = new _hz_ar_indx() ; }
           pIdx = (_hz_ar_indx*) pIdx->m_Ptrs[n] ;
       }
       dnAddr = x/f ;
       if (!pIdx->m_Ptrs[dnAddr])
           { mx->m_nNoDN++ ; pIdx->m_Ptrs[dnAddr] = new _hz_ar_data() ; }
       pDN = (_hz_ar_data*) pIdx->m_Ptrs[dnAddr] ;
       nSlot = x%f ;
       pDN->m_Objs[nSlot] = obj ;
       mx->m_nCount++ ;
       mx->Unlock() ;
       return E_OK ;
   }