Created
July 11, 2025 19:49
-
-
Save ZacAttack/c72d63f7d50ec345c435838964dfe8b2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This bit of OQL helps you find things in a hashmap on heap