From 3a56da3c09845676534f460f75c8adb6c65fbb79 Mon Sep 17 00:00:00 2001 From: gumi Date: Mon, 26 Mar 2018 17:11:34 -0400 Subject: add missing hashtable iterator buildins --- src/emap/script_buildins.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/emap/script_buildins.c') diff --git a/src/emap/script_buildins.c b/src/emap/script_buildins.c index 703307a..78fb940 100644 --- a/src/emap/script_buildins.c +++ b/src/emap/script_buildins.c @@ -1991,6 +1991,32 @@ BUILDIN(htIterator) return false; \ } +BUILDIN(htiFirstKey) +{ + int64 id = script_getnum(st, 2); + checkHtIteratorExists(id); + + const char * key = htreg->iterator_firstkey(id); + if (key) + script_pushstrcopy(st, key); + else + script_pushstrcopy(st, ""); + return true; +} + +BUILDIN(htiLastKey) +{ + int64 id = script_getnum(st, 2); + checkHtIteratorExists(id); + + const char * key = htreg->iterator_lastkey(id); + if (key) + script_pushstrcopy(st, key); + else + script_pushstrcopy(st, ""); + return true; +} + BUILDIN(htiNextKey) { int64 id = script_getnum(st, 2); @@ -2004,6 +2030,19 @@ BUILDIN(htiNextKey) return true; } +BUILDIN(htiPrevKey) +{ + int64 id = script_getnum(st, 2); + checkHtIteratorExists(id); + + const char * key = htreg->iterator_prevkey(id); + if (key) + script_pushstrcopy(st, key); + else + script_pushstrcopy(st, ""); + return true; +} + BUILDIN(htiCheck) { int64 id = script_getnum(st, 2); -- cgit v1.2.3-60-g2f50