/** read /nframes/ from the attached track into /buf/ */ void Playback_DS::read_block ( sample_t *buf, nframes_t nframes ) { THREAD_ASSERT( Playback ); memset( buf, 0, nframes * sizeof( sample_t ) * channels() ); /* stupid chicken/egg */ if ( ! timeline ) return; // printf( "IO: attempting to read block @ %lu\n", _frame ); if ( ! sequence() ) { /* FIXME: what to do here? */ // _frame += _nframes; return; } timeline->rdlock(); /* FIXME: how does this work if _delay is not a multiple of bufsize? */ if ( _frame >= _delay ) { if ( ! sequence()->play( buf, _frame - _delay, nframes, channels() ) ) WARNING( "Programming error?" ); } _frame += nframes; timeline->unlock(); }
/** read /nframes/ from the attached track into /buf/ */ void Playback_DS::read_block ( sample_t *buf, nframes_t nframes ) { THREAD_ASSERT( Playback ); memset( buf, 0, nframes * sizeof( sample_t ) * channels() ); // printf( "IO: attempting to read block @ %lu\n", _frame ); if ( !timeline ) return; while ( timeline->sequence_lock.tryrdlock() ) { if ( _terminate ) return; usleep( 1000 * 10 ); } if ( sequence() ) { if ( ! sequence()->play( buf, _frame + _undelay, nframes, channels() ) ) WARNING( "Programming error?" ); _frame += nframes; } timeline->sequence_lock.unlock(); }
int main() { for (auto i : sequence(-5, +5)) { std::cout << i << " "; } std::cout << std::endl << std::endl; for (auto i : sequence(+5, -5, -1)) { std::cout << i << " "; } std::cout << std::endl << std::endl; std::vector<int> v{1, 2, 3, 4, 5, 6}; for (auto i : sequence(0, v.size())) { std::cout << "Element " << i << ": " << v[i] << std::endl; } std::cout << std::endl; for (auto i : sequence(0, v.size(), 2)) { std::cout << "Element " << i << ": " << v[i] << std::endl; } }
QNFA* context(const QString& start, const QString& stop, const QString&, int action, QNFA **handler, bool cs) { QNFA *nfa, *end, *beg = sequence(start.constData(), start.length(), &end, cs); nfa = new QNFA; nfa->type = ContextBegin; nfa->actionid = action; nfa->out.branch = new QNFABranch; if ( handler ) *handler = nfa; //else // qDebug("no handler set [0x%x]", nfa); end->out.next = nfa; end = nfa; QNFA *endmark, *begendmark = sequence(stop.constData(), stop.length(), &endmark, cs); nfa = new QNFA; nfa->type = ContextEnd; nfa->actionid = action; endmark->out.next = nfa; //end->out->branch->append(endmark); addNFA(end, begendmark); return beg; }
int Line::GetSeg(double y) { for(unsigned i = 0; i < size() - 1; i += degree) if(sequence(double(at(i).y),y,double(at(i+degree).y)) || sequence(double(at(i+degree).y),y,double(at(i).y))) return i; return -1; }
void Track::sequence ( Audio_Sequence * t ) { if ( sequence() == t ) { DMESSAGE( "Attempt to set sequence twice" ); return; } t->track( this ); if ( sequence() ) add( sequence() ); _sequence = t; /* insert following the annotation pack */ pack->insert( *t, 1 ); /* hide the take header */ t->child(0)->hide(); t->color( FL_GRAY ); t->labeltype( FL_NO_LABEL ); adjust_size(); }
void KeySequence::saveSettings(QSettings& settings) const { settings.beginWriteArray("keys"); for (int i = 0; i < sequence().size(); i++) { settings.setArrayIndex(i); settings.setValue("key", sequence()[i]); } settings.endArray(); }
void NameParser::Item::calc_padding (size_t maxval) { for (size_t i = 0; i < sequence().size(); i++) { assert (sequence() [i] >= 0); if (maxval < (size_t) sequence() [i]) maxval = sequence() [i]; } seq_length = 1; for (size_t num = 10; maxval >= num; num *= 10) seq_length += 1; }
void test() { try { throw; } catch (xa& a) { sequence( 0, __LINE__ ); } catch (xb& b) { sequence( 1, __LINE__ ); } catch (...) { sequence( 2, __LINE__ ); } }
int sequence(int n, int length) { length++; if (n==1) { return length; } if (n%2==0) { return sequence(n/2, length); } else { return sequence(n*3+1, length); } }
int main( int argc, char* argv [ ] ) { // In order to compile this, you need C ++ 11. If it doesn't compile, then // you can replace it by a sequence of push_backs. sequence seq({ rotation( cube::left ), rotation( cube::left, 1, 3 ), rotation( cube::up ), rotation( cube::left, -1, 3 ), rotation( cube::up, -1, 1 ), rotation( cube::left, -1, 1 ), rotation( cube::up, 1, 1 ), rotation( cube::left, 1, 3 ), rotation( cube::up, -1, 1 ), rotation( cube::left, -1, 3 ) }); std::cout << seq << "\n"; std::cout << repeat( seq, 5 ) << "\n"; sequence corners = repeat( sequence( { { cube::right }, { cube::down, -1 }, { cube::right, -1 }, { cube::down } } ), 2 ) * sequence( { rotation( cube::up ) } ) * repeat( sequence( { { cube::down, -1 }, { cube::right }, { cube::down }, { cube::right, -1 } } ), 2 ) * sequence( { rotation( cube::up, -1 ) } ); std::cout << corners << "\n"; cube c(4); // Open an SFML window. Switch it on, if you want to use // graphics. // sf::Window // wind( sf::VideoMode( 1024, 500, 32 ), "Rubik Cube" ); char q = ' '; while( q != 'q' ) { std::cout << c << "\n"; // plot(c); // wind. Display( ); // Plotting is nicer of course, but you need graphics. c. rotate( corners ); q = getchar( ); } return 0; }
void KeySequence::loadSettings(QSettings& settings) { sequence().clear(); int num = settings.beginReadArray("keys"); for (int i = 0; i < num; i++) { settings.setArrayIndex(i); sequence().append(settings.value("key", 0).toInt()); } settings.endArray(); setModifiers(0); setValid(true); }
void SequenceComponent::render(QPaintDevice * target, const QPoint & targetOffset, const QRect & sourceRect) { if (sequence()) { QString sequenceStr(sequence()->toString()); QRect rect(sourceRect.left(), 0, sourceRect.width(), this->height()); QPainter painter(target); painter.translate(targetOffset); painter.translate(-rect.topLeft()); painter.setClipRect(rect); // Find cell sizes double unitSize = alignmentView()->unitSizeF(); int firstUnit = alignmentIndexAt(rect.topLeft()); int lastUnit = alignmentIndexAt(rect.topRight()); if (lastUnit >= sequenceStr.size()) { lastUnit = sequenceStr.size() - 1; } int unitLeft = rectAt(firstUnit).left(); painter.save(); if (unitSize < 1) { painter.setRenderHint(QPainter::SmoothPixmapTransform); } painter.scale(unitSize, (double) height()); painter.drawPixmap(0, 0, d->background); painter.restore(); if (unitSize > 8) { // Set font to be a little smaller than usual painter.setPen(Qt::NoPen); QFont font = painter.font(); font.setPixelSize((int) (unitSize * 0.6)); painter.setFont(font); painter.setPen(Qt::NoPen); for (int res = firstUnit; res <= lastUnit && res < sequenceStr.size(); ++res) { QColor col = Qt::red; painter.drawPixmap(unitLeft, 0, d->pixmapFactory().pixmap(sequenceStr[res], (int) unitSize, col)); // Skip to next position unitLeft += unitSize; } } } }
Track::~Track ( ) { Loggable::block_start(); /* must destroy sequences first to preserve proper log order */ takes->clear(); control->clear(); annotation->clear(); delete sequence(); takes = NULL; control = NULL; annotation = NULL; log_destroy(); /* ensure that soloing accounting is performed */ solo( false ); timeline->remove_track( this ); /* give up our ports */ configure_inputs( 0 ); configure_outputs( 0 ); _sequence = NULL; if ( _name ) free( _name ); Loggable::block_end(); }
int Cursor_Region::handle ( int m ) { Logger _log( this ); if ( m == FL_PUSH ) { if ( test_press( FL_BUTTON3 ) ) { char *s = fl_text_edit( "Cursor text:", "&Save", label() ); if ( s ) label( s ); free( s ); return 0; } } int r = Sequence_Region::handle( m ); if ( m == FL_RELEASE ) { sequence()->sort(); timeline->redraw(); } return r; }
/* * Decode a BER encoded DistinguishedName */ void X509_DN::decode_from(BER_Decoder& source) { MemoryVector<byte> bits; source.start_cons(SEQUENCE) .raw_bytes(bits) .end_cons(); BER_Decoder sequence(bits); while(sequence.more_items()) { BER_Decoder rdn = sequence.start_cons(SET); while(rdn.more_items()) { OID oid; ASN1_String str; rdn.start_cons(SEQUENCE) .decode(oid) .decode(str) .verify_end() .end_cons(); add_attribute(oid, str.value()); } } dn_bits = bits; }
bool TransportSendBuffer::resend(const SequenceRange& range) { ACE_GUARD_RETURN( TransportSendStrategy::LockType, guard, this->strategy_->lock_, false); for (SequenceNumber sequence(range.first); sequence <= range.second; ++sequence) { // Re-send requested sample if still buffered; missing samples // will be scored against the given DisjointSequence: BufferMap::iterator it(this->buffers_.find(sequence)); if (it != this->buffers_.end()) { if (OpenDDS::DCPS::Transport_debug_level >= 4) { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) TransportSendBuffer::resend() - ") ACE_TEXT("resending PDU: 0x%x, (0x%x,0x%x)\n"), sequence.getValue(), it->second.first, it->second.second)); } resend(it->second); } } // Have we resent all requested data? return range.first >= low() && range.second <= high(); }
typename RangeT::size_type List< RangeT, TraitsT, ContainerT >::erase(const RangeT& value) { if ( value.end() > limit() ) { // throw ListException( value, limit() ); CString msg; msg.Format( _T( "ListError - erase - size: %u - limit: %I64u - sum: %I64u - " ) _T( "Range - begin: %I64i - end: %I64u" ), size(), limit(), Traits::length_sum(), value.begin(), value.end() ); theApp.Message( MSG_ERROR, msg ); return 0; } if ( value.size() == 0 ) return 0; iterator_pair sequence( equal_range( value ) ); if ( sequence.first == sequence.second ) return 0; const range_type front( min( sequence.first->begin(), value.begin() ), value.begin(), value.value() ); const range_type back( value.end(), max( ( --sequence.second )->end(), value.end() ), value.value() ); range_size_type sum = 0; for ( ++sequence.second; sequence.first != sequence.second; ) sum += erase( sequence.first++ ); sum -= insert( sequence.second, front ); sum -= insert( sequence.second, back ); return sum; }
sequence<BidiIter> &operator |=(sequence<BidiIter> that) { BOOST_ASSERT(!this->empty()); BOOST_ASSERT(0 != this->alternates_); // Keep track of width and purity if(this->alternates_->empty()) { this->width_ = that.width_; this->pure_ = that.pure_; } else { this->width_ |= that.width_; this->pure_ = this->pure_ && that.pure_; } // through the wonders of reference counting, all alternates_ can share an end_alternate if(!this->alt_end_xpr_) { this->alt_end_xpr_ = new alt_end_xpr_type; } // terminate each alternate with an alternate_end_matcher that += sequence(this->alt_end_xpr_); this->alternates_->push_back(that.head_); this->set_quant_(); return *this; }
void Animator::play(const std::string& sequenceName, bool bLoop, bool bForce) { m_bFinished = false; const AnimationSequence* oldSeq = m_sequence; m_sequence = &sequence(sequenceName); m_curSequenceName = sequenceName; if (m_sequence->duration == 0) { m_bFinished = true; m_bPlay = false; m_frame = 0; } else if (m_sequence != oldSeq || bForce) { m_frame = 0; m_scale = 1; m_bPlay = true; onFrame(frame()); } m_bLoop = bLoop; }
/** split region at absolute frame /where/. due to inheritance issues, * the copy must be made in the derived classed and passed in */ void Sequence_Region::split ( Sequence_Region * copy, nframes_t where ) { trim_right( where ); copy->trim_left( where ); sequence()->add( copy ); }
int main(void) { int num[10] = { 0 }; int times; printf("請輸入數字個數:"); scanf("%d", ×); for (int i = 1; i <= times; i++) { printf("請輸入數字:"); scanf("%d", &num[i - 1]); } sequence(num, times); dumparray(num, times); for (int i = 1; i < times; i++) { if (i == 1) { perm(num, i, times, times); } else { while (num[i - 1] == num[0]) { i++; } perm(num, i, times, times); } } }
void ImageLoader::lookInFolder() { std::stringstream ss; ss << m_directoryPath; cv::VideoCapture sequence( ss.str() + "\\%03d.jpg" ); if( !sequence.isOpened() ) { std::cerr << "Failed to open image sequence!\n" << std::endl; m_isValid = false; } // go thorough all images to count them int count = -1; for( ; ; ) { cv::Mat image; sequence >> image; if( image.empty() ) { std::cout << "End of Sequence - found " << count + 1 << " files" << std::endl; break; } ++count; } MAX_INDEX = count; }
RepeatPtr repeat(cocos2d::Node *target, unsigned int times, const std::vector<IFiniteTimePtr> &tweens) { auto s = sequence(target, tweens); auto r = Repeat::create(target, times, std::move(s)); return std::move(r); }
void load_data(std::vector<std::string>& data, std::string file) { data.reserve(1000000); std::fstream in; in.open(file.c_str(), std::fstream::in); if (!in.is_open()) { std::cerr << "[error] File " << file << " can't be opened." << std::endl; exit(1); } std::cerr << "Begin loading reads ..." << std::endl; char c_line[MAX_STR]; while(!in.eof()) { in.getline(c_line, MAX_STR); if (c_line[0] == '>') { in.getline(c_line, MAX_STR); std::string sequence(c_line); data.push_back(sequence); } } std::cerr << data.size() <<" reads have been loaded !" << std::endl; in.close(); }
/** * @see problem::base constructors. */ gtoc_1::gtoc_1():base(8),Delta_V(8),rp(6),t(8) { // Set bounds. const double lb[8] = {3000,14,14,14,14,100,366,300}; const double ub[8] = {10000,2000,2000,2000,2000,9000,9000,9000}; set_bounds(lb,lb+8,ub,ub+8); //Defining the problem data up the problem parameters problem.type = asteroid_impact; problem.mass = 1500.0; // Satellite initial mass [Kg] problem.Isp = 2500.0; // Satellite specific impulse [s] problem.DVlaunch = 2.5; // Launcher DV in km/s int sequence_[8] = {3,2,3,2,3,5,6,10}; // sequence of planets std::vector<int> sequence(8); problem.sequence.insert(problem.sequence.begin(), sequence_, sequence_+8); const int rev_[8] = {0,0,0,0,0,0,1,0}; // sequence of clockwise legs std::vector<int> rev(8); problem.rev_flag.insert(problem.rev_flag.begin(), rev_, rev_+8); problem.asteroid.keplerian[0] = 2.5897261; // Asteroid data problem.asteroid.keplerian[1] = 0.2734625; problem.asteroid.keplerian[2] = 6.40734; problem.asteroid.keplerian[3] = 128.34711; problem.asteroid.keplerian[4] = 264.78691; problem.asteroid.keplerian[5] = 320.479555; problem.asteroid.epoch = 53600; }
RepeatForeverPtr repeatForever(cocos2d::Node *target, const std::vector<IFiniteTimePtr> &tweens) { auto s = sequence(target, tweens); auto r = RepeatForever::create(target, std::move(s)); return std::move(r); }
void Cursor_Point::set ( Log_Entry &e ) { Sequence_Point::set( e ); for ( int i = 0; i < e.size(); ++i ) { const char *s, *v; e.get( i, &s, &v ); if ( ! strcmp( s, ":label" ) ) label( v ); else if ( ! strcmp( s, ":type" )) { type( v ); timeline->add_cursor( this ); } /* /\* FIXME: we need to add this to the time track on creation!!! *\/ */ /* timeline->time_track->add( this ); */ } sequence()->handle_widget_change( start(), length() ); // _make_label(); }
int main() { int a[6],i = 1; while(i < 6) { scanf("%d", &a[i]); i++; } printf("Before sequence:\n"); for (i = 1; i < 6; i++ ) { printf("a[%d] = %d ", i, a[i]); } printf("\n"); sequence(a, 5); printf("After sequence:\n"); i = 1; do{ printf("a[%d] = %d ", i, a[i]); i++; }while(i < 6); return 0; }
void addkey_v4( int no, int n ) { // stretch key std::string oldseed = seed; std::string stretched = seed; for( int i=0; i<100000; i++ ) { if( i == 0 ) { stretched = fc::sha256::hash( stretched + oldseed ); } else { std::vector<char> bytes(stretched.size() / 2); fc::from_hex( stretched, &bytes[0], bytes.size() ); std::string tmp(bytes.begin(), bytes.end()); stretched = fc::sha256::hash( tmp + oldseed ); } } // compute Hash( 'n:no:' + mpk ) std::vector<char> mpk( masterkey.size() / 2); fc::from_hex( masterkey, &mpk[0], mpk.size()); std::string mpks(mpk.begin(), mpk.end()); fc::sha256 sequence( fc::sha256::hash( fc::sha256::hash( std::to_string( n ) + ":" + std::to_string ( no ) + ":" + mpks ) ) ); fc::sha256 secexp( stretched ); privatekeys.push_back( fc::ecc::private_key::generate_from_seed( secexp, sequence ) ); }