Skip to content

Instantly share code, notes, and snippets.

@ZacAttack
Created July 11, 2025 19:49
Show Gist options
  • Select an option

  • Save ZacAttack/c72d63f7d50ec345c435838964dfe8b2 to your computer and use it in GitHub Desktop.

Select an option

Save ZacAttack/c72d63f7d50ec345c435838964dfe8b2 to your computer and use it in GitHub Desktop.
function findThingsInAHashMap(map, things, entryComparator, keyTransformer, entryCallback) {
var results = {};
var mapAsArray = toArray(map.table)
for(i = 0; i < mapAsArray.length; i++) {
var e = mapAsArray[i];
while (e != null) {
if(e.key != null && entryComparator(e, things)) {
var tempResult = entryCallback(e.key, e.value); // NOTE some hashmap implementations use e.val vs. value, so check first!
if (tempResult != null) {
results[keyTransformer(e.key)] = tempResult;
}
}
e = e.next;
}
}
return results;
}
@ZacAttack
Copy link
Author

This bit of OQL helps you find things in a hashmap on heap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment