Exemplo n.º 1
0
Rectangle::Rectangle()
{
	set_left  ( 0. );
	set_right ( 0. );
	set_top   ( 0. );
	set_bottom( 0. );
}
Exemplo n.º 2
0
static void set_child(struct bstree_node *child, struct bstree_node *node, int left)
{
	if (left)
		set_left(child, node);
	else
		set_right(child, node);
}
Exemplo n.º 3
0
int main(void)
{
	int x;
	struct data d;
	struct tree *t,*p,*q;

	d.val = value[0];
	t = alloc_tree(&d); //root node
	
	x=1;
	while(value[x]!=0){
		d.val = value[x];

		p = t;

		/* get to the leaf */
		while(p!=NULL){
			q = p; //Remember the last valid p
			if(d.val > p->d.val)
				p = right(p);
			else
				p = left(p);
		}
		if(d.val > q->d.val)
			set_right(q,&d);
		else
			set_left(q,&d);

		x++;
	}

	inorder_trav(t);

	return 0;
}
Exemplo n.º 4
0
Rectangle::Rectangle(float Width, float Height)
{
	set_left   ( 0 );
	set_bottom ( 0 );	
	set_width  ( Width  );
	set_height ( Height );	
}
Exemplo n.º 5
0
void state_pause()
{
	while(1)
	{
		set_left(0);
		set_right(0);
		while(!wireless_buffer_f);
		wireless_buffer_f = false;
		switch(wireless_buffer[0])
		{
			case PLAY:
				state_play();
				break;
			case DETANGLE:
				state_detangle();
				break;
			case GOALA:
				event_goal('a');
				break;
			case GOALB:
				event_goal('b');
				break;
		}
	}
}
Exemplo n.º 6
0
static off_t del_push(brtr_t *b, off_t r, size_t size, off_t id)
/* puts a node in the delete tree */
{
    struct brtr_node *n;
    struct brtr_node *m;

    if ((n = brtr_node(b, r)) != NULL) {
        size_t ns = node_size(n->ksize, n->vsize);

        if (size < ns)
            r = set_left(b, r, del_push(b, n->left, size, id));
        else
        if (size > ns)
            r = set_right(b, r, del_push(b, n->right, size, id));
        else {
            /* a node of this size already exist;
               enqueue to its stree */
            m = brtr_node(b, id);

            m->stree = n->stree;
            n->stree = id;
        }
    }
    else {
        m = brtr_node(b, id);

        m->left = m->right = m->stree = 0;
        m->c = 1;

        r = id;
    }

    return r;
}
Exemplo n.º 7
0
static off_t del_pull(brtr_t *b, off_t r, size_t size, off_t *id)
/* pulls a node with the specified size from the delete queue */
{
    struct brtr_node *n;

    if ((n = brtr_node(b, r)) != NULL) {
        size_t ns = node_size(n->ksize, n->vsize);

        if (size < ns)
            r = set_left(b, r, del_pull(b, n->left, size, id));
        else
        if (size > ns)
            r = set_right(b, r, del_pull(b, n->right, size, id));
        else {
            struct brtr_node *m;

            /* found; does the node has an stree of equal nodes? */
            if ((m = brtr_node(b, n->stree)) != NULL) {
                *id = n->stree;
                n->stree = m->stree;
            }
            else {
                /* unique node: return it */
                *id = r;
                r = merge_nodes(b, n->left, n->right);
            }
        }
    }

    return r;
}
Exemplo n.º 8
0
struct bstree_node *bstree_insert(struct bstree_node *node, struct bstree *tree)
{
	struct bstree_node *key, *parent;
	int is_left;

	key = do_lookup(node, tree, &parent, &is_left);
	if (key)
		return key;

	if (!parent) {
		INIT_NODE(node);
		tree->root = tree->first = tree->last = node;
		return NULL;
	}
	if (is_left) {
		if (parent == tree->first)
			tree->first = node;
		set_prev(get_prev(parent), node);
		set_next(parent, node);
		set_left(node, parent);
	} else {
		if (parent == tree->last)
			tree->last = node;
		set_prev(parent, node);
		set_next(get_next(parent), node);
		set_right(node, parent);
	}
	return NULL;
}
Exemplo n.º 9
0
Rectangle::Rectangle(float Left, float Bottom, float Width, float Height)
{
	set_left  ( Left 			);
	set_right ( Left + Width    );
	set_top   ( Bottom + Height );
	set_bottom( Bottom 			);
}
Exemplo n.º 10
0
	/* DEFAULT CONSTRUCTOR */
	DrawingObject::DrawingObject()
	{
		set_type("OBJECT");
		set_left(0);
		set_bottom(0);
		set_width(0);
		set_height(0);
	}
Exemplo n.º 11
0
	/* COPY CONSTRUCTOR */
	DrawingObject::DrawingObject(const DrawingObject& o)
	{
		set_type(o.type());
		set_left(o.left());
		set_bottom(o.bottom());
		set_width(o.width());
		set_height(o.height());
	}
Exemplo n.º 12
0
/**
 * \brief Set the rectangle in the image resource.
 * \param r The rectangle.
 */
void
bf::sprite::set_clip_rectangle( const claw::math::rectangle<unsigned int>& r )
{
  set_left(r.position.x);
  set_top(r.position.y);
  set_clip_width(r.width);
  set_clip_height(r.height);
} // sprite::set_clip_rectangle()
Exemplo n.º 13
0
void state_detangle()
{
	m_red(ON);
	set_left(-90);
	set_right(-50);
	m_wait(2000);
	m_red(OFF);
	set_left(0);
	set_right(0);
	char transition = wireless_buffer[0];
	switch(transition)
	{
		case 0xA1:
			state_play();
			return;
	}
}
Exemplo n.º 14
0
void set_car(unsigned int FB, unsigned int LR, unsigned long fast, unsigned long slow)
{
    if (FB){
	set_back();
    }
    else {
	set_go();
    }

    if (LR){
        set_left(slow);
	set_right(fast);
    }
    else {
	set_left(fast);
        set_right(slow);
    }
} 
Exemplo n.º 15
0
	Exit::Exit()
	{
		set_type("EXIT");
		set_left(EXIT_LEFT);
		set_bottom(EXIT_BOTTOM);
		set_width(EXIT_WIDTH);
		set_height(EXIT_HEIGHT);
		add_input(CircuitObject());
		close();
	}
Exemplo n.º 16
0
struct splaytree_node *splaytree_insert(struct splaytree_node *node,
                                        struct splaytree *tree)
{
    struct splaytree_node *root = tree->root;
    int res;

    if (!root) {
        INIT_NODE(node);
        tree->root = node;
        tree->first = node;
        tree->last = node;
        return NULL;
    }

    res = do_splay(node, tree);
    if (res == 0)
        return tree->root;

    root = tree->root;
    if (res < 0) {
        struct splaytree_node *left = get_left(root);

        set_left(left, node);
        set_right(root, node);
        if (left)
            set_next(node, get_last(left));
        else
            tree->first = node;
        set_prev(node, root);
    } else {
        struct splaytree_node *right = get_right(root);

        set_right(right, node);
        set_left(root, node);
        if (right)
            set_prev(node, get_first(right));
        else
            tree->last = node;
        set_next(node, root);
    }
    tree->root = node;
    return NULL;
}
Exemplo n.º 17
0
FractalProto * Fractal::serialize() {
    auto fp = new FractalProto();
    fp->set_bottom(bottom);
    fp->set_height(height);
    fp->set_left(left);
    fp->set_right(right);
    fp->set_width(width);
    fp->set_top(top);
    fp->set_maxiter(maxiter);
    return fp;
}
Exemplo n.º 18
0
static inline void rotate_right(struct splaytree_node *node)
{
    struct splaytree_node *left = get_left(node);	/* can't be NULL */
    struct splaytree_node *r = get_right(left);

    if (r)
        set_left(r, node);
    else
        set_prev(left, node);
    set_right(node, left);
}
Exemplo n.º 19
0
static inline void rotate_left(struct splaytree_node *node)
{
    struct splaytree_node *right = get_right(node);	/* can't be NULL */
    struct splaytree_node *l = get_left(right);

    if (l)
        set_right(l, node);
    else
        set_next(right, node);
    set_left(node, right);
}
Exemplo n.º 20
0
	CircuitObject::CircuitObject(string type)
	{
		set_type(type);
		set_left(0);
		set_bottom(0);
		set_width(0);
		set_height(0);
		set_input1(NULL);
		set_input2(NULL);
		set_output(NULL);
		set_output_value(0);
	}
Exemplo n.º 21
0
	Exit::Exit(const Exit& e)
	{
		set_type(e.type());
		set_left(e.left());
		set_bottom(e.bottom());
		set_width(e.width());
		set_height(e.height());
		add_input(e.input());
		if(e.is_open())
			open();
		else
			close();
	}	
Exemplo n.º 22
0
Node::Node(const Node& src_node) {

    data = src_node.data;
    count = src_node.count;
    if( src_node.left ) {
        Node *new_left = new Node(*(src_node.left));
        set_left(new_left);
    }
    if( src_node.right ) {
        Node *new_right = new Node(*(src_node.right));
        set_right(new_right);
    }
}
Exemplo n.º 23
0
    void tree_cloner::visit_impl(const binary_mult* v)
    {
        v->left()->accept(this);
        auto newleft = cloned_;
        v->right()->accept(this);
        auto newright = cloned_;

        auto& ar = root_->get_arena();
        auto newbinop = ar.create<binary_mult>();
        newbinop->set_left(newleft);
        newbinop->set_right(newright);
        cloned_ = newbinop;
    }
Exemplo n.º 24
0
void rblist::right_rotate(void *item)
{
   void *x, *y;

   y = item;
   x = left(y);
   set_left(y, right(x));
   if (right(x)) {
      set_parent(right(x), y);
   }
   set_parent(x, parent(y));
   /* if no parent then we have a new head */
   if (!parent(y)) {
      head = x;
   } else if (y == left(parent(y))) {
      set_left(parent(y), x);
   } else {
      set_right(parent(y), x);
   }
   set_right(x, y);
   set_parent(y, x);
}
Exemplo n.º 25
0
	CircuitObject::CircuitObject(const CircuitObject& o)
	{
		set_type(o.type());
		set_left(o.left());
		set_bottom(o.bottom());
		set_width(o.width());
		set_height(o.height());
		set_input1(o.input1());
		set_input2(o.input2());
		set_output(o.output());
		set_output_value(o.output_value());
		if(o.has_button())
			give_button();
	}
Exemplo n.º 26
0
/* x is item, y is below and to right, then rotated to below left */
void rblist::left_rotate(void *item)
{
   void *y;
   void *x;

   x = item;
   y = right(x);
   set_right(x, left(y));
   if (left(y)) {
      set_parent(left(y), x);
   }
   set_parent(y, parent(x));
   /* if no parent then we have a new head */
   if (!parent(x)) {
      head = y;
   } else if (x == left(parent(x))) {
      set_left(parent(x), y);
   } else {
      set_right(parent(x), y);
   }
   set_left(y, x);
   set_parent(x, y);
}
Exemplo n.º 27
0
Node tree_create(int key, void* value, int elementSize, Node left, Node right)
{
  assert(value);
  assert(elementSize > 0);
  
  Node node = malloc(sizeof(*node));
  assert(node);

  set_key(node, key);
  set_value(node, value, elementSize);
  set_elementSize(node, elementSize);
  set_left(node, left);
  set_right(node, right);

  return node;
}
Exemplo n.º 28
0
void sniper()
{

	init_all();	
	// set voltage reference to 5V
	 clear(ADMUX, REFS1);
	  set(ADMUX, REFS0);

	  m_disableJTAG();//allowing gpio of F pins

	  //setting ADC prescaler
	  set(ADCSRA,ADPS2);
	  set(ADCSRA,ADPS1);
	  set(ADCSRA,ADPS0);

	  //setting pins to turn off digital circuitry
	  set(DIDR0,ADC1D);//setting F1
	  set(DIDR0,ADC4D);//setting F4
	  set(DIDR0,ADC5D);//setting F5
	  set(DIDR0,ADC6D);//setting F6
	  set(DIDR0,ADC7D);//setting F7

	set(ADCSRA, ADEN);
	play_state = 1;
	set_position(1024/2, 768/2);
	first = true;

	//state_before_game();

	//state_play();

	m_usb_init();
/*	while(!m_usb_isconnected());
	m_green(ON);
*/
	set_left(30);
	set_right(100);
	while(1)
	{
		adc();
	//	m_usb_tx_string("left: ");
		//m_usb_tx_int(a_left);
		wait(1);
	}

}
Exemplo n.º 29
0
    void tree_cloner::visit_impl(const assign* v)
    {
        v->var()->accept(this);
        auto newvar = reinterpret_cast<variable*>(cloned_);
        v->right()->accept(this);
        auto newval = cloned_;

        auto& ar = root_->get_arena();
        auto newasgn = ar.create<assign>();
        newasgn->set_left(newvar);
        newasgn->set_right(newval);

        auto ty = symbol_table::lookup(curr_->table(), v->var()).type;
        symbol_table::set(root_->table(), newvar, newval, ty);

        cloned_ = newasgn;
    }
Exemplo n.º 30
0
void InputMessage::MergeFrom(const InputMessage& from) {
  GOOGLE_CHECK_NE(&from, this);
  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
    if (from.has_ahead()) {
      set_ahead(from.ahead());
    }
    if (from.has_back()) {
      set_back(from.back());
    }
    if (from.has_left()) {
      set_left(from.left());
    }
    if (from.has_right()) {
      set_right(from.right());
    }
  }
  mutable_unknown_fields()->MergeFrom(from.unknown_fields());
}