Rectangle::Rectangle() { set_left ( 0. ); set_right ( 0. ); set_top ( 0. ); set_bottom( 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); }
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; }
Rectangle::Rectangle(float Width, float Height) { set_left ( 0 ); set_bottom ( 0 ); set_width ( Width ); set_height ( Height ); }
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; } } }
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; }
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; }
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; }
Rectangle::Rectangle(float Left, float Bottom, float Width, float Height) { set_left ( Left ); set_right ( Left + Width ); set_top ( Bottom + Height ); set_bottom( Bottom ); }
/* DEFAULT CONSTRUCTOR */ DrawingObject::DrawingObject() { set_type("OBJECT"); set_left(0); set_bottom(0); set_width(0); set_height(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()); }
/** * \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()
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; } }
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); } }
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(); }
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; }
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; }
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); }
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); }
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); }
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(); }
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); } }
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; }
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); }
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(); }
/* 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); }
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; }
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); } }
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; }
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()); }