diff options
| author | xolatile | 2025-08-17 18:28:28 +0200 |
|---|---|---|
| committer | xolatile | 2025-08-17 18:28:28 +0200 |
| commit | bffe8d11bd1dfec49280fb64a17f0ae529ac3f5d (patch) | |
| tree | 9f4f7b6f5003585e5a170bd55ccaa335b8f26f90 /src/shared/tools.h | |
| parent | bec4167d29a68efd0cd2da36143e7f1c78a119a0 (diff) | |
| download | xolatile-badassbug-master.tar.xz xolatile-badassbug-master.tar.zst | |
Diffstat (limited to 'src/shared/tools.h')
| -rw-r--r-- | src/shared/tools.h | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/src/shared/tools.h b/src/shared/tools.h index 44be57d..94bf23a 100644 --- a/src/shared/tools.h +++ b/src/shared/tools.h @@ -782,35 +782,6 @@ template<class K, class T> struct hashtable : hashbase<hashtable<K, T>, hashtabl #define enumeratekt(ht,k,e,t,f,b) loopi((ht).size) for(void *ec = (ht).chains[i]; ec;) { k &e = (ht).enumkey(ec); t &f = (ht).enumdata(ec); ec = (ht).enumnext(ec); b; } #define enumerate(ht,t,e,b) loopi((ht).size) for(void *ec = (ht).chains[i]; ec;) { t &e = (ht).enumdata(ec); ec = (ht).enumnext(ec); b; } -struct unionfind { - struct ufval { - int rank, next; - ufval() : rank(0), next(-1) {} - }; - vector<ufval> ufvals; - int find(int k) { - if(k>=ufvals.length()) return k; - while(ufvals[k].next>=0) k = ufvals[k].next; - return k; - } - int compressfind(int k) { - if(ufvals[k].next<0) return k; - return ufvals[k].next = compressfind(ufvals[k].next); - } - void unite (int x, int y) { - while(ufvals.length() <= max(x, y)) ufvals.add(); - x = compressfind(x); - y = compressfind(y); - if(x==y) return; - ufval &xval = ufvals[x], &yval = ufvals[y]; - if(xval.rank < yval.rank) xval.next = y; - else { - yval.next = x; - if(xval.rank==yval.rank) yval.rank++; - } - } -}; - template <class T, int SIZE> struct queue { int head, tail, len; T data[SIZE]; |
