set_t doUnion(const set_t* s1, const set_t* s2)
{
	

	set_t unionSet;
	
	initSet( &unionSet );
	
	node_set_t* traverse;
	if(s1)
	{
		traverse = s1->head;
		
		while(traverse)
		{
			addElements(&unionSet, traverse->variable);
			traverse = traverse->link;
		}
	}
	if(s2)
	{
		traverse = s2->head;
		while(traverse)
		{
			addElements(&unionSet, traverse->variable);
			traverse = traverse->link;
		}
	}
	return unionSet;
}
Esempio n. 2
0
HelpDialog::HelpDialog() {
	// Set the title and game version
	_msgTitle.set(HELP_MSG, 172, ALIGN_CENTER);
	_msgTitle._bounds.moveTo(5, 0);
	_msgVersion.set(GAME_VERSION, 172, ALIGN_CENTER);
	_msgVersion._bounds.moveTo(5, _msgTitle._bounds.bottom + 3);
	addElements(&_msgTitle, &_msgVersion, NULL);

	// Set buttons
	_btnList[0].setText(F2);
	_btnList[0]._bounds.moveTo(5, _msgVersion._bounds.bottom + 2);
	_btnDescription[0].set(SOUND_OPTIONS, 140, ALIGN_LEFT);
	_btnDescription[0]._bounds.moveTo(_btnList[0]._bounds.right + 2, _btnList[0]._bounds.top + 4);

	_btnList[1].setText(F3);
	_btnList[1]._bounds.moveTo(5, _btnList[0]._bounds.bottom);
	_btnDescription[1].set(QUIT_GAME, 140, ALIGN_LEFT);
	_btnDescription[1]._bounds.moveTo(_btnList[1]._bounds.right + 2, _btnList[1]._bounds.top + 4);

	_btnList[2].setText(F4);
	_btnList[2]._bounds.moveTo(5, _btnList[1]._bounds.bottom);
	_btnDescription[2].set(RESTART_GAME, 140, ALIGN_LEFT);
	_btnDescription[2]._bounds.moveTo(_btnList[2]._bounds.right + 2, _btnList[2]._bounds.top + 4);

	_btnList[3].setText(F5);
	_btnList[3]._bounds.moveTo(5, _btnList[2]._bounds.bottom);
	_btnDescription[3].set(SAVE_GAME, 140, ALIGN_LEFT);
	_btnDescription[3]._bounds.moveTo(_btnList[3]._bounds.right + 2, _btnList[3]._bounds.top + 4);

	_btnList[4].setText(F7);
	_btnList[4]._bounds.moveTo(5, _btnList[3]._bounds.bottom);
	_btnDescription[4].set(RESTORE_GAME, 140, ALIGN_LEFT);
	_btnDescription[4]._bounds.moveTo(_btnList[4]._bounds.right + 2, _btnList[4]._bounds.top + 4);

	_btnList[5].setText(F8);
	_btnList[5]._bounds.moveTo(5, _btnList[4]._bounds.bottom);
	_btnDescription[5].set(SHOW_CREDITS, 140, ALIGN_LEFT);
	_btnDescription[5]._bounds.moveTo(_btnList[5]._bounds.right + 2, _btnList[5]._bounds.top + 4);

	_btnList[6].setText(F10);
	_btnList[6]._bounds.moveTo(5, _btnList[5]._bounds.bottom);
	_btnDescription[6].set(PAUSE_GAME, 140, ALIGN_LEFT);
	_btnDescription[6]._bounds.moveTo(_btnList[6]._bounds.right + 2, _btnList[6]._bounds.top + 4);

	for (int i = 0; i < 7; ++i) {
		addElements(&_btnList[i], &_btnDescription[i], NULL);
	}

	// Add 'Resume' button
	_btnResume.setText(RESUME_PLAY);
	_btnResume._bounds.moveTo(5, _btnList[6]._bounds.bottom + 2);
	addElements(&_btnResume, NULL);

	// Set the dialog size and position
	frame();
	_bounds.collapse(-6, -6);
	setCenter(160, 100);
}
Esempio n. 3
0
OptionsDialog::OptionsDialog() {
	// Set the element text
	_gfxMessage.set(OPTIONS_MSG, 140, ALIGN_LEFT);
	_btnRestore.setText(RESTORE_BTN_STRING);
	_btnSave.setText(SAVE_BTN_STRING);
	_btnRestart.setText(RESTART_BTN_STRING);
	_btnQuit.setText(QUIT_BTN_STRING);
	_btnSound.setText(SOUND_BTN_STRING);
	_btnResume.setText(RESUME_BTN_STRING);

	// Set position of the elements
	_gfxMessage._bounds.moveTo(0, 1);
	_btnRestore._bounds.moveTo(0, _gfxMessage._bounds.bottom + 1);
	_btnSave._bounds.moveTo(0, _btnRestore._bounds.bottom + 1);
	_btnRestart._bounds.moveTo(0, _btnSave._bounds.bottom + 1);
	_btnQuit._bounds.moveTo(0, _btnRestart._bounds.bottom + 1);
	_btnSound._bounds.moveTo(0, _btnQuit._bounds.bottom + 1);
	_btnResume._bounds.moveTo(0, _btnSound._bounds.bottom + 1);

	// Set all the buttons to the widest button
	GfxButton *btnList[6] = {&_btnRestore, &_btnSave, &_btnRestart, &_btnQuit, &_btnSound, &_btnResume};
	int16 btnWidth = 0;
	for (int idx = 0; idx < 6; ++idx)
		btnWidth = MAX(btnWidth, btnList[idx]->_bounds.width());
	for (int idx = 0; idx < 6; ++idx)
		btnList[idx]->_bounds.setWidth(btnWidth);

	// Add the items to the dialog
	addElements(&_gfxMessage, &_btnRestore, &_btnSave, &_btnRestart, &_btnQuit, &_btnSound, &_btnResume, NULL);

	// Set the dialog size and position
	frame();
	_bounds.collapse(-6, -6);
	setCenter(160, 90);
}
Esempio n. 4
0
/**
 * This dialog class provides a simple message display with support for either one or two buttons.
 */
MessageDialog::MessageDialog(const Common::String &message, const Common::String &btn1Message,
							 const Common::String &btn2Message) : GfxDialog() {
	// Set up the message
	addElements(&_msg, &_btn1, NULL);

	_msg.set(message, 200, ALIGN_LEFT);
	_msg._bounds.moveTo(0, 0);
	_defaultButton = &_btn1;

	// Set up the first button
	_btn1.setText(btn1Message);
	_btn1._bounds.moveTo(_msg._bounds.right - _btn1._bounds.width(), _msg._bounds.bottom + 2);

	if (!btn2Message.empty()) {
		// Set up the second button
		add(&_btn2);
		_btn2.setText(btn2Message);
		_btn2._bounds.moveTo(_msg._bounds.right - _btn2._bounds.width(), _msg._bounds.bottom + 2);
		_btn1._bounds.translate(-(_btn2._bounds.width() + 4), 0);
	}

	// Do post setup for the dialog
	setDefaults();

	// Set the dialog's center
	setCenter(g_globals->_dialogCenter.x, g_globals->_dialogCenter.y);
}
Esempio n. 5
0
InventoryDialog::InventoryDialog() {
	// Determine the maximum size of the image of any item in the player's inventory
	int imgWidth = 0, imgHeight = 0;

	SynchronizedList<InvObject *>::iterator i;
	for (i = RING_INVENTORY._itemList.begin(); i != RING_INVENTORY._itemList.end(); ++i) {
		InvObject *invObject = *i;
		if (invObject->inInventory()) {
			// Get the image for the item
			GfxSurface itemSurface = surfaceFromRes(invObject->_displayResNum, invObject->_rlbNum, invObject->_cursorNum);

			// Maintain the dimensions of the largest item image
			imgWidth = MAX(imgWidth, (int)itemSurface.getBounds().width());
			imgHeight = MAX(imgHeight, (int)itemSurface.getBounds().height());

			// Add the item to the display list
			GfxInvImage *img = new GfxInvImage();
			_images.push_back(img);
			img->setDetails(invObject->_displayResNum, invObject->_rlbNum, invObject->_cursorNum);
			img->_invObject = invObject;
			add(img);
		}
	}
	assert(_images.size() > 0);

	// Figure out the number of columns/rows to show all the items
	int cellsSize = 3;
	while ((cellsSize * cellsSize) < (int)_images.size())
		++cellsSize;

	// Set the position of each inventory item to be displayed
	int cellX = 0;
	Common::Point pt(0, 0);

	for (uint idx = 0; idx < _images.size(); ++idx) {
		if (cellX == cellsSize) {
			// Move to the start of the next line
			pt.x = 0;
			pt.y += imgHeight + 2;
			cellX = 0;
		}

		_images[idx]->_bounds.moveTo(pt.x, pt.y);

		pt.x += imgWidth + 2;
		++cellX;
	}

	// Set up the buttons
	pt.y += imgHeight + 2;
	_btnOk.setText(OK_BTN_STRING);
	_btnOk._bounds.moveTo((imgWidth + 2) * cellsSize - _btnOk._bounds.width(), pt.y);
	_btnLook.setText(LOOK_BTN_STRING);
	_btnLook._bounds.moveTo(_btnOk._bounds.left - _btnLook._bounds.width() - 2, _btnOk._bounds.top);
	addElements(&_btnLook, &_btnOk, NULL);

	frame();
	setCenter(SCREEN_CENTER_X, SCREEN_CENTER_Y);
}
Esempio n. 6
0
const char* Path::push(const char* element) {

    if (m_tagValue > 0)
        ++m_tagValue;

    if (m_count > 1 || (m_count == 1 && *m_buffer != '/'))
        write(PATH_SEP);

    addElements(element);
    return m_buffer;
}
Esempio n. 7
0
CharacterDialog::CharacterDialog() {
	// Set the element text
	_msgTitle.set(CHAR_TITLE, 140, ALIGN_LEFT);
	_btnQuinn.setText(CHAR_QUINN_MSG);
	_btnSeeker.setText(CHAR_SEEKER_MSG);
	_btnMiranda.setText(CHAR_MIRANDA_MSG);
	_btnCancel.setText(CHAR_CANCEL_MSG);

	// Set position of the elements
	_msgTitle._bounds.moveTo(5, 5);
	_btnQuinn._bounds.moveTo(25, _msgTitle._bounds.bottom + 1);
	_btnSeeker._bounds.moveTo(25, _btnQuinn._bounds.bottom + 1);
	_btnMiranda._bounds.moveTo(25, _btnSeeker._bounds.bottom + 1);
	_btnCancel._bounds.moveTo(25, _btnMiranda._bounds.bottom + 1);

	// Add the items to the dialog
	addElements(&_msgTitle, &_btnQuinn, &_btnSeeker, &_btnMiranda, &_btnCancel, NULL);

	// Set the dialog size and position
	frame();
	_bounds.collapse(-6, -6);
	setCenter(160, 100);
}
Esempio n. 8
0
int main()
{
  struct node *head1=NULL,*addele=NULL;
  head=insert(head,5);
  insert(head,6);
  insert(head,3);

  display(head);


  head1=insert(head1,8);
   insert(head1,4);
  insert(head1,2);

  display(head1);


  addele=addElements(head,head1);
  display(addele);


  return 0;
}
Esempio n. 9
0
DisjointSet::DisjointSet (const uint size) {
	addElements(size);
}
Esempio n. 10
0
int main() {
  ColoredGraph<GraphVertex,TriColor> gr;
  set<GraphVertex,less<GraphVertex> > groupsall, filesall,functionsall;
  set<GraphVertex,less<GraphVertex> > groupssome, filessome,functionssome,S;
  set<GraphVertex,less<GraphVertex> > groupsnot, filesnot,functionsnot;
  ifstream ifs1("groups.txt");
  ifstream ifs2("files.txt");
  ifstream ifs3("files.txt");
  ifstream ifs4("choices.txt");
  cerr << "reading groups";
  readDoubleColumnGraph(ifs1,groupsall,gr,true);
  cerr << ", files";
  readDoubleColumnGraph(ifs2,filesall,gr,true);
  cerr << ", functions\n";
  readDoubleColumnGraph(ifs3,functionsall,gr,false);
  readSingleColumn(ifs4,gr);
#if 1
  ifstream ifs5("depends.txt");
  list<list<string> > dbllist;
  readMultiColumns(ifs5,dbllist);
#endif
  bool todo  = true;
  while(todo) {
    todo = false;
    gr.ColorChildComponents(TriColor::s_one,TriColor::s_two);
    list<GraphVertex> L(gr.getColored(TriColor::s_two));
    copy(L.begin(),L.end(),inserter(S,S.begin()));
#if 1
    todo = addElements(gr,TriColor::s_one,S,dbllist);
    cerr << "addelements give " << todo << '\n';
#endif
  };
  cerr << "Here is the set after the loop:\n";
  printset(cerr,S,",");
  set_intersection(S.begin(),S.end(),groupsall.begin(),groupsall.end(),
                   inserter(groupssome,groupssome.begin()));
  set_intersection(S.begin(),S.end(),filesall.begin(),filesall.end(),
                   inserter(filessome,filessome.begin()));
  set_intersection(functionsall.begin(),functionsall.end(),S.begin(),S.end(),
                   inserter(functionssome,functionssome.begin()));
  set_difference(groupsall.begin(),groupsall.end(),S.begin(),S.end(),
                   inserter(groupsnot,groupsnot.begin()));
  set_difference(filesall.begin(),filesall.end(),S.begin(),S.end(),
                   inserter(filesnot,filesnot.begin()));
  set_difference(functionsall.begin(),functionsall.end(),S.begin(),S.end(),
                   inserter(functionsnot,functionsnot.begin()));
  cerr << "all groups:\n";
  printset(cerr,groupsall,", ");
  cerr << "\nall files:\n";
  printset(cerr,filesall,", ");
  cerr << "\nall functions:\n";
  printset(cerr,functionsall,", ");
  cerr << "\n\n\n";
  cerr << "groups (not):\n";
  printset(cerr,groupsnot,", ");
  cerr << "\nfiles (not):\n";
  printset(cerr,filesnot,", ");
  cerr << "\nfunctions(not):\n";
  printset(cerr,functionsnot,", ");
  cerr << "\n\n\n";
  cerr << "groups:\n";
  printset(cerr,groupssome,", ");
  cerr << "\nfiles:\n";
  printset(cerr,filessome,", ");
  cerr << "\nfunctions:\n";
  printset(cerr,functionssome,", ");

  cerr << "Staring creation of the file Makefile.mark\n";
  ofstream ofs("Makefile.mark");
  ofs << "p9clist = ";
  printset(ofs,filessome,".o \\\n",".o \n");
  ofs.close();
  cerr << "Ended creation of the file Makefile.mark\n";

  cerr << "Staring creation of the file Makefile.cp\n";
  ofstream ofs2("Makefile.cp");
  ofs2 << "cp ";
  printset(ofs2,filessome,".[hc]pp copyplace/ \n cp ",".[hc]pp copyplace/ \n");
  ofs2.close();
  cerr << "Ended creation of the file Makefile.cp\n";
};
Esempio n. 11
0
Path::Path(const char* path) {

    init();
    addElements(path);
}
Esempio n. 12
0
		void addAllElements(const DataKey& key) {
			addElements(key.getElements());
		}
Esempio n. 13
0
		void initFrom(const std::set<DataKeyElement>& elements) {
			init();
			addElements(elements);
		}