void lemipc(int ac, char **av) { t_info *info; info = init(ac, av); print_board(info->game, 0); while (is_last(info)) ; while (42) { sem_op(info->semid, -1); print_board(info->game, 1); is_dead(info); if (is_last(info)) shmclear(&info, 1); if (info->lead) find(info); else listen_lead(info); print_board(info->game, 0); sem_op(info->semid, 1); usleep(TIMEOUT); } shmclear(&info, 2); }
void* linkedlist_remove(linkedlist _list, void* data) { linkedlist_t* list = (linkedlist_t*) _list; node* n = find_by_data(list, data); if(NULL == n) return NULL; if(is_first(list, n)) // at the first { if(is_last(list, n)) // only one exists { set_head(list, NULL); set_tail(list, NULL); } else // one or more exist { set_head(list, get_next(n)); set_prev(n, NULL); } } else if(is_last((linkedlist_t*)_list, n)) { set_next(get_prev(n), NULL); set_tail(list, get_prev(n)); } else { set_prev(get_next(n), get_prev(n)); set_next(get_prev(n), get_next(n)); } list->size--; free(n); return data; }
list_pointer search_item_in_list(object_type item, list_type *list) { list_pointer aux; /* If there is no item on the list, it returns NULL*/ if(!get_first_in_list(list, &aux)) return NULL; /* While there is an next item, keep searching */ do { if (compare_objects(aux->item, item)) { return aux; } go_next(list, &aux); } while (!is_last(aux, list)); /* Tests if the object is the last */ if (compare_objects(aux->item, item)) { return aux; } return NULL; }
void ASTIterator::next() { if (!is_last()) { _current = ASTParent(_current); } else { _current = NULL; } }
std::string sequence_formatter::postfix(const bool skip) const { if (skip) return empty; std::ostringstream s; s << value_for_position(postfix_configuration_); if (!is_last()) s << element_separator_; return s.str(); }
virtual void operator()(Formatter& output) { for (sexpr::Node* name_expr = namespace_node->s_expr->first_child; name_expr != 0; name_expr = name_expr->next_sibling) { output.put_id(name_expr->token); if (!is_last(name_expr)) { output.put_str("::"); } } }
/* Produce reverse call tree output */ static void inverted_tree(int lev, int last, Symbol *sym) { struct linked_list_entry *p; int rc; if (sym->type == SymUndefined || (max_depth && lev >= max_depth) || !include_symbol(sym)) return; rc = print_symbol(0, lev, last, sym); newline(); if (rc || sym->active) return; set_active(sym); for (p = linked_list_head(sym->caller); p; p = p->next) { set_level_mark(lev+1, !is_last(p)); inverted_tree(lev+1, is_last(p), (Symbol*)p->data); } clear_active(sym); }
//删除一个元素 //如果该元素在表中,则删除,否则不处理(不在表中那么is_last) void delete_node(element_type x, List L) { position p; position tmp_cell; p = find_previous(x, L); if (!is_last(p, L)) { tmp_cell = p->next; p->next = tmp_cell->next; free(tmp_cell); } }
void World::clear() { for (auto i = Entity::list.iterator(); !i.is_last(); i.next()) remove(i.item()); Entity::list.clear(); for (s32 i = 0; i < Entity::list.data.length; i++) Entity::list.data[i].revision = 0; for (Family i = 0; i < World::families; i++) component_pools[i]->clear(); remove_buffer.length = 0; // any deferred requests to remove entities should be ignored; they're all gone }
std::string sequence_formatter:: value_for_position(const infix_configuration& ic) const { if (is_single()) { if (!ic.first().empty()) { // when we are single, first takes priority if supplied. return ic.first(); } return ic.last(); } else if (is_first() && !ic.first().empty()) { // if is first and first has been supplied, it takes precedence. return ic.first(); } else if (!is_last() && !ic.not_last().empty()) { // if we are not last (including first) and not last has been // supplied. return ic.not_last(); } else if (!is_first() && (!is_last() || !ic.not_first().empty())) { // when we are last, not first takes precedence if supplied. return ic.not_first(); } else if (is_last()) return ic.last(); return empty; }
void sequence_formatter::log_current_state() const { BOOST_LOG_SEV(lg, debug) << "Position: " << position_ << " element separator: " << element_separator_ << " is first: " << is_first() << " is last: " << is_last() << " is single: " << is_single(); BOOST_LOG_SEV(lg, debug) << "Prefix configuration: " << prefix_configuration_; BOOST_LOG_SEV(lg, debug) << "Value for prefix position: " << value_for_position(prefix_configuration_); BOOST_LOG_SEV(lg, debug) << "Postfix configuration: " << postfix_configuration_; BOOST_LOG_SEV(lg, debug) << "Value for postfix position: " << value_for_position(postfix_configuration_); }
/*单链表实现*/ void exchange_lnode(pnode pos, list l) { if (is_last(pos, l)) { print_error("can not exchange a last node!\n"); exit(-1); } pnode ptmp = find_previous_by_point(pos, l); if (ptmp == NULL) { print_error("can not find that node!"); exit(-1); } ptmp->next = pos->next; pos->next = ptmp->next->next; ptmp->next->next = pos; }
void print_fourmis(t_env *l) { t_fms *tmp; tmp = l->f; while (tmp) { if (tmp->move == 1) { ft_putchar('L'); ft_putnbr(tmp->num); ft_putchar('-'); ft_putstr(tmp->location->node->name); if (!is_last(tmp->next)) ft_putchar(' '); } tmp = tmp->next; } ft_putchar('\n'); }
/* Sends all the objects of the list to the filter BIN*/ int send_object_list(list_type *list, int number_of_dimensions, OutputPortHandler port) { list_pointer aux; /* If the first item is not found, it justs returns */ if (!get_first_in_list(list, &aux)) { return 0; } /* Send the first object of the List*/ send_object_values(&(aux->item), number_of_dimensions, port); while (!is_last(aux, list)) { go_next(list, &aux); send_object_values(&(aux->item), number_of_dimensions, port); } return 1; }
/* Produce reverse call tree output */ static void inverted_tree(int lev, int last, Symbol *sym) { Consptr cons; int rc; if (sym->type == SymUndefined || (max_depth && lev >= max_depth) || !include_symbol(sym)) return; rc = print_symbol(0, lev, last, sym); newline(); if (rc || sym->active) return; set_active(sym); for (cons = sym->caller; cons; cons = CDR(cons)) { set_level_mark(lev+1, is_printable(CDR(cons))); inverted_tree(lev+1, is_last(cons), (Symbol*)CAR(cons)); } clear_active(sym); }
virtual void operator()(formatter& output) { output.put_id(function_call->s_expr->token); output.put_char('('); for (ast::node* argument = function_call->first_child; argument != 0; argument = argument->next_sibling) { switch (argument->type) { case ast::node_term_variable: { int var_index = ast::annotation<ast::term_ann>(argument)->var_index; output.put_str(var_prefix); output.put_int(var_index); } break; case ast::node_term_call: { paste_precondition_function_call paste(argument, var_prefix); output.put_str("world."); paste(output); } break; default: // unsupported argument type plnnrc_assert(false); } if (!is_last(argument)) { output.put_str(", "); } } output.put_char(')'); }
void Audio::update() { for (auto i = Audio::list.iterator(); !i.is_last(); i.next()) { Transform* transform = i.item()->get<Transform>(); if (transform) { Vec3 pos; Quat rot; transform->absolute(&pos, &rot); AkSoundPosition sound_position; sound_position.Position.X = pos.x; sound_position.Position.Y = pos.y; sound_position.Position.Z = pos.z; Vec3 forward = rot * Vec3(0, 0, -1.0f); sound_position.Orientation.X = forward.x; sound_position.Orientation.Y = forward.y; sound_position.Orientation.Z = forward.z; AK::SoundEngine::SetPosition(transform->entity_id, sound_position); } } AK::SoundEngine::RenderAudio(); }
void exchange_dlnode(pdlnode pos, dlist dl) { if (is_last(pos, dl)) { print_error("can not exchange a last node!\n"); exit(-1); } pdlnode ptmp = find_previous_by_pointer(pos, dl); if (ptmp == NULL) { print_error("can not find that node's previous!"); exit(-1); } ptmp->next = pos->next; pos->next->prev = ptmp; pos->next = ptmp->next->next; ptmp->next->next = pos; pos->next->prev = pos; pos->prev = ptmp->next; }
int main() { list_t l = make_list(); char _[] = "deadbeef"; char *msg = _; for (;*msg != '\0';msg++) { insert(*msg, header(l)); } traversal(print_node, l); sep; printf("%c", find('a', l)->e); sep; insert('v', find('a', l)); traversal(print_node, l); sep; traversal(print_node, pop('e', l)); sep; destory(l); printf("%d %d", is_empty(l), is_last(header(l))); sep; return 0; }
methodOop last_method_oop() { assert(is_last(), ""); return _last_method(); }
methodHandle last_method() { assert(is_last(), ""); return _last_method; }
bool sequence_formatter::is_single() const { return is_first() && is_last(); }
void generate_literal_chain(ast::tree& ast, ast::node* root, formatter& output) { plnnrc_assert(ast::is_op_not(root) || ast::is_term_call(root) || is_atom(root) || is_comparison_op(root)); ast::node* atom = root; if (ast::is_op_not(root)) { atom = root->first_child; } if (ast::is_comparison_op(atom)) { generate_literal_chain_comparison(ast, root, atom, output); return; } if (ast::is_term_call(atom)) { generate_literal_chain_call_term(ast, root, atom, output); return; } const char* atom_id = atom->s_expr->token; int atom_index = ast::annotation<ast::atom_ann>(atom)->index; if (ast::is_op_not(root) && all_unbound(atom)) { output.writeln("if (!tuple_list::head<%i_tuple>(world.atoms[atom_%i]))", atom_id, atom_id); { scope s(output); if (root->next_sibling) { generate_literal_chain(ast, root->next_sibling, output); } else { output.writeln("PLNNR_COROUTINE_YIELD(state);"); } } } else if (ast::is_op_not(root) && all_bound(atom)) { output.writeln("for (state.%i_%d = tuple_list::head<%i_tuple>(world.atoms[atom_%i]); state.%i_%d != 0; state.%i_%d = state.%i_%d->next)", atom_id, atom_index, atom_id, atom_id, atom_id, atom_index, atom_id, atom_index, atom_id, atom_index); { scope s(output); int atom_param_index = 0; for (ast::node* term = atom->first_child; term != 0; term = term->next_sibling) { if (ast::is_term_variable(term)) { int var_index = ast::annotation<ast::term_ann>(term)->var_index; output.writeln("if (state.%i_%d->_%d == state._%d)", atom_id, atom_index, atom_param_index, var_index); { scope s(output, !is_last(term)); output.writeln("break;"); } } if (ast::is_term_call(term)) { paste_precondition_function_call paste(term, "state._"); output.writeln("if (state.%i_%d->_%d == world.%p)", atom_id, atom_index, atom_param_index, &paste); { scope s(output, !is_last(term)); output.writeln("break;"); } } ++atom_param_index; } } output.writeln("if (state.%i_%d == 0)", atom_id, atom_index); { scope s(output, is_first(root)); if (root->next_sibling) { generate_literal_chain(ast, root->next_sibling, output); } else { output.writeln("PLNNR_COROUTINE_YIELD(state);"); } } } else { output.writeln("for (state.%i_%d = tuple_list::head<%i_tuple>(world.atoms[atom_%i]); state.%i_%d != 0; state.%i_%d = state.%i_%d->next)", atom_id, atom_index, atom_id, atom_id, atom_id, atom_index, atom_id, atom_index, atom_id, atom_index); { scope s(output, is_first(root)); const char* comparison_op = "!="; if (ast::is_op_not(root)) { comparison_op = "=="; } int atom_param_index = 0; for (ast::node* term = atom->first_child; term != 0; term = term->next_sibling) { if (ast::is_term_variable(term) && definition(term)) { int var_index = ast::annotation<ast::term_ann>(term)->var_index; output.writeln("if (state.%i_%d->_%d %s state._%d)", atom_id, atom_index, atom_param_index, comparison_op, var_index); { scope s(output); output.writeln("continue;"); } } if (ast::is_term_call(term)) { paste_precondition_function_call paste(term, "state._"); output.writeln("if (state.%i_%d->_%d %s world.%p)", atom_id, atom_index, atom_param_index, comparison_op, &paste); { scope s(output); output.writeln("continue;"); } } ++atom_param_index; } atom_param_index = 0; for (ast::node* term = atom->first_child; term != 0; term = term->next_sibling) { if (ast::is_term_variable(term) && !definition(term)) { int var_index = ast::annotation<ast::term_ann>(term)->var_index; output.writeln("state._%d = state.%i_%d->_%d;", var_index, atom_id, atom_index, atom_param_index); output.newline(); } ++atom_param_index; } if (root->next_sibling) { generate_literal_chain(ast, root->next_sibling, output); } else { output.writeln("PLNNR_COROUTINE_YIELD(state);"); } } } }
void next(TRAPS) { assert(!is_last(), ""); set_method_handle(MethodHandle_vmtarget_oop(), THREAD); }
Bytecodes::Code last_invoke_code() { assert(is_last(), ""); return _last_invoke; }