Esempio n. 1
0
END_TEST

START_TEST(test_node_delete)
{
    node *root = node_new("d", "definition");
    node *l = node_new("b", "b");
    node *ll = node_new("a", "a");
    node *lr = node_new("c", "c");

    node_insert(root, l);
    node_insert(root, ll);
    node_insert(root, lr);

    // ensure correct insertions
    ck_assert_ptr_eq(l, root->left);
    ck_assert_ptr_eq(ll, root->left->left);
    ck_assert_ptr_eq(lr, root->left->right);

    ck_assert_int_eq(4, node_size(root));

    ck_assert_ptr_eq(l, node_delete(root, "b"));

    // ensure correct reinsertion
    ck_assert_ptr_eq(ll, root->left);
    ck_assert_ptr_eq(NULL, root->right);
    ck_assert_ptr_eq(NULL, root->left->left);
    ck_assert_ptr_eq(lr, root->left->right);

    // node is not found in the tree anymore
    ck_assert_ptr_eq(NULL, node_search(root, "b"));

    ck_assert_int_eq(3, node_size(root));

    node_free(root);
}
Esempio n. 2
0
node *node_insert (node *n,char *s) {
    if(n == NULL) {
        n = node_init(data);
        int r = strcmp(n->data,s);
    } else if(r > 0) {
        n->l = node_insert(n->l,s);
    } else if(r < 0) {
        n->r = node_insert(n->r,s);
    }
    return n;
}
Esempio n. 3
0
NODE* node_insert(NODE* node, SYMBOL *symbol)
{
	NODE *root;
	int balance;
	int cmp, cmpchild;
	root = node;

	if (node == NULL)
		return node_new(symbol);
	
	cmp = strcmp(symbol->id, node->symbol->id);
	if (cmp < 0)
	{	 
		/* Left */
		node->left = node_insert(node->left, symbol);
		
		balance = node_height(node->left) - node_height(node->right);
		if (balance == 2)
		{
			cmpchild = strcmp(symbol->id, node->left->symbol->id);
			if (cmpchild < 0)
				root = LL(node);
			else if (cmpchild > 0)
				root = LR(node);
		}

	} else if (cmp > 0)
	{
		/* Right */
		node->right = node_insert(node->right, symbol);

		balance = node_height(node->right) - node_height(node->left);		
		if (balance == 2)
		{
			cmpchild = strcmp(symbol->id, node->right->symbol->id);
			if (cmpchild < 0)
				root = RL(node);
			else if (cmpchild > 0)
				root = RR(node);
		}
 
	}/* else 
	{
		the implementation doesn't allow duplicates, since a lookup is ALWAYS performed first
	} */

	node->height = max(node_height(node->left), node_height(node->right))+1;
	return root;
}
Esempio n. 4
0
void
rbtree_insert(struct rbtree *tree, struct rbtree_elem *elem)
{
  rbnode_t root;

  //rbtree_inorder_check(tree) ;
  root = tree->root;
#if 0
  if (node = rbtree_find(tree, elem)) {
    //rbtree_inorder_check(tree) ;
    return false;
  }
#endif

  //rbtree_inorder_check(tree) ;
  elem->left = elem->right = elem->parent = nil;
  elem->color = _RED_;

  node_insert(&tree->root, elem, tree->less, tree->aux);

  //if (node->parent!=nil && node->parent->left==node) ASSERT(node->high<node->parent->low) ;
  //if (node->parent!=nil && node->parent->right==node) ASSERT(node->low>node->parent->high) ;
  //if (node->right!=nil) ASSERT(node->high<node->right->low) ;
  //if (node->left!=nil) ASSERT(node->low>node->left->high) ;
  //rbtree_inorder_check(tree);
}
Esempio n. 5
0
void trie_insert(trie_tree *tree, const wchar_t *word)
{
	assert(tree != NULL);
	if(tree->root == NULL)
		tree->root = node_make_leaf(L'\0');
	node_insert(tree->root, word);
}
Esempio n. 6
0
void Bptree::insert(Table_info table,Attribute attribute,std::string value,Address record_address)
{
    get_root(table, attribute);
    Address child_new_address;
    std::string child_new_value;
    bool splited=node_insert(root_address,value,record_address,&child_new_address,&child_new_value);
    if (splited)
    {
        Address new_root_address=new_block();
        Bptree_node *new_root=new_node();
        new_root->number=1;
        new_root->leaf=false;
        new_root->key[0]->assign(child_new_value);
        new_root->link[0]=root_address;
        new_root->link[1]=child_new_address;
        new_root->write_back(new_root_address);
        delete root;
        root=new_root;
        root_address=new_root_address;
        // std::cout<<filename<<std::endl;
        Address header_address(table.database,filename,0);
        Block header;
        buffer->read_data(header_address, &header);
        Address_byte root_address_byte;
        root_address_byte.address=new_root_address.address_int();
        header.fill_block_data(0, ADDRESS_SIZE, root_address_byte.byte);
        buffer->write_data(header_address, &header);
    }
}
Esempio n. 7
0
END_TEST

START_TEST(test_node_search)
{
    node *root = node_new("term", "definition");
    node *l = node_new("a", "");
    node *r = node_new("c", "");

    node_insert(root, l);
    node_insert(root, r);

    node *s = node_search(root, "a");

    ck_assert_ptr_eq(l, s);

    node_free(root);
}
Esempio n. 8
0
avl_tree_node_t *avl_tree_add(avl_tree_t *t, avl_tree_key_t k) {
    avl_tree_node_t *n;
    assert(t);

    t->root = node_insert(t->root, t->root, t, k, &n);
    ++t->count;
    return n;
}
Esempio n. 9
0
void plist_array_insert_item(plist_t node, plist_t item, uint32_t n)
{
    if (node && PLIST_ARRAY == plist_get_node_type(node))
    {
        node_insert(node, n, item);
    }
    return;
}
Esempio n. 10
0
int main(int argc, char* argv[]) {
	int i, j, k;
	char c;

	node *head = (node*) malloc(sizeof(node)); // 헤드 노드 생성
	head->next = NULL; // 잘못된 주소 할당 방지 위해 next 포인터 0x0 으로 만들어 놓기 -> head 노드가 노드의 끝이라는 것 명시
	printf("Main: %p, %p\n", head, head->next); // 헤드 노드 및 next 포인터 프린트


	while(1) {
		printf("Input command(I: insert, A: append, C: Append sequentially, D: delete, P: print, R: print all. E: exit.\n");
		scanf(" %c", &c);
		if(c =='E' || c == 'e') break;
		switch(c) {
			case 'I':
			case 'i':
				printf("Input number and position (For example, 4 5 measn put number 4 in fifth node)\n");
				scanf("%d %d", &i, &j);
				node_insert(head, i, j);
				break;
			case 'A' :
			case 'a' :
				printf("Input number (for example, 4 means append number 4)\n");
				scanf("%d", &i);
				node_append(head, i);
				break;
			case 'C' :
			case 'c' :
				printf("Input number (for example, 4 8 means append number 4 5 6 7 8 in a row)\n");
				scanf("%d %d", &i, &j);
				for(k=i; k<=j; k++)
					node_append(head, k);
				break;
			case 'D' :
			case 'd' :
				printf("Input node position to delete (For example, 5 means delete node in postition 5)\n");
				scanf("%d", &i);
				node_remove(head, i);
				break;
			case 'P' :
			case 'p' :
				printf("Input node position to print(For example, 5 means print number in fifth node)\n");
				scanf("%d", &i);
				node_print(head, i);
				break;
			case 'R' :
			case 'r' :
				node_print_all(head);
				break;
		}
	}


	free(head);
	return 0;
}
Esempio n. 11
0
END_TEST

START_TEST(test_node_insert)
{
    node *root = node_new("b", "definition");
    node *l = node_new("a", "a");
    node *r = node_new("c", "c");

    node_insert(root, l);
    node_insert(root, r);

    ck_assert_ptr_eq(l, root->left);
    ck_assert_ptr_eq(r, root->right);

    ck_assert_str_eq("a", root->left->definition);
    ck_assert_str_eq("c", root->right->definition);

    ck_assert_int_eq(3, node_size(root));

    node_free(root);
}
Esempio n. 12
0
END_TEST

START_TEST(test_recursive_node_definition)
{
    node *root = node_new("compound", "a+c+b");

    node *a = node_new("a", "haha");
    node *b = node_new("b", "you");
    node *c = node_new("c", "lie");

    node_insert(root, a);
    node_insert(root, b);
    node_insert(root, c);

    char *definition = node_definition(root, root);

    ck_assert_str_eq("haha you lie", definition);

    node_free(root);
    free(definition);
}
Esempio n. 13
0
static inline
avl_tree_node_t *node_insert(avl_tree_node_t *n,
                             avl_tree_node_t *parent,
                             avl_tree_t *t,
                             avl_tree_key_t k,
                             avl_tree_node_t **inserted) {
    if (!n) {
        n = node_operators[t->inplace].allocator(t, k);
        n->parent = parent;
        *inserted = n;

        return n;
    }

    if (k < n->key)
        n->left = node_insert(n->left, n, t, k, inserted);
    else
        n->right = node_insert(n->right, n, t, k, inserted);

    return node_balance(n);
}
Esempio n. 14
0
File: node.c Progetto: hydra/freewpc
void node_insert_delay_update (struct ball *ball)
{
    ball->timer -= MIN_DELAY;
    if (ball->timer <= 0)
    {
        struct ball_node *dst = ball->node;
        ball->node = NULL;
        node_insert (dst, ball);
    }
    else
        sim_time_register (MIN_DELAY, FALSE,
                           (time_handler_t)node_insert_delay_update, ball);
}
Esempio n. 15
0
/**
 Dodaje słowo do poddrzewa node'a
 @param[in,out] node Węzeł
 @param[in] word Słowo
 */
static void node_insert(trie_node *node, const wchar_t *word)
{
	assert(node != NULL);
	if(word[0] == L'\0')
	{
		node->end_of_word = true;
		return;
	}
	trie_node *son = node_son(node, word[0]);
	if(son == NULL)
		son = node_add_son(node, word[0]);
	node_insert(son, word + 1);
}
Esempio n. 16
0
static int ramfs_create(struct device_d *dev, const char *pathname, mode_t mode)
{
	struct ramfs_priv *priv = dev->priv;
	struct ramfs_inode *node;
	char *file;

	node = rlookup_parent(priv, pathname, &file);
	if (node) {
		node_insert(node, file, mode);
		return 0;
	}
	return -ENOENT;
}
Esempio n. 17
0
void
cc_trie_insert(struct cc_trie* tp, const char* str, unsigned int ud) {
    if(str == NULL) return;

    char c;
    uint32_t cur_pos = tp->root;
    for(; (c=*str++); ) {
        if(c2idx(c) >= 0) {
            cur_pos = node_insert(tp, cur_pos, c);
        }
    }

    struct cc_node* node = pos2node(tp, cur_pos);
    node_addud(node, ud);
}
Esempio n. 18
0
END_TEST

START_TEST(test_node_free)
{
    node *n = node_new("a", "a");
    node *l = node_new("b", "b");

    node_insert(n, l);

    ck_assert_ptr_eq(l, n->right);

    node_free(n);

    // @TODO vérifier que n et l sont désalloués
}
Esempio n. 19
0
bool
rbtree_insert(struct rbtree *tree, ipaddr_t IP)
{
  rbnode_t root, node, parent, succ, pred;

  root = tree->root;
  if (search_pred_succ(root, IP, &succ, &pred)) {
    return false;
  }

  if (pred != nil && pred->high == IP - 1) {
    if (succ != nil && succ->low == IP+1) {
      //log_printf("succ!=nil & pred!=nil.\n") ;

      ipaddr_t high = succ->high ;
      //inorder_check(*tree) ;
      node_delete(&tree->root, succ) ;
      //inorder_check(*tree);
      node = pred;
      pred->high = high;
      //if (pred->parent!=nil && pred->parent->left==pred) ASSERT(pred->high<pred->parent->low) ;
      //if (pred->right!=nil) ASSERT(pred->high<pred->right->low) ;
    } else {
      node = pred;
      pred->high = IP;
    }
  } else if (succ!=nil && succ->low==IP+1) {
    node = succ;
    succ->low=IP;
  } else {
    rbnode_t new_node;
    new_node = malloc(sizeof(struct rbtree_elem));
    ASSERT(new_node);
    new_node->low = new_node->high = IP;
    new_node->left = new_node->right = new_node->parent = nil;
    new_node->color = _RED_;

    node = new_node;
    node_insert(&tree->root, new_node);
  }
  //if (node->parent!=nil && node->parent->left==node) ASSERT(node->high<node->parent->low) ;
  //if (node->parent!=nil && node->parent->right==node) ASSERT(node->low>node->parent->high) ;
  //if (node->right!=nil) ASSERT(node->high<node->right->low) ;
  //if (node->left!=nil) ASSERT(node->low>node->left->high) ;
  //inorder_check(*tree) ;
  return true;
}
Esempio n. 20
0
void plist_dict_set_item(plist_t node, const char* key, plist_t item)
{
    if (node && PLIST_DICT == plist_get_node_type(node))
    {
        node_t* old_item = plist_dict_get_item(node, key);
        if (old_item)
        {
            int idx = plist_free_node(old_item);
	    if (idx < 0) {
		node_attach(node, item);
	    } else {
		node_insert(node, idx, item);
	    }
        }
    }
    return;
}
Esempio n. 21
0
void plist_array_set_item(plist_t node, plist_t item, uint32_t n)
{
    if (node && PLIST_ARRAY == plist_get_node_type(node))
    {
        plist_t old_item = plist_array_get_item(node, n);
        if (old_item)
        {
            int idx = plist_free_node(old_item);
	    if (idx < 0) {
		node_attach(node, item);
	    } else {
		node_insert(node, idx, item);
	    }
        }
    }
    return;
}
Esempio n. 22
0
int main (void){

	LNode my_List;
	LNode temp;
	void *ptr;
	ptr	=NULL;
	arr_init(ptr);
	my_List=llist_new(ptr);

	temp=my_List;

	while (temp!=NULL){
		printf("%d\n",temp->data);
		temp=temp->next;
	}
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
	node_insert(my_List,888,21);

	temp=my_List;

	while (temp!=NULL){
		printf("%d\n",temp->data);
		temp=temp->next;
	}
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

	node_delete(my_List,21);
	temp=my_List;
	while (temp!=NULL){
		printf("%d\n",temp->data);
		temp=temp->next;
	}









	return 0;
}
Esempio n. 23
0
    void OctreeQuant(RGB* src_pixels, int pixels_count, u8* dst_pixels, RGB dst_palette[256])
    {
        node_heap heap = { 0, 0, 0 };
        oct_node* root = node_new(0, 0, 0);

        RGB* pix = src_pixels;
        for (int i = 0; i < pixels_count; i++) {
            heap_add(&heap, node_insert(root, (u8*)pix));
            pix++;
        }

        while (heap.n > 256 /* palette size */ + 1) {
            heap_add(&heap, node_fold(pop_heap(&heap)));
        }

        for (int i = 1; i < heap.n; i++) {
            oct_node* node = heap.buf[i];

            double c = node->count;

            node->r = (u32)(node->r / c + .5);
            node->g = (u32)(node->g / c + .5);
            node->b = (u32)(node->b / c + .5);

            RGB* plt_entry = dst_palette + (i - 1);

            plt_entry->red   = node->r;
            plt_entry->green = node->g;
            plt_entry->blue  = node->b;
        }

        RGB* sptr = src_pixels;
        u8* dptr = dst_pixels;
        for (int i = 0; i < pixels_count; i++) {
            color_replace(root, (u8*)sptr, dptr);
            sptr++;
            dptr++;
        }

        node_free();
        free(heap.buf);
    }
Esempio n. 24
0
bool
skiplist_insert(skiplist* list, void* key, void*** datum_location)
{
    ASSERT(list != NULL);

    skip_node* x = list->head;
    skip_node* update[MAX_LINK] = { 0 };
    for (unsigned k = list->top_link+1; k-->0; ) {
	ASSERT(x->link_count > k);
	while (x->link[k] && list->cmp_func(key, x->link[k]->key) > 0)
	    x = x->link[k];
	update[k] = x;
    }
    x = x->link[0];
    if (x && list->cmp_func(key, x->key) == 0) {
	if (datum_location)
	    *datum_location = &x->datum;
	return false;
    }
    return node_insert(list, key, datum_location, update);
}
Esempio n. 25
0
File: node.c Progetto: hydra/freewpc
/* Move a ball from one location to another.  The two nodes do not
	have to be connected via the default topology. */
void node_move (struct ball_node *dst, struct ball_node *src)
{
    struct ball *ball;

    if (!dst || !src)
        return;

    /* If there are already too many balls in the destination, then
    don't allow the operation: it must remain where it is. */
    if (node_full_p (dst))
    {
        simlog (SLC_DEBUG, "node_kick %s: destination %s is full", src->name, dst->name);
        return;
    }

    ball = node_remove (src);
    if (!ball)
    {
        simlog (SLC_DEBUG, "node_kick: no balls in %s", src->name);
        return;
    }

    simlog (SLC_DEBUG, "node_kick: %s -> %s", src->name, dst->name);
    /* If no delay is associated with a movement from the source, then
    the move is instantaneous.  Otherwise, it will be performed later; in
    the meantime the ball is not associated with any node. */
    if (src->delay == 0)
        node_insert (dst, ball);
    else
    {
#ifdef CONFIG_UI
        ui_update_ball_tracker (ball->index, src->name);
#endif
        node_insert_delay (dst, ball, src->delay);
    }
}
Esempio n. 26
0
bool Bptree::node_insert(Address current, std::string value, Address record_address, Address* new_address, std::string *new_value)
{
    Address null_value(root_address.database_name,filename,0);
    Bptree_node *now=root;
    now->read_from(current);
    bool flag=true;
    bool ret=false;
    Key_type *target;
    switch (attribute.type)
    {
        case SQL_INT:target=new Int_key;break;
        case SQL_FLOAT:target=new Float_key;break;
        case SQL_STRING:target=new String_key(attribute.size);break;
    }
    target->assign(value);
    int loc = 0;
    for (loc=0;loc<now->number;loc++)
    {
        if (target->not_bigger_than(now->key[loc]))
        {
            break;
        }
    }
    if (now->leaf)
    {
        /*when equal, if deleted?not?*/
        if (target->equal(now->key[loc])&&(now->number!=0))
        {
            if (now->deleted[loc]==1)
            {
                now->link[loc]=record_address;
                now->deleted[loc]=0;
                now->write_back(current);
                ret=false;
            }
            else
            {
                // std::cout<<target->key.key_str<<std::endl;
                Error error(16);
                throw error;
            }
        }
        else
        if (now->number<max_branch_number)
        {
            //not split
            for (int i=max_branch_number-1;i>loc;i--)
            {
                now->key[i]->assign(now->key[i-1]->str());
                now->link[i]=now->link[i-1];
                now->deleted[i]=now->deleted[i-1];
            }
            now->key[loc]->assign(value);
            now->link[loc]=record_address;
            now->number++;
            now->write_back(current);
            ret=false;
        }
        else
        {
            //split

            Bptree_node *right=new_node();
            int j=0;
            Address origin_next=now->link[max_branch_number];
//                for (int i=0;i<=max_branch_number;i++)
//                {
//                    std::cout<<"link["<<i<<"]:"<<now->link[i].address_int()<<std::endl;
//                }
            for (int i=max_branch_number;i>loc;i--)
            {
                now->key[i]->assign(now->key[i-1]->str());
                now->link[i]=now->link[i-1];
                now->deleted[i]=now->deleted[i-1];
            }
            now->key[loc]->assign(value);
            now->link[loc]=record_address;
            now->number++;
//                for (int i=0;i<=max_branch_number;i++)
//                {
//                    std::cout<<"link["<<i<<"]:"<<now->link[i].address_int()<<std::endl;
//                }
            for (int i=now->number/2;i<=max_branch_number;i++)
            {
                right->key[j]->assign(now->key[i]->str());
                right->link[j]=now->link[i];
                right->deleted[j]=now->deleted[i];
                now->deleted[i]=false;
                now->link[i]=null_value;
                j++;
            }
            int all=now->number;
            *new_value=now->key[all/2-1]->str();
            now->number=all/2;
            right->leaf=true;
            right->number=all-all/2;
            right->link[max_branch_number]=origin_next;
            Address right_address=new_block();
            *new_address=right_address;
            now->link[max_branch_number]=right_address;
            right->write_back(right_address);
            now->write_back(current);
            delete right;
            ret=true;
            
        }
        
    }
    else
    {
        Address child_new_address;
        std::string child_new_value;
        bool splited=node_insert(now->link[loc],value,record_address,&child_new_address,&child_new_value);
        if (splited==false)
        {
            ret=false;
        }
        else
        {
            now->read_from(current);
            if (now->number<max_branch_number)
            {
                for (int i=max_branch_number-1;i>loc;i--)
                {
                    now->key[i]->assign(now->key[i-1]->str());
                    now->deleted[i]=now->deleted[i-1];
                    now->link[i+1]=now->link[i];
                }
                now->key[loc]->assign(child_new_value);
                now->link[loc+1]=child_new_address;
                now->number++;
                now->write_back(current);
//                    for (int i=0;i<=max_branch_number;i++)
//                    {
//                        std::cout<<"link["<<i<<"]:"<<now->link[i].address_int()<<std::endl;
//                    }
                ret=false;
            }
            else
            {
                Bptree_node *right=new_node();
                for (int i=max_branch_number;i>loc;i--)
                {
                    now->key[i]->assign(now->key[i-1]->str());
                    now->deleted[i]=now->deleted[i-1];
                    now->link[i+1]=now->link[i];
                }
                now->key[loc]->assign(child_new_value);
                now->link[loc+1]=child_new_address;
                now->number++;
                int j=0;
                for (int i=now->number/2;i<=max_branch_number;i++)
                {
                    right->key[j]->assign(now->key[i]->str());
                    right->link[j]=now->link[i];
                    now->link[i]=null_value;
                    j++;
                }
                right->link[j]=now->link[max_branch_number+1];
                int all=now->number;
                *new_value=now->key[all/2-1]->str();
                now->number=all/2-1;
                right->leaf=false;
                right->number=all-all/2;
                Address right_address=new_block();
                *new_address=right_address;
                now->link[max_branch_number]=null_value;
                right->write_back(right_address);
                now->write_back(current);
                delete right;
                ret=true;

                
            }
        }
    }
    delete target;
    return ret;
}
Esempio n. 27
0
SYMBOL* scope_insert(SCOPE* scope, SYMBOL* symbol)
{
	scope->node[symbol->type] = node_insert(scope->node[symbol->type], symbol);
	return symbol;
}
Esempio n. 28
0
File: node.c Progetto: hydra/freewpc
/* Initialize the node graph for this machine.
	This creates the nodes that match the topology of the game, using
	some of the machine-specific parameters to guide things.
	Last, the ball trough is populated with all of the pinballs. */
void node_init (void)
{
    unsigned int i;

    /* Create nodes for all playfield switches.  Not all of these will
    be used necessarily.  The default is for all switches to drain to the
    open playfield.  The switch will remain active for 100ms before it moves. */
    for (i=0; i < NUM_SWITCHES; i++)
    {
        struct ball_node *node = switch_nodes + i;
        node->name = names_of_switches[i];
        node->type = &switch_type_node;
        node->index = i;
        node->unlocked = 1;
        node->size = 1;
        node_join (node, &open_node, 100);
    }

    /* Create nodes for the ball devices.  Trough leads to shooter;
    everything else leads to the open playfield as for the switches. */
    for (i=0; i < MAX_DEVICES; i++)
    {
        device_nodes[i].type = &device_type_node;
        device_nodes[i].index = i;
        device_nodes[i].size = device_properties_table[i].sw_count;
        device_nodes[i].name = device_properties_table[i].name;
        device_nodes[i].unlocked = 0;
#if defined(DEVNO_TROUGH) && defined(MACHINE_SHOOTER_SWITCH)
        if (i == DEVNO_TROUGH)
            node_join (&device_nodes[i], &shooter_node, 50);
        else
#endif
            node_join (&device_nodes[i], &open_node, 0);
    }

    /* The outhole and the shooter switches, initialized above, can
    actually hold more pinballs than 1; they just queue up undetected.
    They are also unlocked, meaning that they stay there until something
    forces them to move on. */
#ifdef MACHINE_OUTHOLE_SWITCH
    outhole_node.size = MAX_BALLS_PER_NODE;
    outhole_node.unlocked = 0;
    node_join (&outhole_node, &trough_node, 100);
#endif
#ifdef MACHINE_SHOOTER_SWITCH
    shooter_node.size = MAX_BALLS_PER_NODE;
    shooter_node.unlocked = 0;
    node_join (&shooter_node, &open_node, 0);
#endif

    /* Initialize the open playfield node, which feeds into the trough
    (or outhole if present). */
    open_node.name = "Playfield";
    open_node.type = &open_type_node;
    open_node.size = MAX_BALLS_PER_NODE;
    open_node.unlocked = 0;
#ifdef drain_node
    node_join (&open_node, &drain_node, 0);
#endif

    /* Fixup the graph in a machine-specific way */
#ifdef CONFIG_MACHINE_SIM
    mach_node_init ();
#endif

#ifdef DEVNO_TROUGH
    /* Create the pinballs and dump them into the trough.
    	Actually, we dump them onto the playfield and force them to drain.
    	This lets us install more balls than the trough can hold, as if
    	you just dropped them onto the playfield. */
    for (i=0; i < sim_installed_balls; i++)
    {
        the_ball[i].node = NULL;
        strcpy (the_ball[i].name, "Ball X");
        the_ball[i].name[5] = i + '0';
        the_ball[i].index = i;
        the_ball[i].flags = 0;

        node_insert (&open_node, &the_ball[i]);
        node_kick (&open_node);
    }
#endif
}
Esempio n. 29
0
void scope_insert(SCOPE* scope, SYMBOL* symbol)
{
	scope->node = node_insert(scope->node, symbol);
}
Esempio n. 30
0
void tree_insert (tree *bt,char *s) {
    bt->root = node_insert(bt->root,s);
}