• Home
  • Raw
  • Download

Lines Matching refs:fm

80 void addToFM ( WordFM* fm, Word k, Word v );
83 Bool delFromFM ( WordFM* fm, /*OUT*/Word* oldV, Word key );
86 Bool lookupFM ( WordFM* fm, /*OUT*/Word* valP, Word key );
88 Word sizeFM ( WordFM* fm );
91 void initIterFM ( WordFM* fm );
95 Bool nextIterFM ( WordFM* fm, /*OUT*/Word* pKey, /*OUT*/Word* pVal );
98 void doneIterFM ( WordFM* fm );
106 WordFM* dopyFM ( WordFM* fm, Word(*dopyK)(Word), Word(*dopyV)(Word) );
1304 static void stackClear(WordFM* fm) in stackClear() argument
1307 assert(fm); in stackClear()
1309 fm->nodeStack[i] = NULL; in stackClear()
1310 fm->numStack[i] = 0; in stackClear()
1312 fm->stackTop = 0; in stackClear()
1316 static inline void stackPush(WordFM* fm, AvlNode* n, Int i) in stackPush() argument
1318 assert(fm->stackTop < WFM_STKMAX); in stackPush()
1320 fm->nodeStack[fm->stackTop] = n; in stackPush()
1321 fm-> numStack[fm->stackTop] = i; in stackPush()
1322 fm->stackTop++; in stackPush()
1326 static inline Bool stackPop(WordFM* fm, AvlNode** n, Int* i) in stackPop() argument
1328 assert(fm->stackTop <= WFM_STKMAX); in stackPop()
1330 if (fm->stackTop > 0) { in stackPop()
1331 fm->stackTop--; in stackPop()
1332 *n = fm->nodeStack[fm->stackTop]; in stackPop()
1333 *i = fm-> numStack[fm->stackTop]; in stackPop()
1335 fm->nodeStack[fm->stackTop] = NULL; in stackPop()
1336 fm-> numStack[fm->stackTop] = 0; in stackPop()
1397 void initFM ( WordFM* fm, in initFM() argument
1402 fm->root = 0; in initFM()
1403 fm->kCmp = kCmp; in initFM()
1404 fm->alloc_nofail = alloc_nofail; in initFM()
1405 fm->dealloc = dealloc; in initFM()
1406 fm->stackTop = 0; in initFM()
1414 WordFM* fm = alloc_nofail(sizeof(WordFM)); in newFM() local
1415 assert(fm); in newFM()
1416 initFM(fm, alloc_nofail, dealloc, kCmp); in newFM()
1417 return fm; in newFM()
1441 void deleteFM ( WordFM* fm, void(*kFin)(Word), void(*vFin)(Word) ) in deleteFM() argument
1443 void(*dealloc)(void*) = fm->dealloc; in deleteFM()
1444 avl_free( fm->root, kFin, vFin, dealloc ); in deleteFM()
1445 memset(fm, 0, sizeof(WordFM) ); in deleteFM()
1446 dealloc(fm); in deleteFM()
1450 void addToFM ( WordFM* fm, Word k, Word v ) in addToFM() argument
1454 node = fm->alloc_nofail( sizeof(struct _AvlNode) ); in addToFM()
1459 avl_insert_wrk( &fm->root, &oldV, node, fm->kCmp ); in addToFM()
1467 Bool delFromFM ( WordFM* fm, /*OUT*/Word* oldV, Word key ) in delFromFM() argument
1469 AvlNode* node = avl_find_node( fm->root, key, fm->kCmp ); in delFromFM()
1471 avl_remove_wrk( &fm->root, node, fm->kCmp ); in delFromFM()
1474 fm->dealloc(node); in delFromFM()
1482 Bool lookupFM ( WordFM* fm, /*OUT*/Word* valP, Word key ) in lookupFM() argument
1484 AvlNode* node = avl_find_node( fm->root, key, fm->kCmp ); in lookupFM()
1494 Word sizeFM ( WordFM* fm ) in sizeFM() argument
1497 return fm->root ? size_avl_nonNull( fm->root ) : 0; in sizeFM()
1501 void initIterFM ( WordFM* fm ) in initIterFM() argument
1503 assert(fm); in initIterFM()
1504 stackClear(fm); in initIterFM()
1505 if (fm->root) in initIterFM()
1506 stackPush(fm, fm->root, 1); in initIterFM()
1511 Bool nextIterFM ( WordFM* fm, /*OUT*/Word* pKey, /*OUT*/Word* pVal ) in nextIterFM() argument
1516 assert(fm); in nextIterFM()
1522 while (stackPop(fm, &n, &i)) { in nextIterFM()
1525 stackPush(fm, n, 2); in nextIterFM()
1526 if (n->left) stackPush(fm, n->left, 1); in nextIterFM()
1529 stackPush(fm, n, 3); in nextIterFM()
1534 if (n->right) stackPush(fm, n->right, 1); in nextIterFM()
1546 void doneIterFM ( WordFM* fm ) in doneIterFM() argument
1550 WordFM* dopyFM ( WordFM* fm, Word(*dopyK)(Word), Word(*dopyV)(Word) ) in dopyFM() argument
1555 assert(fm->stackTop == 0); in dopyFM()
1557 nyu = fm->alloc_nofail( sizeof(WordFM) ); in dopyFM()
1560 *nyu = *fm; in dopyFM()
1562 fm->stackTop = 0; in dopyFM()
1563 memset(fm->nodeStack, 0, sizeof(fm->nodeStack)); in dopyFM()
1564 memset(fm->numStack, 0, sizeof(fm->numStack)); in dopyFM()
1567 nyu->root = avl_dopy( nyu->root, dopyK, dopyV, fm->alloc_nofail ); in dopyFM()