//-----------------------------------------------------------------------------
// Fixes up all elements
//-----------------------------------------------------------------------------
void CImportSFMV6::BuildList( CDmElement *pElement, CUtlRBTree< CDmElement *, int >& list )
{
	if ( !pElement )
		return;

	if ( list.Find( pElement ) != list.InvalidIndex() )
		return;

	list.Insert( pElement );

	// Descend to bottom of tree, then do fixup coming back up the tree
	for ( CDmAttribute *pAttribute = pElement->FirstAttribute(); pAttribute; pAttribute = pAttribute->NextAttribute() )
	{
		if ( pAttribute->GetType() == AT_ELEMENT )
		{
			CDmElement *pElement = pAttribute->GetValueElement<CDmElement>( );
			BuildList( pElement, list );
			continue;
		}

		if ( pAttribute->GetType() == AT_ELEMENT_ARRAY )
		{
			CDmrElementArray<> array( pAttribute );
			int nCount = array.Count();
			for ( int i = 0; i < nCount; ++i )
			{
				CDmElement *pChild = array[ i ];
				BuildList( pChild, list );
			}
			continue;
		}
	}
}
int main()
{
	int m, n;
	while (scanf("%d %d", &m, &n) != EOF)
	{
		ListNode* head1 = BuildList(m);
		ListNode* head2 = BuildList(n);

		int diff = m-n;
		ListNode* pHeadLong = head1;
		ListNode* pHeadShort = head2;
		if (m < n)
		{
			diff = n-m;
			pHeadLong = head2;
			pHeadShort = head1;
		}

		// forward to the proper position
		for (int i = 0; i < diff; ++i)
			pHeadLong = pHeadLong->pNext;

		bool bFound = false;
		while (pHeadLong)
		{ // search for the first common node
			if (pHeadLong->nValue == pHeadShort->nValue)
			{
				bFound = true;
				break;
			}
			else
			{
				pHeadLong = pHeadLong->pNext;
				pHeadShort = pHeadShort->pNext;
			}
		}

		if (bFound)
			printf("%d\n", pHeadLong->nValue);
		else
			printf("My God\n");

		DestroyList(head1);
		DestroyList(head2);
	}

	return 0;
}
void GUIgraph::SetDatasets(const vector<GUIgraph::Dataset>& newData,bool showDif,int button,string name)
{
	this->showDif=showDif;
	graphNames[button]=name;
	data[button].clear();
	data[button].insert(data[button].begin(), newData.begin(), newData.end());
	maximum=0;
	
	for(int a=0;a<2;++a){
		vector<GUIgraph::Dataset>::iterator i=data[a].begin();
		vector<GUIgraph::Dataset>::iterator e=data[a].end();

		for(;i!=e; i++)
		{
			vector<float>::iterator j=i->points.begin();
			vector<float>::iterator k=i->points.end();
			float last=0;
		
			for(;j!=k; j++){
				if(*j-last>maximum)
					maximum=*j-last;
				if(showDif)
					last=*j;
			}
		}
	}
	
	BuildList();
}
Example #4
0
static void LeaveDirectory( void ) {
    char *s;
    int i;

    s = strrchr( m_demos.browse, '/' );
    if( !s ) {
        return;
    }
    *s = 0;

    // rebuild list
    FreeList();
    BuildList();
    MenuList_Init( &m_demos.list );

    // move cursor to the previous directory
    for( i = 0; i < m_demos.numDirs; i++ ) {
        demoEntry_t *e = m_demos.list.items[i];
        if( !strcmp( e->name, s + 1 ) ) {
            MenuList_SetValue( &m_demos.list, i );
            break;
        }
    }

    if( s == m_demos.browse ) {
        m_demos.browse[0] = '/';
        m_demos.browse[1] = 0;
    }
}
Example #5
0
static menuSound_t Activate( menuCommon_t *self ) {
    size_t len, baselen;
    demoEntry_t *e = m_demos.list.items[m_demos.list.curvalue];

    switch( e->type ) {
    case ENTRY_UP:
        LeaveDirectory();
        return QMS_OUT;

    case ENTRY_DN:
        baselen = strlen( m_demos.browse );
        len = strlen( e->name );
        if( baselen + 1 + len >= sizeof( m_demos.browse ) ) {
            return QMS_BEEP;
        }
        if( !baselen || m_demos.browse[ baselen - 1 ] != '/' ) {
            m_demos.browse[ baselen++ ] = '/';
        }
        memcpy( m_demos.browse + baselen, e->name, len + 1 );
        
        // rebuild list
        FreeList();
        BuildList();
        MenuList_Init( &m_demos.list );
        return QMS_IN;

    case ENTRY_DEMO:
        Cbuf_AddText( &cmd_buffer, va( "demo \"%s/%s\"\n", m_demos.browse[1] ?
            m_demos.browse : "", e->name ) );
        return QMS_SILENT;
    }

    return QMS_NOTHANDLED;
}
void Test1()
{
    ListNode* pHead = BuildList();
    ListNode* pReversedHead = Test("Test1", pHead, 1);

    DestroyList(pReversedHead);
}
Example #7
0
static menuSound_t LeaveDirectory(void)
{
    char    *s;
    int     i;

    s = strrchr(m_demos.browse, '/');
    if (!s) {
        return QMS_BEEP;
    }

    if (s == m_demos.browse) {
        strcpy(m_demos.browse, "/");
    } else {
        *s = 0;
    }

    // rebuild list
    FreeList();
    BuildList();
    MenuList_Init(&m_demos.list);

    // move cursor to the previous directory
    for (i = 0; i < m_demos.numDirs; i++) {
        demoEntry_t *e = m_demos.list.items[i];
        if (!strcmp(e->name, s + 1)) {
            MenuList_SetValue(&m_demos.list, i);
            break;
        }
    }

    return QMS_OUT;
}
GUIgraph::GUIgraph(int x, int y, int w, int h):GUIframe(x, y, w, h)
{
	displayList=glGenLists(1);

	showDif=false;
	timebase=1;
	BuildList();
}
Example #9
0
void ProjectPrefsGUI::DoRemove(void)
{

ActiveItem = WidgetLBGetCurSel(IDC_PARLIST);
HostProj->DL = HostProj->DirList_Remove(HostProj->DL, (short)ActiveItem);
BuildList(ActiveItem);

} // ProjectPrefsGUI::DoRemove()
Example #10
0
eOSState cMenuSearchResults::OnYellow()
{
   eOSState state = osUnknown;
   if(!HasSubMenu())
   {
      modeYellow = (modeYellow==showTitleEpisode?showEpisode:showTitleEpisode);
      BuildList();
      state = osContinue;
   }
   return state;
}
Example #11
0
eOSState cMenuSearchResults::OnGreen()
{
   eOSState state = osUnknown;
   if(!HasSubMenu())
   {
      m_bSort=!m_bSort;
      BuildList();
      state = osContinue;
   }
   return state;
}
void GUIbutton::SetCaption(const string& capt)
{
	caption=capt;
	
	if(autosizing)
	{
		w=(int)(guifont->GetWidth(caption.c_str()))+14;
	}
	
	BuildList();
}
Example #13
0
BOOL CDialogClasses::OnInitDialog( )
{
	m_ImageList.Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32, 1, 1);
	m_ImageList.SetBkColor(RGB(255, 255, 255));
	m_hClassIcon = LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON_CLASS));
	m_ImageList.Add(m_hClassIcon);
	
	BuildList();

	return TRUE;
}
Example #14
0
void ProjectPrefsGUI::DoAdd(void)
{
struct DirList *DLNew;

if (DLNew = HostProj->DirList_Add(HostProj->DL, NULL, 0))
	{
	if (! HostProj->DL)
		HostProj->DL = DLNew;
	BuildList(HostProj->DirList_ItemExists(HostProj->DL, DLNew->Name));
	} // if

} // ProjectPrefsGUI::DoAdd()
Example #15
0
static void Expose( menuFrameWork_t *self ) {
    time_t now = time( NULL );
    struct tm *tm = localtime( &now );

    if( tm ) {
        m_demos.year = tm->tm_year;
    }

    BuildList();
    // move cursor to previous position
    MenuList_SetValue( &m_demos.list, m_demos.selection );
}
Example #16
0
// --- cMenuSearchResultsForBlacklist -------------------------------------------------------
cMenuSearchResultsForBlacklist::cMenuSearchResultsForBlacklist(cBlacklist* Blacklist)
   :cMenuSearchResults(cTemplFile::GetTemplateByName("MenuSearchResults"))
{
   ButtonBlue[0] = tr("Button$all channels");
   ButtonBlue[1] = tr("Button$only FTA");
   ButtonBlue[2] = tr("Button$Timer preview");

   blacklist = Blacklist;
   m_bSort = true;
   modeBlue = blacklist->useChannel==3?showNoPayTV:(EPGSearchConfig.ignorePayTV?showNoPayTV:showAll);

   BuildList();
}
Example #17
0
BOOL CEnvelopeTypeDialog::OnInitDialog()
{
	CPmwDialogColor::OnInitDialog();

	m_List.ReadList("ENVELOPE.DAT");

	BuildList();

   CreateWizzardButtons ();
   EnableWizardButtons (m_WizFlags);

	return TRUE;  // return TRUE  unless you set the focus to a control
}
Example #18
0
// --- cMenuSearchResultsForList -------------------------------------------------------
cMenuSearchResultsForList::cMenuSearchResultsForList(cSearchResults& SearchResults, const char* Title, bool IgnoreRunning)
   :cMenuSearchResults(cTemplFile::GetTemplateByName("MenuSearchResults"))
{
   ButtonBlue[0] = tr("Button$Setup");
   searchResults = &SearchResults;
   m_bSort = true;
   ignoreRunning = IgnoreRunning;

   BuildList();

   cString szTitle = cString::sprintf(Title, Count());
   SetTitle(szTitle);
}
Example #19
0
int main() {
    
    Node *Head;
    
    Head = InitList();
    PrintList(Head);	/* Print the initial list */
    
    BuildList(Head);
    
    PrintList(Head);	/* Print the list again */
    DeleteList(Head);
    
    return 0;
}
Example #20
0
				/*
				 * ============================================================
				 * Function		: BuildShapes
				 *
				 * Description	: Compiles buildlists for the shapes that the 
				 *				  the gfxParticle objectsneed. 
				 * ============================================================
				 */
				void BuildShapes() throw() {
					for ( size_t part = 0; part < activeCount; part++ ) {
						if ( shapes.find( particleArray[part].shape ) == shapes.end() ) {	// Check if there is a build list for this shape
								// If not found hen we need to add this shape to
								// the shapes container with the gfxShape as  the key
								shapes.emplace( particleArray[part].shape, static_cast<GLuint>( shapes.size() ) );

								// gfxParticle shape is definitely in shapes container
								BuildList( particleArray[part].shape.type,					// Type of shape to build
										   particleArray[part].shape.size,					// Size of shape to build
										   &shapes[particleArray[part].shape] );			// Pointer to built shape handle
						}
					}
				}
Example #21
0
//++
//------------------------------------------------------------------------------------
// Details: Add another MI result object to  the value list's of list is
// results.
//          Only result objects can be added to a list of result otherwise this
//          function
//          will return MIstatus::failure.
// Type:    Method.
// Args:    vResult - (R) The MI result object.
// Return:  None.
// Throws:  None.
//--
void CMICmnMIValueList::BuildList(const CMICmnMIValueResult &vResult) {
  // Clear out the default "<Invalid>" text
  if (m_bJustConstructed) {
    m_bJustConstructed = false;
    m_strValue = vResult.GetString();
    BuildList();
    return;
  }

  const CMIUtilString data(ExtractContentNoBrackets());
  const char *pFormat = "[%s,%s]";
  m_strValue =
      CMIUtilString::Format(pFormat, data.c_str(), vResult.GetString().c_str());
}
Example #22
0
// --- cMenuSearchResultsForSearch -------------------------------------------------------
cMenuSearchResultsForSearch::cMenuSearchResultsForSearch(cSearchExt* SearchExt, cMenuTemplate* MenuTemplate)
   :cMenuSearchResults(MenuTemplate)
{
   ButtonBlue[0] = tr("Button$all channels");
   ButtonBlue[1] = tr("Button$only FTA");
   ButtonBlue[2] = tr("Button$Timer preview");

   searchExt = SearchExt;
   m_bSort = true;
   if (searchExt)
   {
      modeBlue = searchExt->useChannel==3?showNoPayTV:(EPGSearchConfig.ignorePayTV?showNoPayTV:showAll);
      BuildList();
   }
}
Example #23
0
// --- cMenuSearchResultsForRecs -------------------------------------------------------
cMenuSearchResultsForRecs::cMenuSearchResultsForRecs(const char *query)
   :cMenuSearchResultsForQuery(NULL)
{
   SetTitle(tr("found recordings"));
   if (query)
   {
      searchExt = new cSearchExt;
      strcpy(searchExt->search, query);
      searchExt->mode = 0; // substring
      searchExt->useTitle = 1;
      searchExt->useSubtitle = 0;
      searchExt->useDescription = 0;
      BuildList();
   }
}
Example #24
0
fsInternetResult fsFtpFiles::GetList(LPCTSTR pszPath)
{
	fsInternetResult ir;

	m_bAbort = FALSE;

	m_strPath = pszPath;

	
	ir = m_pServer->SetCurrentDirectory (pszPath);
	if (ir != IR_SUCCESS)
		return ir;

	
	return BuildList ();
}
void GUIbutton::SetSize(int w1, int h1)
{
	if(w1==0)
		autosizing=true;
	else
		autosizing=false;
	h=max(20, h1);
	
	if(autosizing)
	{
		w=(int)(guifont->GetWidth(caption.c_str()))+14;
	}
	else
		w=w1;
	BuildList();
}
Example #26
0
GUIpane::GUIpane(int x, int y, int w, int h) : GUIframe(x, y, w, h)
{
	displayList=glGenLists(1);

	dragging=false;
	resizing=false;
	canDrag=false;
	canResize=false;
	drawFrame=true;
	downInside=false;

	minW=50;
	minH=50;
	
	BuildList();
}
Example #27
0
//++ ------------------------------------------------------------------------------------
// Details:	Add another MI value object to  the value list's of list is values.
//			Only values objects can be added to a list of values otherwise this function 
//			will return MIstatus::failure.
// Type:	Method.
// Args:	vValue	- (R) The MI value object.
// Return:	MIstatus::success - Functional succeeded.
//			MIstatus::failure - Functional failed.
// Throws:	None.
//--
bool CMICmnMIValueList::BuildList( const CMICmnMIValue & vValue )
{
	// Clear out the default "<Invalid>" text
	if( m_bJustConstructed )
	{
		m_bJustConstructed = false;
		m_strValue = vValue.GetString();
		return BuildList();
	}

	const MIchar * pFormat = "[%s,%s]";
	m_strValue = m_strValue.FindAndReplace( "[", "" );
	m_strValue = m_strValue.FindAndReplace( "]", "" );	
	m_strValue = CMIUtilString::Format( pFormat, m_strValue.c_str(), vValue.GetString().c_str() );

	return MIstatus::success;
}
Example #28
0
void AwayEditorWindow::DeleteMessage() {

	if( client->AwayMode() == AM_STANDARD_MESSAGE ) {
		if( client->CurrentAwayMessageName() == currentMsg ) {
			windows->ShowMessage( Language.get("AME_ERR1"), B_INFO_ALERT );
			return;
		}
	}

	prefs->RemoveAwayMessage( currentMsg );
	currentMsg = "";
	hasSelection = false;
	isDirty = false;
	genView->textview->MakeDirty(false);
	BuildList();
	EnableMessageStuff(false);
	PostAppMessage( new BMessage(BEAIM_LOAD_AWAY_MENU) );
}
Example #29
0
// --- cMenuSearchResultsForQuery -------------------------------------------------------
cMenuSearchResultsForQuery::cMenuSearchResultsForQuery(const char *query, bool IgnoreRunning)
   :cMenuSearchResultsForSearch(NULL, cTemplFile::GetTemplateByName("MenuSearchResults"))
{
   modeBlue = EPGSearchConfig.ignorePayTV?showNoPayTV:showAll;
   ignoreRunning = IgnoreRunning;
   // create a dummy search
   if (query)
   {
      searchExt = new cSearchExt;
      strcpy(searchExt->search, query);
      searchExt->mode = 0; // substring
      searchExt->useTitle = 1;
      searchExt->useSubtitle = 0;
      searchExt->useDescription = 0;
      searchExt->blacklistMode = blacklistsNone;
      BuildList();
   }
}
Example #30
0
//++
//------------------------------------------------------------------------------------
// Details: Add another MI value object to  the value list's of list is values.
//          Only values objects can be added to a list of values otherwise this
//          function
//          will return MIstatus::failure.
// Type:    Method.
// Args:    vValue  - (R) The MI value object.
// Return:  None.
// Throws:  None.
//--
void CMICmnMIValueList::BuildList(const CMICmnMIValue &vValue) {
  // Clear out the default "<Invalid>" text
  if (m_bJustConstructed) {
    m_bJustConstructed = false;
    m_strValue = vValue.GetString();
    BuildList();
    return;
  }

  // Remove already present '[' and ']' from the start and end
  m_strValue = m_strValue.Trim();
  size_t len = m_strValue.size();
  if ((len > 1) && (m_strValue[0] == '[') && (m_strValue[len - 1] == ']'))
    m_strValue = m_strValue.substr(1, len - 2);
  const char *pFormat = "[%s,%s]";
  m_strValue = CMIUtilString::Format(pFormat, m_strValue.c_str(),
                                     vValue.GetString().c_str());
}