1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-17 18:54:48 +00:00

hprint:: added index_pointer_int

This commit is contained in:
Zeno Rogue 2023-09-14 17:36:07 +02:00
parent 6e695b5262
commit b617bc12a7

View File

@ -46,13 +46,18 @@ EX string fts(ld x, int prec IS(6)) {
EX map<void*, int> pointer_indices; EX map<void*, int> pointer_indices;
EX string index_pointer(void *v) { EX int index_pointer_int(void *v) {
if(v == nullptr) return "0"; if(v == nullptr) return 0;
if(!pointer_indices.count(v)) { if(!pointer_indices.count(v)) {
int s = isize(pointer_indices); int s = isize(pointer_indices) + 1;
pointer_indices[v] = s; pointer_indices[v] = s;
} }
int i = pointer_indices[v]; return pointer_indices[v];
}
EX string index_pointer(void *v) {
int i = index_pointer_int(v);
if(!i) return "0";
string res; string res;
while(true) { res += ('A' + (i % 26)); i /= 26; if(!i) break; i--; } while(true) { res += ('A' + (i % 26)); i /= 26; if(!i) break; i--; }
return res; return res;