// 8bit value (poke address value) Item *poke(List *expression) { uint16_t addr = eval_as_uint16(second(expression)); if (third(expression)) { *((uint8_t *)(addr)) = eval_as_uint8(third(expression)); } return peek(expression); }
void G2oEdgeSE3:: linearizeOplus() { const SE3 & T_21 = _measurement; SE3 I; const Vector6d & d = _error; _jacobianOplusXi = third(T_21, d); _jacobianOplusXj = -third(I, -d); }
int main(int argc, const char *argv[]) { Node first(10, 20); Node second(30, 40); Node third(100, 50); Node forth(100, 33); first.setNext(&second); second.setNext(&third); std::cout << first.getTail()->getValue() << std::endl; std::cout << second.getTail()->getValue() << std::endl; std::cout << third.getTail()->getValue() << std::endl; Hash h; h.put(10,20); h.put(30,40); h.put(10,30); h.put(30,50); std::cout << h.get(10,20) << std::endl; std::cout << h.get(11,20) << std::endl; std::cout << h.get(10,30) << std::endl; std::cout << h.get(31,100) << std::endl; std::cout << h.get(30,40) << std::endl; std::cout << h.get(30,50) << std::endl; return 0; }
void ListExample::ExampleConstructor(void) { // constructors used in the same order as described above: list<int> first; // empty list of ints // khởi tạo một danh sách trống cout << "The contents of first are: "; PrintListInt(first); list<int> second (4,100); // four ints with value 100 // khởi tạo 4 số int với giá trị 100 cout << "The contents of second are: "; PrintListInt(second); list<int> third (second.begin(),second.end()); // iterating through second // khởi tạo từ một danh sách khác cout << "The contents of third are: "; PrintListInt(third); list<int> fourth (third); // a copy of third // sao chép danh sách thứ 3 cout << "The contents of fourth are: "; PrintListInt(fourth); // the iterator constructor can also be used to construct from arrays: // sử dụng con trỏ khởi tạo từ một mảng có sẵn int myints[] = {16,2,77,29}; list<int> fifth (myints, myints + sizeof(myints) / sizeof(int) ); cout << "The contents of fifth are: "; PrintListInt(fifth); }
int main () { //using the connstructors in order //iterating through the lists std::list<int> first; // empty list of ints std::list<int> second (4,100); // (4,50) 4, four ints with value 50 std::list<int> third (second.begin(),second.end()); // iterating through second std::list<int> fourth (third); // fourth int is a copy of third // the iterator constructors: int myints[] = {16,20,40,19}; int *it;// declaring algorithm std::list<int> fifth (myints, myints + sizeof(myints) / sizeof(int) ); std::cout << "The contents of fifth are: "; for (std::list<int>::iterator it = fifth.begin(); it != fifth.end(); it++) std::cout << *it << ' '; std::cout << '\n'; //using algorithm find it = std::find (myints, myints+6, 20); if (it != myints+6) std::cout << "Element found in myints: " << *it << '\n'; else std::cout << "Element not found in myints\n"; return 0; }
int main( int argc, char** argv ) { QApplication app( argc, argv ); mutex = new QMutex; QHBox box( 0, 0, TRUE ); QLabel label( &box ); label.setAlignment(Qt::AlignCenter); label.setMinimumSize(400, 300); GUIThread first( &label, "<b>Ping</b>" ); GUIThread second( &label, "<i>Pong</i>" ); WaitThread third(&first, &second, &label); app.setMainWidget( &box ); box.setCaption("Qt Example - GUI Threads"); box.show(); first.start(); second.start(); third.start(); int r = app.exec(); delete mutex; return r; }
void instrn() { s=18;sp=6; w9=w8=w4=w6=w5=w2=w3=w7=w0=wk=we=wf=wj=wl=wp=wr=ws=s/2;//1/2 w1=wi=s/4; wg=wc=wh=wn=wb=wu=wt=wv=wx=wy=2*s/3;//2/3 ww=wm=wa=wd=wo=wq=wz=3*s/4;//3/4 h=s;//1 xnxt=-190;ynxt=320; how(); //////////////// s=18;sp=6; w9=w8=w4=w6=w5=w2=w3=w7=w0=wk=we=wf=wj=wl=wp=wr=ws=s/2;//1/2 w1=wi=s/4; wg=wc=wh=wn=wb=wu=wt=wv=wx=wy=2*s/3;//2/3 ww=wm=wa=wd=wo=wq=wz=3*s/4;//3/4 h=s;//1 xnxt=-190;ynxt-=4*s; first(); xnxt=-190;ynxt-=2*s; second(); xnxt=-190;ynxt-=2*s; third(); xnxt=-190;ynxt-=2*s; fourth(); }
obj eval_function(ref lt, rel rt) {//lt ÇÉXÉ^ÉbÉNêœÇ›Ç… if(type(lt)== tInternalFn) goto ci; if(type(lt)!=tClosure) {print((obj)lt); assert(0);} { list ll = seek_lamb(ul(lt), rt); if(ll && type(first(ll))==tInternalFn) { lt = first(ll); goto ci; } if(! ll) error("no appropriate function."); push(env); obj vars = Assoc(); env = op(vars, retain(third(ll))); bind_vars(&vars, first(ll), rt); release(rt); obj rr = exec(second(ll)); release(env); env = pop(&is); return strip_return(rr); } ci: try { obj rr=(ufn(lt))(rt); release(rt); return rr; } catch(eval_error){ error("not defined for that value."); return nil; } }
int main () { std::set<int> first; // empty set of ints int myints[]= {10,20,30,40,50}; std::set<int> second (myints,myints+5); // range //find and delete std::set<int>::iterator it; it = second.find (50); second.erase (it); //insert second.insert(1); std::set<int> third (second); // a copy of second std::set<int> fourth (second.begin(), second.end()); // iterator ctor. bool(*fn_pt)(int,int) = fncomp; std::set<int,bool(*)(int,int)> sixth (fn_pt); // function pointer as Compare std::set<int,classcomp> fifth(myints,myints+5); // class as Compare std::set<int,classcomp>::iterator iter = fifth.begin(); while(iter != fifth.end()) { std::cout<<*iter<<std::endl; iter++; } return 0; }
// (config <id> <value> <persist> Item *config(List *expression) { Item *value_item = third(expression); if (value_item) { uint8_t item = eval_as_uint8(second(expression)); uint8_t value = eval_as_uint8(value_item); uint8_t permanent = eval_as_uint8(fourth(expression)); if (item < NUM_BOOLCONFIG) { // bool set_bool_value(&bit_config, item, value); if (permanent) { uint8_t stored_config = eeprom_read_byte(CONFIG_START_ADDR); set_bool_value(&stored_config, item, value); eeprom_update_byte(CONFIG_START_ADDR, stored_config); } } else { item -= NUM_BOOLCONFIG; if (item < NUM_BYTECONFIG) { // byte byte_config[item] = value; if (permanent) { eeprom_update_byte(BYTE_CONFIG_START_ADDR, value); } } } } return 0; }
uintptr_t sml_gettime(uintptr_t pair) { time_t t; mkTagTripleML(pair); t = time(NULL); if (t == (time_t) -1) { third(pair) = convertIntToML(-1); return pair; } first(pair) = convertIntToML(t % 1000000000); second(pair) = convertIntToML(t / 1000000000); third(pair) = convertIntToML(0); return pair; }
HttpHeader::ResultEnum HttpHeader::ProcessFirstLine(std::string &line) { log_trace(); // Parse the first element of the line size_t endPos1 = line.find(' '); if (endPos1 == std::string::npos) { log_warn("Bad first line: " << line); return HEADER_FAULT; } std::string first(line, 0, endPos1); // Parse the second element of the line size_t endPos2 = line.find(' ', endPos1+1); if (endPos2 == std::string::npos) { log_warn("Bad first line: " << line); return HEADER_FAULT; } std::string second(line, endPos1+1, endPos2-endPos1-1); // Parse the third element of the line std::string third(line, endPos2+1, std::string::npos); log_debug("first=" << first << ", second=" << second << ",third=" << third); return ProcessFirstLine(first, second, third); }
Item *led(List *expression) { uint8_t led = eval_as_string(second(expression))[0] == 'R' ? 0 : 1; Item *value = third(expression); led_mode(led, value ? LEDMANUAL : LEDSTATE_OFF); set_out(leds[led], eval_as_uint8(value)); return 0; }
uintptr_t REG_POLY_FUN_HDR(sml_getgrnam, uintptr_t triple, Region memberListR, Region memberR, String nameML, size_t s, uintptr_t exn) { uintptr_t res; uintptr_t *list, *pair; char *b; struct group gbuf, *gbuf2; char **members; char *name = &(nameML->data); mkTagTripleML(triple); s = convertIntToC(s) + 1; b = (char *) malloc(s); if (!b) { res = errno; third(triple) = res; return triple; } res = getgrnam_r(name, &gbuf, b, s-1, &gbuf2); third(triple) = res; if (res) { free(b); return triple; } if (!gbuf2) { free(b); raise_exn(exn); } first(triple) = convertIntToML(gbuf2->gr_gid); members = gbuf2->gr_mem; makeNIL(list); while (*members) { allocPairML(memberListR, pair); first(pair) = (uintptr_t) REG_POLY_CALL(convertStringToML, memberR, *members); second(pair) = (uintptr_t) list; makeCONS(pair, list); members++; } free(b); second(triple) = (uintptr_t) list; return triple; }
void practice_priority_queue() { int myints[]={10,60,50,20}; std::priority_queue<int> second (myints,myints+4); cout << second.top() << endl; std::priority_queue<int, std::vector<int>, std::greater<int> > third (myints,myints+4); cout << third.top() << endl; }
int main () { //!NOTE: should work perfectly now. ExampleOfUsingClassComp(); // empty set that can contain ints std::set<int> first; int myints[]= {40,50,10,30,20}; std::set<int> second (myints,myints+5); // This should be printed in order; set has an internal // comparator that 'looks' and 'works' like those given above. //!NOTE: We replace the for loop below with 'PrintSetContents' // for(std::set<int>::const_iterator cit = second.begin(); // cit != second.end(); cit++) // std::cout << (*cit) << " "; // std::cout << std::endl; PrintSetContents(second.begin(), second.end()); // a copy of second std::set<int> third (second); // Constructor that takes iterators std::set<int> fourth (second.begin(), second.end()); // class/struct as Compare object std::set<int,classcomp<int> > fifth; // function pointer as Compare method bool(*fn_pt)(int,int) = fncomp; std::set<int,bool(*)(int,int)> sixth (second.begin(), second.end(), fn_pt); // Should print elements reversed for(std::set<int,bool(*)(int,int)>::iterator it = sixth.begin(); it != sixth.end(); it++) std::cout << (*it) << " "; std::cout << std::endl; char str[] = "For... He's a Jolly Good Fellow!.." "For He's a Jolly Good Fellow!..." "And so say all of us, and so say all of us." "I WISH TO WISH THE WISH YOU WISH TO WISH," "BUT IF YOU WISH THE WISH THE WITCH WISHES, " "I WON'T WISH THE WISH YOU WISH TO WISH." "@#^&@)*(^%$#!$#&(*#!@$#!~~`1;/.,''`)"; std::set<char> chara(str, str + strlen(str)); //!NOTE: We replace the for loop below with 'PrintSetContents' // for(std::set<char>::const_iterator cch = chara.begin(); // cch != chara.end(); cch++) // std::cout << (*cch); // std::cout << std::endl; //!TODO: comment out the line below, compile & run. Note what // happens. PrintSetContents(chara.begin(), chara.end()); return 0; }
int main(int argc, char const *argv[]) { Employee first; Employee second("second"); Employee third(second); first.display(); second.display(); third.display(); return 0; }
// (pin_mode <pinid> IN|HIGH|OUT|PWM|ADC [value]) Item *lio_pinmode(List *expression) { const uint8_t pinid = eval_as_uint8(second(expression)); pin_mode(pinid, eval_as_string(third(expression))); Item *value = fourth(expression); if (value) { set_pin_value(pinid, eval_as_uint16(value)); } return 0; }
void testConstructor() { FuncTrace(); ConstructorTest first("First"); ConstructorTest second(first); second = first; second = ConstructorTest("Tmp1"); cout << "Now test move constructor" << endl; ConstructorTest third(ConstructorTest("Tmp2")); third.setName("Third"); third.printName(); }
OBJECT_PTR return_from_metacont_fn(metacont_closure_t *mcls, reg_closure_t *cls) { OBJECT_PTR exp = mcls->closed_vals[0]; OBJECT_PTR fn_exp = second(exp); OBJECT_PTR ret_exp = third(exp); metacont_closure_t *mcls1 = mcps(fn_exp); return mcls1->mfn(mcls1, create_reg_ret_from_closure1(ret_exp, cls)); }
//----------------------main--------------------- task main() { bool flamingo = true; bool blownUp = true; while(flamingo == blownUp) { first(); second(); third(); } }
// (vector-set! x index e) Cell* op_vecset(Scheme *sc) { if (is_immutable(first(sc->args))) { return error_helper(sc, "vector-set!: unable to alter immutable vector:", first(sc->args)); } int index = long_value(second(sc->args)); if (index < 0 || index >= long_value(first(sc->args))) { return error_helper(sc, "vector-set!: out of bounds:", second(sc->args)); } set_vector_item(first(sc->args), index, third(sc->args)); return s_return_helper(sc, first(sc->args)); }
TEST(AffineTransform, ScaleFloatSize) { WebCore::AffineTransform test(6.0, 5.0, 4.0, 3.0, 2.0, 1.0); testValueConstruction(test); WebCore::FloatSize first(1.0f, 2.0f); test.scale(first); EXPECT_DOUBLE_EQ(6.0, test.a()); EXPECT_DOUBLE_EQ(5.0, test.b()); EXPECT_DOUBLE_EQ(8.0, test.c()); EXPECT_DOUBLE_EQ(6.0, test.d()); EXPECT_DOUBLE_EQ(2.0, test.e()); EXPECT_DOUBLE_EQ(1.0, test.f()); WebCore::FloatSize second(1.0f, 0.5f); test.scale(second); testValueConstruction(test); WebCore::FloatSize third(2.0f, 1.0f); test.scale(third); EXPECT_DOUBLE_EQ(12.0, test.a()); EXPECT_DOUBLE_EQ(10.0, test.b()); EXPECT_DOUBLE_EQ(4.0, test.c()); EXPECT_DOUBLE_EQ(3.0, test.d()); EXPECT_DOUBLE_EQ(2.0, test.e()); EXPECT_DOUBLE_EQ(1.0, test.f()); WebCore::FloatSize fourth(0.5f, 1.0f); test.scale(fourth); testValueConstruction(test); WebCore::FloatSize fifth(0.5f, 2.0f); test.scale(fifth); EXPECT_DOUBLE_EQ(3.0, test.a()); EXPECT_DOUBLE_EQ(2.5, test.b()); EXPECT_DOUBLE_EQ(8.0, test.c()); EXPECT_DOUBLE_EQ(6.0, test.d()); EXPECT_DOUBLE_EQ(2.0, test.e()); EXPECT_DOUBLE_EQ(1.0, test.f()); }
int RLEChunk::flatten(const math::Vector<3, int>& vector) const { math::Dimension first(m_compression.getFirst()), second(m_compression.getSecond()), third(m_compression.getThird()); return vector[first] + vector[second] * extract(first, SEGMENT_WIDTH, SEGMENT_HEIGHT, SEGMENT_DEPTH) + vector[third] * extract(first, SEGMENT_WIDTH, SEGMENT_HEIGHT, SEGMENT_DEPTH) * extract(second, SEGMENT_WIDTH, SEGMENT_HEIGHT, SEGMENT_DEPTH); };
//Menu algoritmos de repetiçao void load_alg_loop_while (void) { do { printf("\n\t../Loop Algorithms - While \n"); printf("\nPlease choose one of the following options:\n"); printf("_____________________________________________________\n\n"); printf("1......................................................\n"); printf("2......................................................\n"); printf("3......................................................\n"); printf("4......................................................\n"); printf("5......................................................\n"); printf("6......................................................\n"); printf("7......................................................\n"); printf("8.Return\n"); printf("9.Exit\n"); printf("_____________________________________________________\n\n"); printf("\t\tEnter Choice: "); scanf("%u", &choice); system("clear"); switch (choice) { case 1: first(); break; case 2: second(); break; case 3: third(); break; case 4: fourth(); break; case 5: fifth(); break; case 6: sixth(); break; case 7: seventh(); break; case 8:load_alg_loop(); break; case 9: printf("\nQuitting program!\n"); exit(FLAG); break; default: printf("\nInvalid choice!\n"); break; } } while (choice != 9); }
Item *fmt(List *expression) { char *fmt = (char *)eval_as_string(second(expression)); uint16_t fmt_size = strlen(fmt)+1; uint16_t value = eval_as_uint16(third(expression)); // move the format to the back of our fixed string buffer char *moved_fmt = str_buf+STRBUFSIZE-fmt_size; strcpy(moved_fmt, fmt); // and write the formatted string to the buffer snprintf(str_buf, STRBUFSIZE-fmt_size, moved_fmt, value); return string_retval(); }
/********************************************************************** * print_matrix * * Print the best guesses out of the match rating matrix. **********************************************************************/ void print_matrix(MATRIX rating_matrix) { int x; int dimension; int spread; CHOICES rating; cprintf ("Ratings Matrix (top choices)\n"); dimension = matrix_dimension (rating_matrix); /* Do each diagonal */ for (spread = 0; spread < dimension; spread++) { /* For each spot */ for (x = 0; x < dimension - spread; x++) { /* Process one square */ rating = matrix_get (rating_matrix, x, x + spread); if (rating != NOT_CLASSIFIED) { cprintf ("\t[%d,%d] : ", x, x + spread); if (first_node (rating)) cprintf ("%-10s%4.0f\t|\t", class_string (first_node (rating)), class_probability (first_node (rating))); if (second_node (rating)) cprintf ("%-10s%4.0f\t|\t", class_string (second_node (rating)), class_probability (second_node (rating))); if (third (rating)) cprintf ("%-10s%4.0f\n", class_string (third (rating)), class_probability (third (rating))); else new_line(); } } } }
int main () { int myints[]= {10,60,50,20}; std::priority_queue<int> first; std::priority_queue<int> second (myints,myints+4); std::priority_queue<int, std::vector<int>, std::greater<int> > third (myints,myints+4); // using mycomparison: typedef std::priority_queue<int,std::vector<int>,mycomparison> mypq_type; mypq_type fourth; // less-than comparison mypq_type fifth (mycomparison(true)); // greater-than comparison return 0; }
int main(){ std::vector< std::tuple<int, int> > inputVector; std::tuple<int,int> first (7, 160); std::tuple<int,int> second (3, 90); std::tuple<int,int> third (2, 15); inputVector.push_back(first); inputVector.push_back(second); inputVector.push_back(third); int maxAmount = maxDuffelBagValue(inputVector, 22); std::cout << maxAmount; }
Quaternion Quaternion::Slerp(const Quaternion &first, const Quaternion &second, float interpolationCoefficient) { float dot = first.Dot(second); if(dot > s_quaternionDotTolerance) return Lerp(first, second, interpolationCoefficient); dot = Clamp(dot, -1.0f, 1.0f); float theta = acosf(dot) * interpolationCoefficient; Quaternion third(second - first * dot); third.NormalizeThis(); return first * cosf(theta) + third * sinf(theta); }