コード例 #1
0
void LinkedListPriorityQueue::enqueue(string value) {
	Cell *newCell = new Cell;
    newCell->word = value;
    if (isEmpty()) {
        head = newCell;
        newCell->next = NULL;    
    
    } else {
        Cell *previous = NULL;
        Cell *current = head;
        findInsertionPoint(previous, current, value);
        if(previous == NULL) {
            //Front of List
            newCell->next = current;
            head = newCell;
        } else {
            //Middle of List
            newCell->next = current;
            previous->next = newCell;
        }
        newCell->word = value;
        if (previous) {
            previous->next = newCell;
        }
    }
    count ++;
}
コード例 #2
0
ファイル: ingredientcombobox.cpp プロジェクト: KDE/krecipes
void IngredientComboBox::createIngredient( const Element &element )
{
	int row = findInsertionPoint( element.name );

	QString remember_text;
	if ( isEditable() )
		remember_text = lineEdit()->text();

	insertItem( row, element.name );
	completionObject()->addItem(element.name);

	if ( isEditable() )
		lineEdit()->setText( remember_text );

	//now update the map by pushing everything after this item down
	QMap<int, int> new_map;
	for ( QMap<int, int>::iterator it = ingredientComboRows.begin(); it != ingredientComboRows.end(); ++it ) {
		if ( it.key() >= row ) {
			new_map.insert( it.key() + 1, it.value() );
		}
		else
			new_map.insert( it.key(), it.value() );
	}
	ingredientComboRows = new_map;
	ingredientComboRows.insert( row, element.id );
}
コード例 #3
0
ファイル: win32_popup.cpp プロジェクト: mstorsjo/vlc
void Win32Popup::addSeparator( int pos )
{
    MENUITEMINFO sepItem;
    sepItem.cbSize = sizeof( MENUITEMINFO );
    sepItem.fMask = MIIM_FTYPE;
    sepItem.fType = MFT_SEPARATOR;

    InsertMenuItem( m_hMenu, findInsertionPoint( pos ), TRUE, &sepItem );
}
コード例 #4
0
ファイル: os2_popup.cpp プロジェクト: 12307/VLC-for-VS2010
void OS2Popup::addSeparator( int pos )
{
    MENUITEM mi;

    mi.iPosition   = findInsertionPoint( pos );
    mi.afStyle     = MIS_SEPARATOR;
    mi.afAttribute = 0;
    mi.id          = 0;
    mi.hwndSubMenu = NULLHANDLE;
    mi.hItem       = NULLHANDLE;

    WinSendMsg( m_hMenu, MM_INSERTITEM, MPFROMP( &mi ), 0 );
}
コード例 #5
0
ファイル: win32_popup.cpp プロジェクト: mstorsjo/vlc
void Win32Popup::addItem( const std::string &rLabel, int pos )
{
    MENUITEMINFO menuItem;
    menuItem.cbSize = sizeof( MENUITEMINFO );
//     menuItem.fMask = MIIM_FTYPE | MIIM_ID | MIIM_TYPE | MIIM_STRING;
//     menuItem.fType = MFT_STRING;
    menuItem.fMask = MIIM_ID | MIIM_STRING;
    menuItem.wID = pos;
    menuItem.dwTypeData = ToT(rLabel.c_str());
    menuItem.cch = rLabel.size();

    InsertMenuItem( m_hMenu, findInsertionPoint( pos ), TRUE, &menuItem );
}
コード例 #6
0
ファイル: os2_popup.cpp プロジェクト: 12307/VLC-for-VS2010
void OS2Popup::addItem( const string &rLabel, int pos )
{
    MENUITEM mi;

    mi.iPosition   = findInsertionPoint( pos );
    mi.afStyle     = MIS_TEXT;
    mi.afAttribute = 0;
    mi.id          = pos;
    mi.hwndSubMenu = NULLHANDLE;
    mi.hItem       = NULLHANDLE;

    WinSendMsg( m_hMenu, MM_INSERTITEM, MPFROMP( &mi ),
                MPFROMP( rLabel.c_str()));
}
コード例 #7
0
ファイル: main.cpp プロジェクト: htano/study
int
insertionSort(int* array, int num, int g)
{
    int cnt = 0;

    for (int i = g; i < num; i=i+g) {
        int target = array[i];
        int point  = findInsertionPoint(array, i-g, target, g);
        for (int j = i; j > point; j=j-g) {
            array[j] = array[j-g];
//            gCnt++;
        }
        gCnt++;
        array[point] = target;
    }


    return cnt;
}