34 std::sort(arr, arr + sz);
52 queue.emplace_back(t);
76 auto element = queue.back();
96 void alloc(
const int size) {
104 if(arr)
delete[] arr;
123 if(other.arr == arr)
return *
this;
141 auto swap_arr_sz = arr_sz;
144 arr_sz = other.arr_sz;
146 other.arr = swap_arr;
147 other.arr_sz = swap_arr_sz;
152 alloc(other->arr_sz);
153 for(
int i = 0; i < other->arr_sz; ++i) {
154 arr[i] = other->arr[i];
156 arr_sz = other->arr_sz;
234 int max_val = arr[0];
235 for(
int i = 1; i <
cur_pos; ++i) {
236 const int val = arr[i];
237 if(val > max_val) max_val = val;
250 if (arr &&
size <= arr_sz)
return;
251 T *old_arr =
nullptr;
252 int old_arr_sz = arr_sz;
253 if (arr) old_arr = arr;
256 if (old_arr !=
nullptr) {
257 int cp_pt = std::min(old_arr_sz, arr_sz);
258 memcpy(arr, old_arr, cp_pt *
sizeof(T));
297 struct comparator_map {
300 explicit comparator_map(T *m) {
304 bool operator()(
const T &a,
const T &b) {
305 return map[a] < map[b];
308 comparator_map c = comparator_map(map);
309 std::sort(arr, arr +
cur_pos, c);
332 void alloc(
const int size) {
335 arr = (
int*) calloc(size,
sizeof(
int));
365 if(other.arr == arr)
return *
this;
377 auto swap_arr_sz = arr_sz;
379 arr_sz = other.arr_sz;
380 other.arr = swap_arr;
381 other.arr_sz = swap_arr_sz;
386 memcpy(arr, other.arr, other.arr_sz *
sizeof(
int));
387 arr_sz = other.arr_sz;
404 memset(arr, 0, arr_sz *
sizeof(
int));
415 if (arr && size <= arr_sz)
return;
418 int old_arr_sz = arr_sz;
421 int cp_pt = std::min(old_arr_sz, arr_sz);
422 memcpy(arr, old_arr, cp_pt *
sizeof(
int));
487 memset(s, -1, size *
sizeof(T));
493 void set(
int index, T value) {
510 memset(s, -1, sz *
sizeof(T));
517 if (s[index]++ == -1)
552 memset(s, mark, sz *
sizeof(
int));
570 if(other.s == s)
return *
this;
590 if(s && sz == size) {
595 s = (
int*) calloc((
unsigned int) size,
sizeof(int));
605 inline bool get(
int pos) {
608 return s[pos] == mark;
616 inline void set(
int pos) {
635 if(mark == -1) full_reset();
641 auto swap_mark = mark;
647 other.mark = swap_mark;
653 for(
int i = 0; i < other->sz; ++i) {
Set specialized for quick resets.
void swap(markset &other)
void copy(const markset *other)
markset(const markset &other)
markset & operator=(const markset &other)
void initialize(int size)
Fixed-size array, uninitialized.
void copy(const worklist_t< T > *other)
dej_nodiscard bool empty() const
void sort_after_map(T *map)
worklist_t< T > & operator=(const worklist_t< T > &other)
void swap(worklist_t< T > &other)
void set_size(const int size)
void resize(const int size)
T & operator[](int index) const
worklist_t(const worklist_t< T > &other)
dej_nodiscard int size() const
worklist_t(const worklist_t< T > &&other)
void set(int index, T value)
void initialize(int size)
Fixed-size integer array, 0-initialized.
workspace & operator=(const workspace &other)
void copy(const workspace &other)
void resize(const int size)
int & operator[](int index) const
dej_nodiscard int * get_array() const
workspace & operator=(workspace &&other)
workspace(const workspace &other)
void swap(workspace &other)
worklist_t< int > worklist
void sort_t(T *arr, int sz)
workset_t< int > work_set_int