Exemple #1
0
	bool insert(const K& key, const V& val) {
		if (n_elements + 1 >= next_rehash)
			rehash();

		size_t i = hash_func(key) % buckets;
		HashBucket *b = &data[i];

		while (b->size == BUCKET_SIZE) {
			rehash();

			i = hash_func(key) % buckets;
			b = &data[i];
		}

		size_t e = 0;
		for (; e < b->size; e++) {
			if (b->data[e].key == key)
				return false;
		}
		b->data[e].key = key;
		b->data[e].val = val;
		b->size++;

		n_elements++;
		return true;
	}
Exemple #2
0
void
Astar(char *start_str, int start_pos)
{
	int i, th, hvalue, curp, nxtp;
	char nxt[STR_LEN+1];
	struct EACH cur, tmp;
	strcpy(queue[0].str, start_str);
	queue[0].pos = start_pos;
	queue[0].value = hash_func(start_str);
	count = 1;
	mark[queue[0].value] = 1; /* open list */
	g[queue[0].value] = 0;
	h[queue[0].value] = estimate(start_str);
	pre[queue[0].value] = -1;
	dir[queue[0].value] = -1;
	idx[queue[0].value] = 0;
	while(count != 0) {
		cur = pop();
		if(cur.value == target) {
			output(target);
			printf("\n");
			return;
		}
		mark[cur.value] = 2; /* add to closed-list */
		curp = cur.pos;
		for(i=0; i<4; i++) {
			if(movable[curp][i]) {
				nxtp = curp + pos[i];
				strcpy(nxt, cur.str);
				nxt[curp] = nxt[nxtp];
				nxt[nxtp] = '0';
				hvalue = hash_func(nxt);
				if(mark[hvalue]==1 && g[hvalue]>(g[cur.value]+1)) { /* update */
					g[hvalue] = g[cur.value]+1;
					pre[hvalue] = cur.value;
					dir[hvalue] = i;
					up_heapify(idx[hvalue]);
				} else if(mark[hvalue]==0) { /* add to open-list */
					strcpy(tmp.str, nxt);
					tmp.pos = nxtp;
					tmp.value = hvalue;
					mark[hvalue] = 1;
					g[hvalue] = g[cur.value]+1;
					h[hvalue] = estimate(nxt);
					pre[hvalue] = cur.value;
					dir[hvalue] = i;
					idx[hvalue] = count;
					push(tmp);
				}
			}
		}
	}
	printf("unsolvable\n");
}
Exemple #3
0
void hashmap_remove(hashmap_p m, char* key){
	int n = strlen(key);
	size_t h = hash_func(key) % m->num_buckets;
	item_t *itm = m->buckets[h];
	item_t *last = NULL;
	int keyind;
	while(itm!=NULL){
		if(strcmp(key, itm->key)==0)
			break;
		last = itm;
		itm = itm->next;
	}
	
	if(itm != NULL){
		if(last==NULL)
			m->buckets[h] = NULL;
		else last->next = itm->next;
		
		free(itm->key);
		m->destructor(itm->val);
		free(itm);
		
		keyind = vector_index(m->keys, key, n);
		vector_remove(m->keys, keyind);
		m->size--;
	}
}
Exemple #4
0
void hashmap_put(hashmap_p m, char* key, void* val, size_t len){
	int keylen = strlen(key);
	size_t h = hash_func(key) % m->num_buckets;
	item_t* itm = m->buckets[h];
	item_t* last = NULL;
	
	while(itm!=NULL){
		if(strcmp(key, itm->key)==0){
		if(itm->val!=NULL) m->destructor(itm->val);
		itm->val = malloc(len);
		memcpy(itm->val, val, len);
			return;
		}
		if(itm->next==NULL) last = itm;
		itm = itm->next;
	}
	
	itm = (item_t*)malloc(sizeof(item_t));
	itm->key = malloc(keylen+1);
	memcpy(itm->key, key, keylen+1);
	itm->val = malloc(len);
	memcpy(itm->val, val, len);
	itm->next = NULL;
	if(last==NULL) m->buckets[h] = itm;
	else last->next = itm;
	vector_add(m->keys, itm->key, keylen+1);
	m->size++;
}
Exemple #5
0
/* 1. Use the target_key to find the corresponding bucket. Read it into buffer if necessary.
   2. Make use of the directory to traverse each record in the bucket. Compare each search
      key value to the value of target_key. If they are equal, copy the record to the result
	  page.
   3. If there is any overflow pages, repeat step 2 for those pages as well.
   P.S. The result page should have been initialized. */
bool search_by_key (const char *target_key, struct page *result, FILE *data_stream)
{
	unsigned int target_pid = *index (hash_func (target_key), data_stream);
	int target_fnum = find_target_frame (target_pid, data_stream);
	int start_offset, ovp_pid;
	char s_key[20];
	bool dummy, overflow = false;

	assert (result->dirctory[0] == 0 && result->dirctory[1] == 1);	// The result page should be empty.

	do
	{
		for (int i = 0; i < buffer[target_fnum].dirctory[1] -1; i++)
		{
			start_offset = buffer[target_fnum].dirctory[i + 2];
			get_search_key (s_key, buffer[target_fnum].data, start_offset);
			if (strcmp (target_key, s_key) == 0)
				insert_record (result, buffer[target_fnum].data, &start_offset, &dummy, &overflow, data_stream);

			assert (overflow == false);	// The result cannot over one page size recently.
		}

		if ((ovp_pid = buffer[target_fnum].opid) != -1)
		{
			target_pid = ovp_pid;
			target_fnum = find_target_frame (target_pid, data_stream);
		}
	} while (ovp_pid != -1);

	if (result->dirctory[1] == 1)
		return false;		// No such record.
	return true;
}
Exemple #6
0
int remove_element(hash_table_t* h_table, off_t index, off_t length) {
  hash_key_t key_hash = hash_func(index);
  unsigned int place = key_hash % (h_table -> size);
  list_element* ptr = (h_table -> table)[place];
  if(ptr == NULL) {
    return 1;
  } else {
    while(ptr) {
      if (((ptr -> data -> index) == index) && ((ptr -> data -> length) == length)) {
        if(ptr == (h_table -> table)[place]) {
          (h_table -> table)[place] = ptr -> next;
          if(ptr -> next != NULL) {
            ptr -> next -> prev = NULL;
          }
          free(ptr);
          return 0;
        } else {
          if(ptr -> next != NULL) {
            ptr -> next -> prev = ptr -> prev;
            ptr -> prev -> next = ptr -> next;
          } else {
            ptr -> prev -> next = NULL;
          }
          free(ptr);
          return 0;
        }
      }
    ptr = ptr -> next;
    }
  }
  return 1;
}
Exemple #7
0
/* double size of the hash table */
int hash_resize(hash_t *ht) {
    hash_entry_t **tmp, *he, *next;
    unsigned int i, slots, h;
    int ret;

    tmp = ht->data;
    ht->data = NULL;
    slots = ht->slots;

    if ((ret = hash_init(ht, slots * 2)) != 0) {
        return -1;
    }

    /* tmp retails the proper pointer for now */
    for (i = 0; i < slots; ++i) {
        if ((he = tmp[i])) {
            while (he) {
                next = he->next;
                h = hash_func(ht, he->key) % ht->slots; /* new hash value */
                /* insert into new hash table */
                he->next = ht->data[h];
                ht->data[h] = he;
                ht->count++;
                he = next;
            }
        }
    }

    free(tmp);
    return 0; 
}
Exemple #8
0
/* remove an entry from a hash table */
int hash_delete(hash_t *ht, const void *key) {
    unsigned int index;
    hash_entry_t *he, *prev;

    index = hash_func(ht, key) % ht->slots;

    if ((he = ht->data[index])) {
        prev = NULL;
        while (he) {
            if (HASH_CMP_KEYS(ht, key, he->key)) {
                /* remove the entry from the linked list */
                if (prev) {
                    prev->next = he->next;
                } else {
                    ht->data[index] = he->next;
                }

                HASH_FREE_KEY(ht, he);
                HASH_FREE_VAL(ht, he);
                free(he);
                --ht->count;
                return 0;
            }
            prev = he;
            he = he->next;
        }
    }
    return -1;
}
Exemple #9
0
void ldr_update_salt(struct db_main *db, struct db_salt *salt)
{
	struct db_password *current;
	int (*hash_func)(void *binary);
	int hash;

	if (salt->hash_size < 0) {
		salt->count = 0;
		if ((current = salt->list))
		do {
			current->next_hash = current->next;
			salt->count++;
		} while ((current = current->next));

		return;
	}

	memset(salt->hash, 0,
		password_hash_sizes[salt->hash_size] *
		sizeof(struct db_password *));

	hash_func = db->format->methods.binary_hash[salt->hash_size];

	salt->count = 0;
	if ((current = salt->list))
	do {
		hash = hash_func(current->binary);
		current->next_hash = salt->hash[hash];
		salt->hash[hash] = current;
		salt->count++;
	} while ((current = current->next));
}
Exemple #10
0
int hash_store(struct hash *h, int key, void *value)
{
  struct bucket *b, **p;

  p = &(h->data[hash_func(h, key)]);
  if (!*p)
    {
      b = *p = malloc(sizeof(struct bucket));
      if (!b)
	return -1;
      b->next = NULL;
      b->key = key;
      b->data = value;
      return 0;
    }

  for (b = *p; b && b->key != key; b = *p)
    p = (struct bucket **) *p;
  if (b && b->key == key)
    {
      b->data = value;
      return 1;
    }
  b = *p = malloc(sizeof(struct bucket));
  if (!b)
    return -1;
  b->next = NULL;
  b->key = key;
  b->data = value;
  return 0;
}
Exemple #11
0
static struct kmemleak_object *hash_search(unsigned long ptr) {
	struct kmemleak_object *p;
	int i,loops;

	i = hash_func(ptr);
	p = hash_table[i];
	loops=0;
	if( (p!=NULL) &&  ((p>(&objs[MAX_STATIC_OBJS+10])) || (p<(&objs[0])))) {
		memleak_serious_bug=1;
		sanity_location=985;

		err_arg1=(unsigned long)i;
		err_arg2=(unsigned long)p;
		return NULL;
	}
	while (p != NULL) {
		if(sanity_check(p,10)==0){
			return NULL;
		}
		loops++;
		if (p->pointer == ptr)
			return p;
		p = p->next;
		if (loops==MAX_STATIC_OBJS){
			memleak_serious_bug=1;
			sanity_location=100;
			return NULL;
		}
	}
	return NULL;

}
Exemple #12
0
std::vector<bool> Key::getSecondaryDeviceCode(int n)
{
  std::vector<bool> ret;
  //generating hash 
  std::stringstream ss;
  ss << n << key;
  
  BYTE *hash = hash_func((BYTE*)ss.str().c_str(), ss.str().size(), SHA);
  //BYTE *hash = aes((BYTE*)ss.str().c_str(), ss.str().size());

  //id of device:
  ret = changeIntToBinary(n);

	if (hash)
	{
    //length of message
    int len = hash_length / 8;

    //debug: showing generated key for secondary devices
		std::cout << "hash: 0x";

    //change hash into binary code
		for (int i = 0; i < len; i ++) //it should be changed due to change of encryption.
    {
			std::cout << std::hex << (int)hash[i];
      storeHexIntoKey(hash[i], ret);
    }

    std::cout << "\n";
	}

	delete [] hash;

  return ret;
}
Exemple #13
0
/*
 * Hash a term.
 */
extern hash_t hash_term(term_t t)
{
    switch (type(t))
    {
        case VAR:
            return hash_var(var(t));
        case NIL:
            return hash_nil();
        case BOOL:
            return hash_bool(boolean(t));
        case NUM:
            return hash_num(num(t));
        case ATOM:
            return hash_atom(atom(t));
        case STR:
            return hash_string(string(t));
        case FOREIGN:
            return hash_foreign(foreign(t));
        case FUNC:
            return hash_func(func(t));
        default:
        {
            hash_t dummy = HASH(0, 0);
            return dummy;
        }
    }
}
Exemple #14
0
static inline void
hashHandle(cpSpaceHash *hash, cpHandle *hand, cpBB bb)
{
	// Find the dimensions in cell coordinates.
	cpFloat dim = hash->celldim;
	int l = bb.l/dim;
	int r = bb.r/dim;
	int b = bb.b/dim;
	int t = bb.t/dim;
	
	int n = hash->numcells;
	for(int i=l; i<=r; i++){
		for(int j=b; j<=t; j++){
			int index = hash_func(i,j,n);
			cpSpaceHashBin *bin = hash->table[index];
			
			// Don't add an object twice to the same cell.
			if(containsHandle(bin, hand)) continue;

			cpHandleRetain(hand);
			// Insert a new bin for the handle in this cell.
			cpSpaceHashBin *newBin = getEmptyBin(hash);
			newBin->handle = hand;
			newBin->next = bin;
			hash->table[index] = newBin;
		}
	}
}
Exemple #15
0
int
main(int argc, char **argv)
{
	int i, j, len, sp, cnt=0;
	char input[STR_LEN*5], num[STR_LEN+1];
	fgets(input, STR_LEN*5-1, stdin);
	len = strlen(input);
	for(i=0; i<len; i++) {
		if(input[i]>='0' && input[i]<='8')
			num[cnt++] = input[i];
		else if(input[i]=='x') {
			num[cnt++] = '0';
			sp = cnt-1;
		}
	}
	num[STR_LEN] = '\0';
	for(i=0; i<STR_LEN; i++)
		for(j=0; j<STR_LEN; j++)
			distance[i][j] = dist(i, j);
	memset(pre, -1, sizeof(pre));
	memset(dir, -1, sizeof(dir));
	memset(idx, -1, sizeof(idx));
	memset(mark, 0, sizeof(mark));
	memset(g, 0, sizeof(g));
	memset(h, 0, sizeof(h));
	target = hash_func("123456780");
	Astar(num, sp);
	return 0;
}
Exemple #16
0
static uint32_t
word_hash_function(const void *key, uint32_t iv)
{
    const char *str = (const char *) key;
    const int len = strlen(str);
    return hash_func((const uint8_t *)str, len, iv);
}
struct hash_node *cache_lookup(char *file_name){

	int hash = hash_func(8192,file_name);
	struct hash_node *curr = cache[hash];
	
	if(curr->flag ==0){	
		return NULL;
	}	
	while(curr){
		if(curr->flag == 1){
			if(strcmp(curr->data->file_name,file_name)==0){
				return curr;
			}
			if(curr->next==NULL)	
				return NULL;
			curr=curr->next;
		}
		else if(curr->flag == 2){	// it has been deleted
			if(curr->next == NULL)
				return NULL;
			curr= curr->next;
		}
	}
return NULL;
}
void
cpSpaceHashRenderDebug(cpSpatialIndex *index)
{
	if(index->klass != &klass){
		cpAssertWarn(cpFalse, "Ignoring cpSpaceHashRenderDebug() call to non-spatial hash spatial index.");
		return;
	}
	
	cpSpaceHash *hash = (cpSpaceHash *)index;
	cpBB bb = cpBBNew(-320, -240, 320, 240);
	
	cpFloat dim = hash->celldim;
	int n = hash->numcells;
	
	int l = (int)floor(bb.l/dim);
	int r = (int)floor(bb.r/dim);
	int b = (int)floor(bb.b/dim);
	int t = (int)floor(bb.t/dim);
	
	for(int i=l; i<=r; i++){
		for(int j=b; j<=t; j++){
			int cell_count = 0;
			
			int index = hash_func(i,j,n);
			for(cpSpaceHashBin *bin = hash->table[index]; bin; bin = bin->next)
				cell_count++;
			
			GLfloat v = 1.0f - (GLfloat)cell_count/10.0f;
			glColor3f(v,v,v);
			glRectf(i*dim, j*dim, (i + 1)*dim, (j + 1)*dim);
		}
	}
}
Exemple #19
0
/* add an entry to the map */
static void map_add(map_t *m, const char *key, const char *val)
{
    mapnode_t *tmp;
    unsigned int idx;

    if (!m) return;

    idx = hash_func(key) % m->nbuckets;
    tmp = m->buckets + idx;
    while (tmp->next != NULL) {
        if (strcmp(tmp->key,key) == 0) break;
        tmp = tmp->next;
    }

    /* add new entry to map */
    if (tmp->next == NULL) {
        m->count ++;
        tmp->key = my_strdup(key);
        tmp->val = set_init(50); /* XXX: chosen arbitrarily */
        tmp->next = (mapnode_t *)malloc(sizeof(mapnode_t));
        tmp->next->key = NULL;
        tmp->next->val = NULL;
        tmp->next->next = NULL;
    }
    set_add(tmp->val,val);
}
Exemple #20
0
struct rain_ctx *
rain_handle_query_ctx(rain_routine_t rid,bool blog)
{
	struct rain_handle* h = H;
	if(h->rainid != RAIN_ID(rid)){
		if(blog){
			RAIN_LOG(0,"HANDLE_QUERY_FAILED:not local rid,rid:%x",rid);
		}
		return NULL;
	}
	int hash = hash_func(LOCAL_ID(rid));
	if( hash >= CTX_SET){
		if(blog){
			RAIN_LOG(0,"HANDLE_QUERY_FAILED:,invailed rid:%x",rid);
		}
		return NULL;
	}
	rain_mutex_lock(&h->mtx);
	struct rain_ctx *ctx =  h->ppctx[hash];
	if(!ctx || ctx->rid != rid){
		if(blog){
			RAIN_LOG(0,"HANDLE_QUERY_FAILED:,routine is not exist:%x",rid);
		}
		rain_mutex_unlock(&h->mtx);
		return NULL;
	}
	__sync_add_and_fetch(&ctx->ref,1);
	rain_mutex_unlock(&h->mtx);
	return ctx;
}
Exemple #21
0
int
rain_handle_kill(rain_routine_t rid,int code)
{
	struct rain_handle* h = H;
	int hash = hash_func(LOCAL_ID(rid));
	if( hash >= CTX_SET){
		return RAIN_ERROR;
	}
	rain_mutex_lock(&h->mtx);
	struct rain_ctx *ctx =  h->ppctx[hash];
	if( !ctx ||  ctx->rid != rid ){
		RAIN_LOG(0,"rain_ctx_handle_kill:,invailed rid:%x",rid);
		rain_mutex_unlock(&h->mtx);
		return RAIN_ERROR;
	}
	bool bexit = false;
	if(__sync_bool_compare_and_swap(&ctx->bexit,false,true)){
		ctx->exit_code = code;
		if(__sync_sub_and_fetch(&ctx->ref,1) == 0){
			bexit = true;
			_unregist_handle(hash);
		}
	}
	rain_mutex_unlock(&h->mtx);
	if(bexit){
		_ctx_destroy(ctx);
	}
	return RAIN_OK;
}
Exemple #22
0
static tcpclient_t *
_new_client(tcpsvr_t *svr,wod_socket_t fd)
{
	if(svr->num_cli == TCPSVR_MAX_CONNECT){
		return NULL;
	}

	int hash = -1;
	int i=0;
	for(i=0;i<TCPSVR_MAX_CONNECT;i++){
		hash = hash_func(svr->cut_index++);
		if(!svr->clients[hash].binuse){
			break;
		}
	}
	assert(hash != -1);
	tcpclient_t * cli = &svr->clients[hash];
	cli->svr = svr;
	if(0 != tcpclient_init(cli,fd,hash)){
		return NULL;
	}
	cli->binuse = true;
	wod_net_noblock(fd,1);
	wod_net_keep_alive(fd,1);
	++svr->num_cli;
	return cli;
}
Exemple #23
0
int find(hash_table* tab,char* key)
{
int hash = hash_func(key);
if(tab->nodes[hash] != NULL) 
return tab->nodes[hash]->value;
else return -1;
}
Exemple #24
0
/*
 * The mroute_addr hash function takes into account the
 * address type, number of bits in the network address,
 * and the actual address.
 */
uint32_t
mroute_addr_hash_function (const void *key, uint32_t iv)
{
  return hash_func (mroute_addr_hash_ptr ((const struct mroute_addr *) key),
		    mroute_addr_hash_len ((const struct mroute_addr *) key),
		    iv);
}
int SymbolTable::insert(Symbol* sym, int op)
{
  int index = hash_func(sym->getName()) % capacity;
  ChainNode* new_node = new ChainNode();
  new_node->data = sym;
  
  if(size >= capacity*loadFactor || size == capacity-1)
    {
      rehash();
      return insert(sym, INSERT);
    }

  while(table[index] && strcmp(sym->getName(), table[index]->data->getName()) != 0)
    index = ++index%capacity;
  if(table[index] == NULL)
    {
     
      new_node->next = NULL;
      table[index] = new_node;
      if(op == INSERT)
	size++;
    }
  else
    {
      new_node->next = table[index];
      table[index] = new_node;
    }

  if(op == INSERT)
    { 
      scopes.push(index);
    }

  return index;
}
Exemple #26
0
elem_t *lookup(hash_table_t table, app_pc addr)
{
    list_t *list = table[hash_func(addr)];
    if (list != NULL)
        return find_elem(list, addr);

    return NULL;
}
Exemple #27
0
struct lll_object *
lll_get_symbol(const char *symbol_string) {
    if (!lll_correct_symbol_string_p(symbol_string)) {
        lll_error(2, symbol_string, __FILE__, __LINE__);
        return NULL;
    }

    char *lowercase_version = lll_to_lowercase(symbol_string);

    if (strcmp(lowercase_version, "nil") == 0) {
        free(lowercase_version);
        return NULL;
    }

    struct lll_symbol_entry *entry = &hash_table[hash_func(lowercase_version)];

    while (true) {
        /* haven't binded symbols. */
        if (entry == NULL) {
            entry = MALLOC_STRUCT(lll_symbol_entry);
            entry->string = lowercase_version;

            struct lll_object *obj = lll_csymbol(entry->string);
            //obj->d.symbol->pair->d.obj = lll_cons(LLL_UNDEFINED(), NULL);

            entry->symbol = obj;
            entry->another_entry = NULL;

            return entry->symbol;
        }

        if (entry->string == NULL) {
            entry->string = lowercase_version;
            entry->symbol = lll_csymbol(entry->string);
            entry->symbol->d.symbol->pair->d.obj = lll_cons(LLL_UNDEFINED(), NULL);

            return entry->symbol;
        }

        if (strcmp(entry->string, lowercase_version) == 0) {
            /* So we have one copy in hash_table. Free second. */
            free(lowercase_version);

            /* string not binded yet */
            if (entry->symbol == NULL) {
                entry->symbol = lll_csymbol(entry->string);
                entry->symbol->d.symbol->pair->d.obj = lll_cons(LLL_UNDEFINED(), NULL);

                return entry->symbol;
            }
            /* string binded */
            else {
                return entry->symbol;
            }
        }
        entry = entry->another_entry;
    }
}
static void
cpSpaceHashPointQuery(cpSpaceHash *hash, cpVect point, cpSpatialIndexQueryFunc func, void *data)
{
	cpFloat dim = hash->celldim;
	int idx = hash_func(floor_int(point.x/dim), floor_int(point.y/dim), hash->numcells);  // Fix by ShiftZ
	
	query_helper(hash, &hash->table[idx], &point, func, data);
	hash->stamp++;
}
// modified from http://playtechs.blogspot.com/2007/03/raytracing-on-grid.html
void
cpSpaceHashSegmentQuery(cpSpaceHash *hash, void *obj, cpVect a, cpVect b, cpFloat t_exit, cpSpatialIndexSegmentQueryFunc func, void *data)
{
	a = cpvmult(a, 1.0f/hash->celldim);
	b = cpvmult(b, 1.0f/hash->celldim);
	
	int cell_x = floor_int(a.x), cell_y = floor_int(a.y);

	cpFloat t = 0;

	int x_inc, y_inc;
	cpFloat temp_v, temp_h;

	if (b.x > a.x){
		x_inc = 1;
		temp_h = (cpffloor(a.x + 1.0f) - a.x);
	} else {
		x_inc = -1;
		temp_h = (a.x - cpffloor(a.x));
	}

	if (b.y > a.y){
		y_inc = 1;
		temp_v = (cpffloor(a.y + 1.0f) - a.y);
	} else {
		y_inc = -1;
		temp_v = (a.y - cpffloor(a.y));
	}
	
	// Division by zero is *very* slow on ARM
	cpFloat dx = cpfabs(b.x - a.x), dy = cpfabs(b.y - a.y);
	cpFloat dt_dx = (dx ? 1.0f/dx : INFINITY), dt_dy = (dy ? 1.0f/dy : INFINITY);
	
	// fix NANs in horizontal directions
	cpFloat next_h = (temp_h ? temp_h*dt_dx : dt_dx);
	cpFloat next_v = (temp_v ? temp_v*dt_dy : dt_dy);
	
	int n = hash->numcells;
	cpSpaceHashBin **table = hash->table;

	while(t < t_exit){
		int idx = hash_func(cell_x, cell_y, n);
		t_exit = cpfmin(t_exit, segmentQuery_helper(hash, &table[idx], obj, func, data));

		if (next_v < next_h){
			cell_y += y_inc;
			t = next_v;
			next_v += dt_dy;
		} else {
			cell_x += x_inc;
			t = next_h;
			next_h += dt_dx;
		}
	}
	
	hash->stamp++;
}
int cache_evict(int file_size){
	while((max_cache-cache_current_size) < file_size){
		cache_current_size =cache_current_size-LST_queue->size;
		int hash = hash_func(8192,LST_queue->name);
		cache[hash]->flag =2;
		LST_queue = delete_head_lst(LST_queue);
	}
	return 0;
}