Пример #1
0
bool FFDecSW::set()
{
	bool restartPlaying = false;

	if ( ( respectHurryUP = sets().getBool( "HurryUP" ) ) )
	{
		if ( ( skipFrames = sets().getBool( "SkipFrames" ) ) )
			forceSkipFrames = sets().getBool( "ForceSkipFrames" );
		else
			forceSkipFrames = false;
	}
	else
		skipFrames = forceSkipFrames = false;

	if ( lowres != sets().getInt( "LowresValue" ) )
	{
		lowres = sets().getInt( "LowresValue" );
		restartPlaying = true;
	}

	if ( thread_type_slice != sets().getBool( "ThreadTypeSlice" ) )
	{
		thread_type_slice = sets().getBool( "ThreadTypeSlice" );
		restartPlaying = true;
	}

	int _threads = sets().getInt( "Threads" );
	if ( _threads <= 0 )
	{
		_threads = QThread::idealThreadCount();
		if ( _threads < 1 )
			_threads = 1;
	}
	if ( _threads > 16 )
		_threads = 16;
	if ( threads != _threads )
	{
		threads = _threads;
		restartPlaying = true;
	}

	return !restartPlaying && sets().getBool( "DecoderEnabled" );
}
void Shape_GetPointOutlineColor(avm *vm)
{
    word w;
    long off = newtable(vm, ZEN_INITIALTABLESIZE);
    long tindex = TOTinsert(vm, off);
    ctable* tbl = (ctable*)getdata(vm->hp.heap, off);
    word index, source;
    sfColor col = sfShape_GetPointOutlineColor(getint(vm, 0), getint(vm, 1));
    sets(&index, newstring(vm, "R"));
    seti(&source, col.r);
    IA(vm, tbl, tindex, &index, &source);
    sets(&index, newstring(vm, "G"));
    seti(&source, col.g);
    IA(vm, tbl, tindex, &index, &source);
    sets(&index, newstring(vm, "B"));
    seti(&source, col.b);
    IA(vm, tbl, tindex, &index, &source);
    sets(&index, newstring(vm, "A"));
    seti(&source, col.a);
    IA(vm, tbl, tindex, &index, &source);
    sett(&w, tindex);
    returnv(vm, &w);
}
void string_getrect(avm *vm)
{
     word w;
     long off = newtable(vm, ZEN_INITIALTABLESIZE);
     long tindex = TOTinsert(vm, off);
     ctable* tbl = (ctable*)getdata(vm->hp.heap, off);
     word index, source;
     sfFloatRect col = sfString_GetRect(getstring(vm, 0));
     sets(&index, newstring(vm, "Left"));
     seti(&source, col.Left);
     IA(vm, tbl, tindex, &index, &source);
     sets(&index, newstring(vm, "Top"));
     seti(&source, col.Top);
     IA(vm, tbl, tindex, &index, &source);
     sets(&index, newstring(vm, "Right"));
     seti(&source, col.Right);
     IA(vm, tbl, tindex, &index, &source);
     sets(&index, newstring(vm, "Bottom"));
     seti(&source, col.Bottom);
     IA(vm, tbl, tindex, &index, &source);
     sett(&w, tindex);
     returnv(vm, &w);
}
Пример #4
0
ModuleSettingsWidget::ModuleSettingsWidget(Module &module) :
	Module::SettingsWidget(module)
{
	enabledB = new QCheckBox(tr("Enabled"));
	enabledB->setChecked(sets().getBool("Enabled"));

	useSHMB = new QCheckBox(tr("Use shared memory"));
	useSHMB->setChecked(sets().getBool("UseSHM"));

	QLabel *adaptorsL = new QLabel(tr("XVideo outputs") + ": ");

	adaptorsB = new QComboBox;
	adaptorsB->addItem(tr("Default"));
	adaptorsB->addItems(XVIDEO::adaptorsList());
	int idx = adaptorsB->findText(sets().getString("Adaptor"));
	adaptorsB->setCurrentIndex(idx < 0 ? 0 : idx);

	QGridLayout *layout = new QGridLayout(this);
	layout->addWidget(enabledB, 0, 0, 1, 2);
	layout->addWidget(useSHMB, 1, 0, 1, 2);
	layout->addWidget(adaptorsL, 2, 0, 1, 1);
	layout->addWidget(adaptorsB, 2, 1, 1, 1);
}
Пример #5
0
void controlBar::barSpacing()
{
  //_-_-_-_-_//_-_-_-_-_ spacing setup //_-_-_-_-_//_-_-_-_-_
  for(int i=0; i<3;i++)
    bHldr.push_back(buttonHolder());
  
  if(cfg().drawNewUser) bHldr[0].addObj(cfg().newUser);
  bHldr[0].addObj(clearBut);
  bHldr[0].internalSpace(30);
  
  bHldr[1].addObj(undoBut);
  bHldr[1].addObj(redoBut);
  bHldr[1].internalSpace(20);
  
  for (unsigned int i=0; i<sets.size(); i++) sets(i).w=sets(i).h=72;
  
  for (unsigned int i=0; i<sets.size(); i++) bHldr[2].addObj(sets(i));
  bHldr[2].internalSpace(20);
  
  double maxH=0;
  int pad=ofGetWidth();
  
  for (unsigned int i=0; i<bHldr.size(); i++) {
    maxH=max(maxH,bHldr[i].maxHeight());
    pad-=bHldr[i].area.width;
  }
  buttonBar=ofRectangle(x,y,ofGetWidth(),maxH*1.2);
  
  for (unsigned int i=0; i<bHldr.size(); i++) {
    bHldr[i].area.height=bHldr[i].h=buttonBar.height;
    bHldr[i].padding(pad/bHldr.size());
  }
  
  h=subBar.height+buttonBar.height;
  w=ofGetWidth();
}
Пример #6
0
int main() {
    union_find sets(10);

    sets.unite(1, 2);
    sets.unite(1, 3);

    sets.unite(5, 6);
    sets.unite(6, 7);

    sets.unite(1, 5);

    sets.print();

    return 0;
}
int main(){

	int  set;
	char relationship[15];

	while (scanf("%d", &set) != EOF)
	{
		sets(set, relationship);

		show(set, relationship);
	}

	return 0;

}
int main(int argc, char *argv[])
/* Process command line. */
{
struct slName *fileList = NULL;
int i;
optionInit(&argc, argv, options);
if (argc < 4)
    usage();
/* make a list out of the filenames. */
for (i = 2; i < argc; i++)
    slNameAddHead(&fileList, argv[i]);
slReverse(&fileList);
sets(argv[1], fileList);
slNameFreeList(&fileList);
return 0;
}
Пример #9
0
void read_from_file(vector<string>& strElems, string file_to_read) {
	try {
		// define file to read input data from
		ifstream sets(file_to_read);

		// store input data in a vector of strings
		while (!sets.eof()) {
			strElems.push_back("");
			getline(sets, strElems[strElems.size() - 1]);
	  	}
		sets.close();
	}
	catch (exception) {
		cerr << "error with 'read_from_file'";
	}
}
Пример #10
0
int wxSelectDispatcher::Dispatch(int timeout)
{
    wxSelectSets sets(m_sets);
    switch ( DoSelect(sets, timeout) )
    {
        case -1:
            wxLogSysError(_("Failed to monitor I/O channels"));
            return -1;

        case 0:
            // timeout expired without anything happening
            return 0;

        default:
            return ProcessSets(sets);
    }
}
Пример #11
0
void ModuleSettingsWidget::saveSettings()
{
	toneGenerator->save();
	if (pcmExtsE->text().isEmpty())
		pcmExtsE->setText(standartExts);
	sets().set("PCM", pcmB->isChecked());
	sets().set("PCM/extensions", pcmExtsE->text().split(';', QString::SkipEmptyParts));
	for (int i = 0; i < formatB.size(); ++i)
		if (formatB[i]->isChecked())
		{
			sets().set("PCM/format", i);
			break;
		}
	sets().set("PCM/chn", chnB->value());
	sets().set("PCM/srate", srateB->value());
	sets().set("PCM/offset", offsetB->value());
	sets().set("PCM/BE", (bool)endianB->currentIndex());
	sets().set("Rayman2", rayman2EB->isChecked());
}
Пример #12
0
void testSet_2()
{
	vector<vector<int>> sets(SETNUM);
	int n = dataGen_2(sets);
	int* ret = new int[n];

#ifdef TIMING_FOR_APLWAH
	clock_t t1,t2;
	t1 = clock();
#endif
#ifdef NUM_LIST
	for(int i=0;i<SETNUM;i++){
		printf("\nSet %d:",i);
		for(int j=0;j<NUM_LIST;j++){
			printf(" %d",sets[i][j]);
		}
		
	}
	printf("\n\n");
#endif
	int* end = set_intersection(sets[0].begin(),sets[0].end(),sets[1].begin(),sets[1].end(),ret);
	for(int i=2;i<SETNUM;i++){
		end = set_intersection(ret,end,sets[i].begin(),sets[i].end(),ret);
	}
#ifdef NUM_LIST
	printf("Intersections:");
	for(int j=0;j<NUM_LIST;j++){
		printf(" %d",ret[j]);
	}
	printf("\n\n");
#endif
#ifdef TIMING_FOR_APLWAH
	t2 = clock();
	printf("STL set_intersection:\n%d Sets, each with %d integers, Step %d\nResult: %d integers, using %d ms\n\n",SETNUM,INTNUM,STEP,end - ret,t2 - t1);
#endif

#ifdef COUNTING
	int* start = ret;
	while(start != end){
		cout<<*start<<' ';
		start++;
	}
	cout<<endl;
#endif
}
Пример #13
0
void controlBar::drawForeground(){
  
  if(anim.isPlaying()){
    drawStyledBox(skipBut.x-50, skipBut.y-50, skipBut.w+100, skipBut.h+100);
    skipBut.draw((ofGetWidth()-skipBut.w)/2, ofGetHeight()*3./4);
  }
  
  
  if(report().isReporting()){
	  report().draw();
  }
  else if(serChk.drawForeground());
  else if(upload.drawForeground());
  else if(cfg().savePrograms&&bPluginChoice){
	  ofSetColor(black.opacity(200));
	  ofRect(0,0,ofGetWidth(),ofGetHeight());
	  drawStyledBox(create.x-50, create.y-50, create.w+100, (edit.y-create.y)+edit.h+100);
	  create.draw((ofGetWidth()-create.w)/2,(ofGetHeight()-create.h*2)/2-50);
	  edit.draw((ofGetWidth()-edit.w)/2,(ofGetHeight()+edit.h*2)/2+50);
  }
  else if(bChooseLevel){
    //ofSetColor(0, 0, 0,192);
    //ofRect(0, y, ofGetWidth(), ofGetHeight());
    for (unsigned int i=0; i<sets.size(); i++) sets(i).w=sets(i).h=200,sets(i).setAvailable(true);
    
	subtitle.setSize(50);
	subtitle.setMode(OF_FONT_CENTER);
	subtitle.setMode(OF_FONT_TOP);
	string title1="Select a programmer level";
	string title2="to begin.";
	double boxWid=(sets.size()-1)*ofGetWidth()/(sets.size())+(sets(0).w)+100;
	boxWid=max(boxWid,double(subtitle.stringWidth(title1)));

	double stringHgt=subtitle.stringHeight(title1)*2+50;
	double boxHgt=sets(0).h+stringHgt+150;

	drawStyledBox(0, y, ofGetWidth(),ofGetHeight()-y);
    //drawStyledBox((ofGetWidth()-boxWid)/2, ofGetHeight()/2-stringHgt-50, boxWid,boxHgt);
	ofSetColor(cfg().textColor);
	subtitle.drawString(title1,ofGetWidth()/2,ofGetHeight()/2-stringHgt);
	subtitle.drawString(title2,ofGetWidth()/2,ofGetHeight()/2-stringHgt+(stringHgt)/2);
    for (unsigned int i=0; i<sets.size(); i++) sets(i).draw((i+.5)*ofGetWidth()/(sets.size())-(sets(i).w)/2,ofGetHeight()/2+50);
  }
  else if(cfg().test&&test().isTesting()) test().drawForeground();
  else anim.drawForeground();
  
  
  anim.drawCursor();
}
Пример #14
0
template <typename INT> void Node_Set<INT>::entity_load_params()
{
  std::vector<ex_set> sets(1);
  sets[0].id                       = id_;
  sets[0].type                     = EX_NODE_SET;
  sets[0].entry_list               = nullptr;
  sets[0].extra_list               = nullptr;
  sets[0].distribution_factor_list = nullptr;

  int err = ex_get_sets(fileId, 1, &sets[0]);

  if (err < 0) {
    std::cout << "ERROR: Failed to get nodeset parameters for nodeset " << id_ << ". !  Aborting..."
              << '\n';
    exit(1);
  }

  numEntity        = sets[0].num_entry;
  num_dist_factors = sets[0].num_distribution_factor;
}
Пример #15
0
void Equalizer::alloc( bool b )
{
	mutex.lock();
	if ( !b && ( fftIn || fftOut ) )
	{
		canFilter = false;
		FFT_NBITS = FFT_SIZE = FFT_SIZE_2 = 0;
		av_fft_end( fftIn );
		av_fft_end( fftOut );
		fftIn = NULL;
		fftOut = NULL;
		av_free( complex );
		complex = NULL;
		input.clear();
		last_samples.clear();
		wind_f.clear();
		f.clear();
	}
	else if ( b )
	{
		if ( !fftIn || !fftOut )
		{
			FFT_NBITS  = sets().getInt( "Equalizer/nbits" );
			FFT_SIZE   = 1 << FFT_NBITS;
			FFT_SIZE_2 = FFT_SIZE / 2;
			fftIn  = av_fft_init( FFT_NBITS, false );
			fftOut = av_fft_init( FFT_NBITS, true );
			complex = ( FFTComplex * )av_malloc( FFT_SIZE * sizeof( FFTComplex ) );
			input.resize( chn );
			last_samples.resize( chn );
			wind_f.resize( FFT_SIZE );
			for ( int i = 0 ; i < FFT_SIZE ; ++i )
				wind_f[ i ] = 0.5f - 0.5f * cos( 2.0f * M_PI * i / ( FFT_SIZE - 1 ) );
		}
		interpolateFilterCurve();
		canFilter = true;
	}
	mutex.unlock();
}
Пример #16
0
WindowImpl::WindowImpl():
    m_ui(new Ui::WindowImpl)
{
    m_ui->setupUi(this);
    QApplication::setStyle(new QNotoStyle);

    QSettings sets(QSettings::IniFormat, QSettings::UserScope, "qnoto", "qnoto");
    restoreGeometry(sets.value("MainWindow/Geometry").toByteArray());

    QDockWidget *dockWidget = new QDockWidget("Left side", this);
    dockWidget->setContentsMargins(0, 0, 0, 0);
    dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea);
    dockWidget->setFloating(false);
    dockWidget->setFeatures(dockWidget->features() ^ QDockWidget::DockWidgetClosable ^ QDockWidget::DockWidgetMovable ^ QDockWidget::DockWidgetFloatable);
    dockWidget->setTitleBarWidget(new QWidget);
    m_split = new SideSplit(this);
    dockWidget->setWidget(m_split);
    addDockWidget(Qt::LeftDockWidgetArea, dockWidget);

    m_editors = qnoto::plugin<qnoto::Editors>();
    connect(m_editors, &qnoto::Editors::updateEditMenu, this, &WindowImpl::updateEditMenu);

    setCentralWidget(m_editors);

    const auto& acts = m_editors->actions();
    for(const auto& it: acts){
        if (it->property("name").toString().startsWith("File_")){
            m_ui->menuFile->addAction(it);
        }
        if (it->property("name").toString().startsWith("Window_")){
            m_ui->menuWindow->addAction(it);
        }
    }

    connect(m_ui->actionPreferences, &QAction::triggered, this, &WindowImpl::showPreferences);

    m_split->restoreState(sets);
    m_editors->restoreState();
}
Пример #17
0
void LuminesRobot::think(btype *map, int width, int height, const BlockSet coming[3])
{
    thinkNextBlock(map, width, height, coming);
    return;
    int i, j;
    int r, t;
    int score;
    BlockSet bs;
    int top1, top2;
    LuRobotResultPair res;
    ::std::vector< int > tops(width,0);
    ::std::vector< Set > sets((width-1)*4);
    sets.clear();
    tops.clear();

#ifdef _DEBUG
    OutputDebugString("\n");
#endif
    for (i=0;i<width;i++)
    {
        for (j=height-1;j>=0;j--)
        {
            if (map[i+j*width] == BT_NONE)
                break;
#ifdef _DEBUG
            if (map[i+j*width] == BT_A)
                OutputDebugString("a");
            else 
                OutputDebugString("b");
        }
        char n[3];
        sprintf(n,"%d\n",j);
        OutputDebugString(n);
#else
        }
#endif

        tops.push_back(j);
    }
Пример #18
0
void StickerSetInner::installDone(const MTPBool &result) {
	StickerSets &sets(cRefStickerSets());

	sets.insert(_setId, StickerSet(_setId, _setAccess, _setTitle, _setShortName, _setCount, _setHash, _setFlags)).value().stickers = _pack;

	int32 insertAtIndex = 0;
	StickerSetsOrder &order(cRefStickerSetsOrder());
	for (int32 s = order.size(); insertAtIndex < s; ++insertAtIndex) {
		StickerSets::const_iterator i = sets.constFind(order.at(insertAtIndex));
		if (i == sets.cend() || !(i->flags & MTPDstickerSet_flag_official)) {
			break;
		}
	}
	int32 currentIndex = cStickerSetsOrder().indexOf(_setId);
	if (currentIndex != insertAtIndex) {
		if (currentIndex > 0) {
			order.removeAt(currentIndex);
			if (currentIndex < insertAtIndex) {
				--insertAtIndex;
			}
		}
		order.insert(insertAtIndex, _setId);
	}

	StickerSets::iterator custom = sets.find(CustomStickerSetId);
	if (custom != sets.cend()) {
		for (int32 i = 0, l = _pack.size(); i < l; ++i) {
			custom->stickers.removeOne(_pack.at(i));
		}
		if (custom->stickers.isEmpty()) {
			sets.erase(custom);
		}
	}
	cSetStickersHash(QByteArray());
	Local::writeStickers();
	emit installed(_setId);
	App::wnd()->hideLayer();
}
int main()
{
    std::vector<Element> elements;
    elements.reserve(30);
    for (size_t i = 0; i < elements.capacity(); ++i)
    {
        elements.push_back(Element(rand() % 90));
    }

    for (size_t i = 0; i < elements.size(); ++i)
    {
        elements[i].dsID = i;
    }

    Rank rank(elements);
    Parent parent(elements);

    boost::disjoint_sets<Rank*, Parent*> sets(&rank, &parent);

    for (size_t i = 0; i < elements.size(); ++i)
    {
        sets.make_set(elements.at(i));
    }

    for (size_t i = 0; i < elements.size(); ++i)
    {
        // Union between this element and one randomly chosen from the rest
        size_t j = rand() % elements.size();
        sets.union_set(elements[i], elements[j]);
    }

    std::cout << "Found " << sets.count_sets(elements.begin(), elements.end()) << " sets:" << std::endl;

    sets.compress_sets(elements.begin(), elements.end());

    std::cout << std::endl << "After path compression:" << std::endl;
}
Пример #20
0
bool OpenGL2Writer::set()
{
	bool doReset = false;

	const bool newAllowPBO = sets().getBool("AllowPBO");
	if (newAllowPBO != allowPBO)
	{
		allowPBO = newAllowPBO;
		doReset = true;
	}

	const bool newHqScaling = sets().getBool("HQScaling");
	if (newHqScaling != m_hqScaling)
	{
		m_hqScaling = newHqScaling;
		doReset = true;
	}

	vSync = sets().getBool("VSync");
	if (drawable && !drawable->setVSync(vSync))
		doReset = true;

	const bool newForceRtt = sets().getBool("ForceRtt");
	if (forceRtt != newForceRtt)
		doReset = true;
	forceRtt = newForceRtt;

#ifdef Q_OS_WIN
	bool newPreventFullScreen = sets().getBool("PreventFullScreen");
	if (preventFullScreen != newPreventFullScreen)
		doReset = true;
	preventFullScreen = newPreventFullScreen;
#endif

	return !doReset && sets().getBool("Enabled");
}
Пример #21
0
void controlBar::draw(int _x, int _y)
{
  buttonBar.x=x=_x;
  buttonBar.y=y=_y;
  subBar.x=x;
  subBar.y=y+buttonBar.height;
  
  
  //_-_-_-_-_//_-_-_-_-_//_-_-_-_-_//_-_-_-_-_//_-_-_-_-_
  //_-_-_-_-_//_-_-_-_-_//buttonbar//_-_-_-_-_//_-_-_-_-_
  
  if(!cfg().defaultColor) ofSetColor(cfg().controlBarColor);
  else ofSetColor(black);
  ofRect(buttonBar.x,buttonBar.y,buttonBar.width,buttonBar.height);
  
  ofSetColor(gray.opacity(128));
  if(cfg().defaultColor) drawHatching(buttonBar.x, buttonBar.y, buttonBar.width, buttonBar.height, 50,50);
  
  for (unsigned int i=0; i<sets.size(); i++) sets(i).w=sets(i).h=72;
  bHldr[0].draw(buttonBar.x,buttonBar.y);
  for (unsigned int i=1; i<bHldr.size(); i++) {
    bHldr[i].draw(bHldr[i-1].area.x+bHldr[i-1].area.width,buttonBar.y);
  }
  
  //_-_-_-_-_//_-_-_-_-_//_-_-_-_-_//_-_-_-_-_//_-_-_-_-_
  //_-_-_-_-_//_-_-_-_-_//subTitle //_-_-_-_-_//_-_-_-_-_
  
  if(cfg().defaultColor) ofSetColor(gray);
  else ofSetColor(cfg().subtitleColor);
  ofRect(subBar.x,subBar.y,subBar.width,subBar.height);
  drawBorder(subBar);
  
  if(cfg().defaultColor) ofSetColor(yellow);
  else ofSetColor(cfg().lineColor);
  ofRect(subBar.x, subBar.y, subBar.width, 1);
  
  if(sets.getSelected()){
    ofButton & t=sets.getSelected()->choice;
    int wid=t.w/16+1;
    if(cfg().defaultColor) ofSetColor(yellow);
	else ofSetColor(cfg().lineColor);
    ofRect(t.x-wid, y, t.w+wid*2, buttonBar.height);
    wid=t.w/16;
	if(cfg().defaultColor) ofSetColor(gray);
	else ofSetColor(cfg().subtitleColor);
    ofRect(t.x-wid, y, t.w+wid*2, buttonBar.height+10);
    t.draw(t.x,t.y);
    
    if(cfg().defaultColor) ofSetColor(yellow);
	else ofSetColor(cfg().textColor);
    subtitle.setSize(22);
    subtitle.setMode(OF_FONT_LEFT);
    subtitle.drawString(sets.getSelected()->subtitle, 50, subBar.y+(subBar.height-subtitle.stringHeight(sets.getSelected()->subtitle))/2+5);
  }
  
  if(cfg().test&&test().isTesting()){
    ofRectangle & cBar=test().controlBar;
    
    ofSetColor(0x33, 0x33, 0x33);
    ofRect(0, 0, ofGetWidth(), ofGetHeight());
    ofSetColor(black);
    drawHatching(0, 0, ofGetWidth(), ofGetHeight(), 15,1);
    
    test().draw(0,cBar.y+cBar.height,ofGetHeight()-(cBar.y+cBar.height),ofGetHeight()-(cBar.y+cBar.height));
    blocks->base.draw(ofGetHeight(), y);
	cfg().test=false;
	blocks->base.drawButtonArea(ofGetHeight(),y);
	cfg().test=true;
    test().drawCurrentBlock();
    
    test().drawControlBar(x, y);
  }
}
Пример #22
0
void BuildBasisAndCloseSetOpt(std::vector<std::string> fileNames, std::ofstream &output, const double probability, const size_t rep)
{
    std::cout <<  "Precounting..." << std::endl << std::endl;

    const size_t testNum = fileNames.size();
    std::vector<std::vector<FCA::ImplicationInd> > basises(testNum);
    std::vector<FCA::BitSet> sets(testNum);
    std::vector<size_t> attrNum(testNum);

    std::ifstream input;
    for (size_t fileInd = 0; fileInd < fileNames.size(); ++fileInd)
    {
        input.open(fileNames[fileInd].c_str());
        FCA::Context context;			

        ReadContext(context, input);
        input.close();		

        basises[fileInd] = FCA::ComputeDGBasis<FCA::LinClosure>(context);
        sets[fileInd] = GetRandomBitSet(context.getAttributesCnt(), probability);
        attrNum[fileInd] = context.getAttributesCnt();
    }

    Timer timer;

    output << "Closure" << std::endl << std::endl;
    for (size_t i = 0; i < testNum; ++i)
    {
        FCA::BitSet tmp(attrNum[i]);
        timer.StartTiming();
        for (size_t j = 0; j < rep; ++j)
        {
            FCA::Closure::Apply(sets[i], basises[i], tmp);
        }
        timer.StopTiming();

        output << i << ". " << Time(timer.GetUserSeconds()) << " " << basises[i].size() << std::endl;
    }
    output << std::endl;

    output << "LinClosure" << std::endl << std::endl;
    for (size_t i = 0; i < testNum; ++i)
   { 
        std::vector<size_t> premiseCount;
        std::vector<std::vector<size_t> > list(attrNum[i]);
        size_t prevImplSetSize = 0;

        FCA::BitSet tmp(attrNum[i]);
        FCA::LinClosure::Apply(sets[i], basises[i], premiseCount, list, prevImplSetSize, tmp);
        timer.StartTiming();
        for (size_t j = 0; j < rep; ++j)
        {
            FCA::LinClosure::Apply(sets[i], basises[i], premiseCount, list, prevImplSetSize, tmp);
        }
        timer.StopTiming();

        output << i << ". " << Time(timer.GetUserSeconds()) << " " << basises[i].size() << std::endl;
    }
    output << std::endl;

    output << "LinClosureImproved" << std::endl << std::endl;
    for (size_t i = 0; i < testNum; ++i)
    {
        std::vector<FCA::BitSet> list(attrNum[i]);
        size_t prevImplSetSize = 0;

        FCA::BitSet tmp(attrNum[i]);
        FCA::LinClosureImproved::Apply(sets[i], basises[i], list, prevImplSetSize, tmp);
        timer.StartTiming();
        for (size_t j = 0; j < rep; ++j)
        {
            FCA::LinClosureImproved::Apply(sets[i], basises[i], list, prevImplSetSize, tmp);
        }
        timer.StopTiming();

        output << i << ". " << Time(timer.GetUserSeconds()) << " " << basises[i].size() << std::endl;
    }
    output << std::endl;
}
Пример #23
0
void ApiWrap::gotStickerSet(uint64 setId, const MTPmessages_StickerSet &result) {
	_stickerSetRequests.remove(setId);
	
	if (result.type() != mtpc_messages_stickerSet) return;
	const MTPDmessages_stickerSet &d(result.c_messages_stickerSet());
	
	if (d.vset.type() != mtpc_stickerSet) return;
	const MTPDstickerSet &s(d.vset.c_stickerSet());

	StickerSets &sets(cRefStickerSets());
	StickerSets::iterator it = sets.find(setId);
	if (it == sets.cend()) return;

	it->access = s.vaccess_hash.v;
	it->hash = s.vhash.v;
	it->shortName = qs(s.vshort_name);
	it->title = stickerSetTitle(s);
	it->flags = s.vflags.v;

	const QVector<MTPDocument> &d_docs(d.vdocuments.c_vector().v);
	StickerSets::iterator custom = sets.find(CustomStickerSetId);

	StickerPack pack;
	pack.reserve(d_docs.size());
	for (int32 i = 0, l = d_docs.size(); i != l; ++i) {
		DocumentData *doc = App::feedDocument(d_docs.at(i));
		if (!doc || !doc->sticker()) continue;

		pack.push_back(doc);
		if (custom != sets.cend()) {
			int32 index = custom->stickers.indexOf(doc);
			if (index >= 0) {
				custom->stickers.removeAt(index);
			}
		}
	}
	if (custom != sets.cend() && custom->stickers.isEmpty()) {
		sets.erase(custom);
		custom = sets.end();
	}

	bool writeRecent = false;
	RecentStickerPack &recent(cGetRecentStickers());
	for (RecentStickerPack::iterator i = recent.begin(); i != recent.cend();) {
		if (it->stickers.indexOf(i->first) >= 0 && pack.indexOf(i->first) < 0) {
			i = recent.erase(i);
			writeRecent = true;
		} else {
			++i;
		}
	}
	if (pack.isEmpty()) {
		int32 removeIndex = cStickerSetsOrder().indexOf(setId);
		if (removeIndex >= 0) cRefStickerSetsOrder().removeAt(removeIndex);
		sets.erase(it);
	} else {
		it->stickers = pack;
	}

	if (writeRecent) {
		Local::writeUserSettings();
	}

	Local::writeStickers();

	if (App::main()) emit App::main()->stickersUpdated();
}
Пример #24
0
 PSR& operator=(uint32 data) {
   setf(data), sets(data), setx(data), setc(data);
   return *this;
 }
Пример #25
0
ModuleSettingsWidget::ModuleSettingsWidget(Module &module) :
	Module::SettingsWidget(module)
{
	toneGenerator = new AddD(sets(), NULL, this);

	pcmB = new QGroupBox(tr("Uncompressed PCM sound"));
	pcmB->setCheckable(true);
	pcmB->setChecked(sets().getBool("PCM"));

	QLabel *pcmExtsL = new QLabel(tr("File extensions (semicolon separated)") + ": ");

	pcmExtsE = new QLineEdit;
	QString exts;
	foreach (const QString &ext, sets().get("PCM/extensions").toStringList())
		exts += ext + ";";
	pcmExtsE->setText(exts);

	QGroupBox *fmtB = new QGroupBox(tr("Format"));
	QVBoxLayout *fmtLayout = new QVBoxLayout(fmtB);
	int checked = sets().getInt("PCM/format");
	for (int i = 0; i < PCM::FORMAT_COUNT; ++i)
	{
		QRadioButton *rB = new QRadioButton(formatName[i]);
		if (i == checked)
			rB->setChecked(true);
		fmtLayout->addWidget(rB);
		formatB.append(rB);
	}

	QLabel *chnL = new QLabel(tr("Channel count") + ": ");

	chnB = new QSpinBox;
	chnB->setRange(1, 8);
	chnB->setValue(sets().getInt("PCM/chn"));

	QLabel *srateL = new QLabel(tr("Sample rate") + ": ");

	srateB = new QSpinBox;
	srateB->setSuffix(" Hz");
	srateB->setRange(2, 1000000000);
	srateB->setValue(sets().getInt("PCM/srate"));

	QLabel *offsetL = new QLabel(tr("Offset") + ": ");

	offsetB = new QSpinBox;
	offsetB->setSuffix(" B");
	offsetB->setRange(0, 0x7FFFFFFF);
	offsetB->setValue(sets().getInt("PCM/offset"));

	endianB = new QComboBox;
	endianB->addItem("Little endian");
	endianB->addItem("Big endian");
	endianB->setCurrentIndex(sets().getBool("PCM/BE"));

	QGridLayout *pcmLayout = new QGridLayout(pcmB);
	pcmLayout->addWidget(pcmExtsL, 0, 0, 1, 1);
	pcmLayout->addWidget(pcmExtsE, 0, 1, 1, 2);
	pcmLayout->addWidget(fmtB, 1, 0, 5, 1);
	pcmLayout->addWidget(chnL, 1, 1, 1, 1);
	pcmLayout->addWidget(chnB, 1, 2, 1, 1);
	pcmLayout->addWidget(srateL, 2, 1, 1, 1);
	pcmLayout->addWidget(srateB, 2, 2, 1, 1);
	pcmLayout->addWidget(offsetL, 3, 1, 1, 1);
	pcmLayout->addWidget(offsetB, 3, 2, 1, 1);
	pcmLayout->addWidget(endianB, 4, 1, 1, 2);
	pcmLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding), 5, 1, 1, 2);

	rayman2EB = new QCheckBox(tr("Rayman2 music (*.apm)"));
	rayman2EB->setChecked(sets().getBool("Rayman2"));

	QGridLayout *layout = new QGridLayout(this);
	layout->addWidget(toneGenerator);
	layout->addWidget(pcmB);
	layout->addWidget(rayman2EB);
}
Пример #26
0
bool AudioCDDemux::freedb_query( cddb_disc_t *&cddb_disc )
{
#ifdef Q_OS_WIN
	bool hasHomeEnv = getenv( "HOME" );
	if ( !hasHomeEnv )
		putenv( "HOME=" + QDir::homePath().toLocal8Bit() );
#endif
	cddb_conn_t *cddb = cddb_new();
#ifdef Q_OS_WIN
	if ( !hasHomeEnv )
		putenv( "HOME=" );
#endif
	cddb_disc = cddb_disc_new();

#ifdef Q_OS_WIN
	const QString cddbDir = QMPlay2Core.getSettingsDir() + "CDDB";
	if ( QDir( cddbDir ).exists() || QDir( QMPlay2Core.getSettingsDir() ).mkdir( "CDDB" ) )
		cddb_cache_set_dir( cddb, cddbDir.toLocal8Bit() );
#endif

	cddb_disc_set_length( cddb_disc, FRAMES_TO_SECONDS( cdio_get_track_lba( cdio, CDIO_CDROM_LEADOUT_TRACK ) ) );
	for ( int trackno = 1 ; trackno <= numTracks ; ++trackno )
	{
		cddb_track_t *pcddb_track = cddb_track_new();
		cddb_track_set_frame_offset( pcddb_track, cdio_get_track_lba( cdio, trackno ) );
		cddb_disc_add_track( cddb_disc, pcddb_track );
	}

	bool useNetwork = false;

	cddb_disc_calc_discid( cddb_disc );
	if ( cddb_disc_get_discid( cddb_disc ) == discID )
		cddb_cache_only( cddb );
	else
	{
		discID = cddb_disc_get_discid( cddb_disc );

		cddb_set_timeout( cddb, 3 );
		cddb_http_enable( cddb );
		cddb_set_server_port( cddb, 80 );

		Settings sets( "QMPlay2" );
		if ( sets.getBool( "Proxy/Use" ) )
		{
			cddb_http_proxy_enable( cddb );
			cddb_set_http_proxy_server_name( cddb, sets.getString( "Proxy/Host" ).toLocal8Bit() );
			cddb_set_http_proxy_server_port( cddb, sets.getUInt( "Proxy/Port" ) );
			if ( sets.getBool( "Proxy/Login" ) )
			{
				cddb_set_http_proxy_username( cddb, sets.getString( "Proxy/User" ).toLocal8Bit() );
				cddb_set_http_proxy_password( cddb, QString( QByteArray::fromBase64( sets.getByteArray( "Proxy/Password" ) ) ).toLocal8Bit() );
			}
		}

		useNetwork = true;
	}

	for ( int i = 0 ; i <= useNetwork ; ++i )
	{
		if ( cddb_query( cddb, cddb_disc ) > 0 )
		{
			do if ( cddb_disc_get_discid( cddb_disc ) == discID )
			{
				cddb_read( cddb, cddb_disc );
				cddb_destroy( cddb );
				return true;
			} while ( cddb_query_next( cddb, cddb_disc ) );
		}
		if ( useNetwork && !i )
			cddb_set_server_name( cddb, "freedb.musicbrainz.org" );
	}

	cddb_disc_destroy( cddb_disc );
	cddb_destroy( cddb );
	cddb_disc = NULL;
	return false;
}
Пример #27
0
bool AudioCDDemux::set()
{
	useCDDB   = sets().getBool( "AudioCD/CDDB" );
	useCDTEXT = sets().getBool( "AudioCD/CDTEXT" );
	return true;
}
Пример #28
0
void ApiWrap::gotStickerSet(uint64 setId, const MTPmessages_StickerSet &result) {
	_stickerSetRequests.remove(setId);
	
	if (result.type() != mtpc_messages_stickerSet) return;
	const MTPDmessages_stickerSet &d(result.c_messages_stickerSet());
	
	if (d.vset.type() != mtpc_stickerSet) return;
	const MTPDstickerSet &s(d.vset.c_stickerSet());

	StickerSets &sets(cRefStickerSets());
	StickerSets::iterator it = sets.find(setId);
	if (it == sets.cend()) return;

	it->access = s.vaccess_hash.v;
	it->hash = s.vhash.v;
	it->shortName = qs(s.vshort_name);
	QString title = qs(s.vtitle);
	if ((it->flags & MTPDstickerSet_flag_official) && !title.compare(qstr("Great Minds"), Qt::CaseInsensitive)) {
		title = lang(lng_stickers_default_set);
	}
	it->title = title;
	it->flags = s.vflags.v;

	const QVector<MTPDocument> &d_docs(d.vdocuments.c_vector().v);
	StickerSets::iterator custom = sets.find(CustomStickerSetId);

	QSet<DocumentData*> found;
	int32 wasCount = -1;
	for (int32 i = 0, l = d_docs.size(); i != l; ++i) {
		DocumentData *doc = App::feedDocument(d_docs.at(i));
		if (!doc || !doc->sticker) continue;

		if (wasCount < 0) wasCount = it->stickers.size();
		if (it->stickers.indexOf(doc) < 0) {
			it->stickers.push_back(doc);
		} else {
			found.insert(doc);
		}

		if (custom != sets.cend()) {
			int32 index = custom->stickers.indexOf(doc);
			if (index >= 0) {
				custom->stickers.removeAt(index);
			}
		}
	}
	if (custom != sets.cend() && custom->stickers.isEmpty()) {
		sets.erase(custom);
		custom = sets.end();
	}

	bool writeRecent = false;
	RecentStickerPack &recent(cGetRecentStickers());

	if (wasCount < 0) { // no stickers received
		for (RecentStickerPack::iterator i = recent.begin(); i != recent.cend();) {
			if (it->stickers.indexOf(i->first) >= 0) {
				i = recent.erase(i);
				writeRecent = true;
			} else {
				++i;
			}
		}
		cRefStickerSetsOrder().removeOne(setId);
		sets.erase(it);
	} else {
		for (int32 j = 0, l = wasCount; j < l;) {
			if (found.contains(it->stickers.at(j))) {
				++j;
			} else {
				for (RecentStickerPack::iterator i = recent.begin(); i != recent.cend();) {
					if (it->stickers.at(j) == i->first) {
						i = recent.erase(i);
						writeRecent = true;
					} else {
						++i;
					}
				}
				it->stickers.removeAt(j);
				--l;
			}
		}
		if (it->stickers.isEmpty()) {
			cRefStickerSetsOrder().removeOne(setId);
			sets.erase(it);
		}
	}

	if (writeRecent) {
		Local::writeUserSettings();
	}

	Local::writeStickers();

	if (App::main()) emit App::main()->stickersUpdated();
}
Пример #29
0
void ModuleSettingsWidget::saveSettings()
{
	sets().set("WriterEnabled", enabledB->isChecked());
	sets().set("Delay", delayB->value());
}
Пример #30
0
inline void merge_segments_with_function( const volume_ptr<ID>& seg_ptr,
                                          const region_graph_ptr<ID,F> rg_ptr,
                                          std::vector<std::size_t>& counts,
                                          const FN& func,
                                          const M& lowt )
{
    zi::disjoint_sets<ID> sets(counts.size());

    region_graph<ID,F>& rg  = *rg_ptr;

    for ( auto& it: rg )
    {
        std::size_t size = func(std::get<0>(it));

        if ( size == 0 )
        {
            break;
        }

        ID s1 = sets.find_set(std::get<1>(it));
        ID s2 = sets.find_set(std::get<2>(it));

        if ( s1 != s2 && s1 && s2 )
        {
            if ( (counts[s1] < size) || (counts[s2] < size) )
            {
                counts[s1] += counts[s2];
                counts[s2]  = 0;
                ID s = sets.join(s1,s2);
                std::swap(counts[s], counts[s1]);
            }
        }
    }

    std::cout << "Done with merging" << std::endl;

    std::vector<ID> remaps(counts.size());

    ID next_id = 1;

    std::size_t low = static_cast<std::size_t>(lowt);

    for ( ID id = 0; id < counts.size(); ++id )
    {
        ID s = sets.find_set(id);
        if ( s && (remaps[s] == 0) && (counts[s] >= low) )
        {
            remaps[s] = next_id;
            counts[next_id] = counts[s];
            ++next_id;
        }
    }

    counts.resize(next_id);

    std::ptrdiff_t xdim = seg_ptr->shape()[0];
    std::ptrdiff_t ydim = seg_ptr->shape()[1];
    std::ptrdiff_t zdim = seg_ptr->shape()[2];

    std::ptrdiff_t total = xdim * ydim * zdim;

    ID* seg_raw = seg_ptr->data();

    for ( std::ptrdiff_t idx = 0; idx < total; ++idx )
    {
        seg_raw[idx] = remaps[sets.find_set(seg_raw[idx])];
    }

    std::cout << "Done with remapping, total: " << (next_id-1) << std::endl;

    region_graph<ID,F> new_rg;

    for ( auto& it: rg )
    {
        ID s1 = remaps[sets.find_set(std::get<1>(it))];
        ID s2 = remaps[sets.find_set(std::get<2>(it))];

        if ( s1 != s2 && s1 && s2 )
        {
            auto mm = std::minmax(s1,s2);
            new_rg.emplace_back(std::get<0>(it), mm.first, mm.second);
        }
    }

    rg.swap(new_rg);

    std::cout << "Done with updating the region graph, size: "
              << rg.size() << std::endl;
}