*** empty log message ***

This commit is contained in:
hyung-hwan 2005-05-10 06:08:57 +00:00
parent 4b35c301d1
commit 2e19ebfe01
4 changed files with 17 additions and 13 deletions

View File

@ -1,16 +1,18 @@
/*
* $Id: hash.c,v 1.3 2005-05-10 06:02:19 bacon Exp $
* $Id: hash.c,v 1.4 2005-05-10 06:08:57 bacon Exp $
*/
#include <xp/stx/hash.h>
#include <xp/stx/object.h>
#include <xp/bas/assert.h>
xp_stx_word_t xp_stx_new_link (
xp_stx_t* stx, xp_stx_word_t key, xp_stx_word_t value)
{
xp_stx_word_t x;
x = xp_stx_alloc_object (3);
XP_STX_CLASS(stx,x) = hash_lookup(stx, XP_STX_TEXT("Link"));
x = xp_stx_alloc_object (stx, 3);
XP_STX_CLASS(stx,x) = stx->link_class;
XP_STX_AT(stx,x,0) = key;
XP_STX_AT(stx,x,1) = value;
/* XP_STX_AT(stx,x,2) = stx->nil; */
@ -23,12 +25,12 @@ xp_stx_word_t xp_stx_hash_lookup (
xp_stx_t* stx, xp_stx_word_t table,
xp_stx_word_t hash, xp_stx_word_t key)
{
xp_stx_word_t harr, link, next;
xp_stx_word_t harr, link;
xp_assert (XP_STX_TYPE(stx,table) == XP_STX_INDEXED);
harr = XP_STX_AT(stx,table,0);
hash = link % XP_STX_SIZE(stx,table);
hash = hash % XP_STX_SIZE(stx,table);
link = XP_STX_AT(stx,harr,hash);
while (link != stx->nil) {
@ -48,12 +50,11 @@ void xp_stx_hash_insert (
xp_assert (XP_STX_TYPE(stx,table) == XP_STX_INDEXED);
harr = XP_STX_AT(stx,table,0);
hash = link % XP_STX_SIZE(stx,table);
hash = hash % XP_STX_SIZE(stx,table);
link = XP_STX_AT(stx,harr,hash);
if (link == stx->nil) {
new = xp_stx_new_link (stx, key, value);
XP_STX_AT(stx,harr,hash) = new;
XP_STX_AT(stx,harr,hash) = xp_stx_new_link (stx, key, value);
}
else {
for (;;) {
@ -64,8 +65,7 @@ void xp_stx_hash_insert (
next = XP_STX_AT(stx,link,2);
if (next == stx->nil) {
new = xp_stx_new_link (stx, key, value);
XP_STX_AT(stx,link,2) = new;
XP_STX_AT(stx,link,2) = xp_stx_new_link (stx, key, value);
break;
}

View File

@ -1,4 +1,4 @@
SRCS = stx.c memory.c object.c
SRCS = stx.c memory.c object.c hash.c
OBJS = $(SRCS:.c=.o)
OUT = libxpstx.a

View File

@ -1,5 +1,5 @@
/*
* $Id: stx.c,v 1.5 2005-05-08 15:22:45 bacon Exp $
* $Id: stx.c,v 1.6 2005-05-10 06:08:57 bacon Exp $
*/
#include <xp/stx/stx.h>
@ -26,6 +26,9 @@ xp_stx_t* xp_stx_open (xp_stx_t* stx, xp_stx_word_t capacity)
stx->true = XP_STX_TRUE;
stx->false = XP_STX_FALSE;
stx->link_class = XP_STX_NIL;
stx->symbol_table = XP_STX_NIL;
return stx;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: stx.h,v 1.6 2005-05-10 06:02:19 bacon Exp $
* $Id: stx.h,v 1.7 2005-05-10 06:08:57 bacon Exp $
*/
#ifndef _XP_STX_STX_H_
@ -69,6 +69,7 @@ struct xp_stx_t
xp_stx_word_t nil;
xp_stx_word_t true;
xp_stx_word_t false;
xp_stx_word_t link_class;
xp_stx_word_t symbol_table;
xp_bool_t __malloced;