int doTests(struct dm_disk_if *d, int argc, char **argv) { addBucket("ltop()"); addBucket("ptol()"); return layout_test_simple(d); }
/* initialize symbol table */ void symSetTable(SymbolTable *st) { /* start with one clean bucket */ st->hdr.next = st; st->hdr.prev = st; addBucket(st); }
/* reset symbol table */ void symClearTable(SymbolTable *st) { /* unchain all buckets and free storage */ while (st->hdr.next != st) remBucket(st->hdr.next); /* start with one clean bucket */ addBucket(st); }
void World::addToBuckets(Rect* r) { assert(use_partitioning); for (int i = r->x/bucket_width;i<=(r->x+r->w)/bucket_width;i++) for (int j = r->y/bucket_height;j<=(r->y+r->h)/bucket_height;j++) { bucket* b = addBucket(i,j); if (b) b->rect_v.push_front(r); } }
/* Convert string to symbol. A copy of the name string is made on the heap for use by the symbol. */ Symbol symIntern(SymbolTable *st, const char *name) { SymUnion *bckt; SymUnion *scoop = NULL; char *copy; int i; /* pick up existing symbol */ bckt = st->hdr.next; while (bckt != st) { i = 1; while (i < BSIZE) { scoop = bckt + i; if (scoop->entry.refs) { if (strcmp(name, scoop->entry.stat.used.name) == 0) { scoop->entry.refs++; return scoop; } i++; } else i += scoop->entry.stat.free.count; } bckt = bckt->hdr.next; } /* pick up free entry */ bckt = st->hdr.next; while (bckt != st) { if ((scoop = bckt->hdr.free)) { if (scoop->entry.stat.free.count > 1) scoop += --scoop->entry.stat.free.count; else bckt->hdr.free = scoop->entry.stat.free.ptr; break; } bckt = bckt->hdr.next; } /* no free entry - allocate new bucket */ if (scoop == NULL) { addBucket(st); scoop = st->hdr.next + 1; scoop += --scoop->entry.stat.free.count; } /* initialize symbol */ scoop->entry.refs = 1; copy = (char *) alloc(strlen(name) + 1); strcpy(copy, name); scoop->entry.stat.used.name = copy; scoop->entry.stat.used.value = NULL; return scoop; }
void SortedDeque<T, TSize>::insert(T value) { bool added = false; if (deque.empty()) { addBucket(); } for (unsigned i = 0; i < deque.size(); i++) { for (unsigned k = 0; k < deque.at(i).size(); k++) { if (value == deque.at(i).at(k).first) { deque.at(i).at(k).second++; added = true; break; } else if (value < deque.at(i).at(k).first) { deque.at(i).insert(deque.at(i).begin() + k, std::make_pair(value, 1)); added = true; break; } } if (!added) { deque.at(i).push_back(std::make_pair(value, 1)); sort(deque.at(i).begin(), deque.at(i).end()); break; } } if (size_unique() > capacity()) { addBucket(); } }