Ejemplo n.º 1
0
Dictionary Dictionary::copy() const {

	Dictionary n(is_shared());

	List<Variant> keys;
	get_key_list(&keys);

	for(List<Variant>::Element *E=keys.front();E;E=E->next()) {
		n[E->get()]=operator[](E->get());
	}

	return n;
}
Ejemplo n.º 2
0
Dictionary Dictionary::duplicate(bool p_deep) const {

	Dictionary n;

	List<Variant> keys;
	get_key_list(&keys);

	for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
		n[E->get()] = p_deep ? operator[](E->get()).duplicate(p_deep) : operator[](E->get());
	}

	return n;
}
Ejemplo n.º 3
0
uint32_t Dictionary::hash() const {

	uint32_t h = hash_djb2_one_32(Variant::DICTIONARY);

	List<Variant> keys;
	get_key_list(&keys);

	for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {

		h = hash_djb2_one_32(E->get().hash(), h);
		h = hash_djb2_one_32(operator[](E->get()).hash(), h);
	}

	return h;
}
Ejemplo n.º 4
0
void plot_succ_veb(int n, int cutoff, FILE *gnuplot_ins, FILE *gnuplot_succ, FILE *gnuplot_total){
	printf("vEB: %d elements\n",n);
	srandom(235423);
	struct timespec succ, ins, start, end;
	succ.tv_nsec = 0;
	succ.tv_sec = 0;
	ins.tv_nsec = 0;
	ins.tv_sec = 0;
	
	vebtree * vebt = veb_initialize(24, 64);
	rb_tree * rbt = rb_init();
	
	int i;
	for (i = 0; i < n; i++){
		clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start);
		veb_insert(i, NULL, vebt);
		clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end);
		increment(&ins, &start, &end);
		rb_insert(i, rbt);
	}
	linked_list * ll = get_key_list(rbt, cutoff);
	linked_list_node * node= ll->first;
	int ii = 0;
	while(node){
		ii++;
		int32_t s;
		clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start);
		veb_findsucc(node->data, &s, vebt);
		clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end);
		node = node->next;
		increment(&succ, &start, &end);
	}
	printf("searched %d keys\n", ii);
	if(gnuplot_ins)
		fprintf(gnuplot_ins, "%d %ld\n", n, ((ins.tv_sec*  1000000000)+(ins.tv_nsec))/n);
	if(gnuplot_succ)
		fprintf(gnuplot_succ, "%d %ld\n", n, ((succ.tv_sec*1000000000)+(succ.tv_nsec))/(ii));
	if(gnuplot_total)
		fprintf(gnuplot_total, "%d %ld\n", n, (((ins.tv_sec + succ.tv_sec) *  1000)+(ins.tv_nsec + succ.tv_nsec)/1000000));	
	veb_destruct(vebt);
	rb_destruct(rbt);
	linked_list_destruct(ll);
}
Ejemplo n.º 5
0
Key2KanaTable *
StyleFile::get_key2kana_table (std::string section)
{
    Key2KanaTable *table = NULL;

    std::vector<std::string> keys;
    bool success = get_key_list (keys, section);
    if (success) {
        table = new Key2KanaTable (get_title ());
        std::vector<std::string>::iterator it;
        for (it = keys.begin (); it != keys.end (); it++) {
            std::vector<std::string> array;
            get_string_array (array, section, *it);
            table->append_rule (*it, array);
        }
    }

    return table;
}