Lines Matching defs:bag
841 WordBag* bag = alloc_nofail(cc, sizeof(WordBag));
842 bag->fm = VG_(newFM)( alloc_nofail, cc, dealloc, NULL );
843 return bag;
846 void VG_(deleteBag) ( WordBag* bag )
848 void (*dealloc)(void*) = bag->fm->dealloc;
849 VG_(deleteFM)( bag->fm, NULL, NULL );
850 VG_(memset)(bag, 0, sizeof(WordBag));
851 dealloc(bag);
854 void VG_(addToBag)( WordBag* bag, UWord w )
857 if (VG_(lookupFM)(bag->fm, &key, &count, w)) {
860 VG_(addToFM)(bag->fm, w, count+1);
862 VG_(addToFM)(bag->fm, w, 1);
866 UWord VG_(elemBag) ( const WordBag* bag, UWord w )
869 if (VG_(lookupFM)( bag->fm, &key, &count, w)) {
878 UWord VG_(sizeUniqueBag) ( const WordBag* bag )
880 return VG_(sizeFM)( bag->fm );
894 UWord VG_(sizeTotalBag)( const WordBag* bag )
896 if (bag->fm->root)
897 return sizeTotalBag_wrk(bag->fm->root);
902 Bool VG_(delFromBag)( WordBag* bag, UWord w )
905 if (VG_(lookupFM)(bag->fm, &key, &count, w)) {
909 VG_(addToFM)(bag->fm, w, count-1);
912 VG_(delFromFM)( bag->fm, NULL, NULL, w );
920 Bool VG_(isEmptyBag)( const WordBag* bag )
922 return VG_(sizeFM)(bag->fm) == 0;
925 Bool VG_(isSingletonTotalBag)( const WordBag* bag )
928 if (VG_(sizeFM)(bag->fm) != 1)
930 nd = bag->fm->root;
937 UWord VG_(anyElementOfBag)( const WordBag* bag )
939 /* Return an arbitrarily chosen element in the bag. We might as
941 AvlNode* nd = bag->fm->root;
942 vg_assert(nd); /* if this fails, 'bag' is empty - caller is in error. */
947 void VG_(initIterBag)( WordBag* bag )
949 VG_(initIterFM)(bag->fm);
952 Bool VG_(nextIterBag)( WordBag* bag, /*OUT*/UWord* pVal, /*OUT*/UWord* pCount )
954 return VG_(nextIterFM)( bag->fm, pVal, pCount );
957 void VG_(doneIterBag)( WordBag* bag )
959 VG_(doneIterFM)( bag->fm );