void BBSortEx_flush(BBSortEx *self) { u32_t cache_count = self->cache_max - self->cache_tick; VArray *elems; BBSortExRun *run; u32_t i; if (!cache_count) return; else elems = VA_new(cache_count); /* Sort, then create a new run. */ BBSortEx_Sort_Cache(self); for (i = self->cache_tick; i < self->cache_max; i++) { VA_Push(elems, self->cache[i]); } run = BBSortExRun_new(elems); DECREF(elems); BBSortEx_Add_Run(self, (SortExRun*)run); DECREF(run); /* Blank the cache vars. */ self->cache_tick += cache_count; SortEx_Clear_Cache(self); }
void BBSortEx_flush(BBSortEx *self) { uint32_t cache_count = self->cache_max - self->cache_tick; Obj **cache = (Obj**)self->cache; VArray *elems; if (!cache_count) { return; } else { elems = VA_new(cache_count); } // Sort, then create a new run. BBSortEx_Sort_Cache(self); for (uint32_t i = self->cache_tick; i < self->cache_max; i++) { VA_Push(elems, cache[i]); } BBSortEx *run = BBSortEx_new(0, elems); DECREF(elems); BBSortEx_Add_Run(self, (SortExternal*)run); // Blank the cache vars. self->cache_tick += cache_count; BBSortEx_Clear_Cache(self); }
void BBSortEx_Flush_IMP(BBSortEx *self) { BBSortExIVARS *const ivars = BBSortEx_IVARS(self); uint32_t buf_count = ivars->buf_max - ivars->buf_tick; Obj **buffer = ivars->buffer; VArray *elems; if (!buf_count) { return; } else { elems = VA_new(buf_count); } // Sort, then create a new run. BBSortEx_Sort_Buffer(self); for (uint32_t i = ivars->buf_tick; i < ivars->buf_max; i++) { VA_Push(elems, buffer[i]); } BBSortEx *run = BBSortEx_new(0, elems); DECREF(elems); BBSortEx_Add_Run(self, (SortExternal*)run); // Blank the buffer vars. ivars->buf_tick += buf_count; BBSortEx_Clear_Buffer(self); }