mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-25 17:40:36 +00:00
hprint:: added index_pointer_int
This commit is contained in:
parent
6e695b5262
commit
b617bc12a7
13
hprint.cpp
13
hprint.cpp
@ -46,13 +46,18 @@ EX string fts(ld x, int prec IS(6)) {
|
||||
|
||||
EX map<void*, int> pointer_indices;
|
||||
|
||||
EX string index_pointer(void *v) {
|
||||
if(v == nullptr) return "0";
|
||||
EX int index_pointer_int(void *v) {
|
||||
if(v == nullptr) return 0;
|
||||
if(!pointer_indices.count(v)) {
|
||||
int s = isize(pointer_indices);
|
||||
int s = isize(pointer_indices) + 1;
|
||||
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;
|
||||
while(true) { res += ('A' + (i % 26)); i /= 26; if(!i) break; i--; }
|
||||
return res;
|
||||
|
Loading…
Reference in New Issue
Block a user