diff options
Diffstat (limited to 'ltable.c')
-rw-r--r-- | ltable.c | 28 |
1 files changed, 5 insertions, 23 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltable.c,v 1.19 1999/01/25 12:30:11 roberto Exp roberto $ | 2 | ** $Id: ltable.c,v 1.20 1999/01/25 17:41:19 roberto Exp roberto $ |
3 | ** Lua tables (hash) | 3 | ** Lua tables (hash) |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -152,28 +152,10 @@ void luaH_set (Hash *t, TObject *ref, TObject *val) { | |||
152 | } | 152 | } |
153 | 153 | ||
154 | 154 | ||
155 | static Node *hashnext (Hash *t, int i) { | 155 | int luaH_pos (Hash *t, TObject *r) { |
156 | Node *n; | 156 | Node *n = luaH_present(t, r); |
157 | int tsize = nhash(t); | 157 | luaL_arg_check(ttype(val(n)) != LUA_T_NIL, 2, "key not found"); |
158 | if (i >= tsize) | 158 | return n-(t->node); |
159 | return NULL; | ||
160 | n = node(t, i); | ||
161 | while (ttype(val(n)) == LUA_T_NIL) { | ||
162 | if (++i >= tsize) | ||
163 | return NULL; | ||
164 | n = node(t, i); | ||
165 | } | ||
166 | return n; | ||
167 | } | ||
168 | |||
169 | Node *luaH_next (Hash *t, TObject *r) { | ||
170 | if (ttype(r) == LUA_T_NIL) | ||
171 | return hashnext(t, 0); | ||
172 | else { | ||
173 | Node *n = luaH_present(t, r); | ||
174 | luaL_arg_check(ttype(val(n)) != LUA_T_NIL, 2, "key not found"); | ||
175 | return hashnext(t, (n-(t->node))+1); | ||
176 | } | ||
177 | } | 159 | } |
178 | 160 | ||
179 | 161 | ||