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 ++;
}
Exemplo n.º 2
0
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 );
}
Exemplo n.º 3
0
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 );
}
Exemplo n.º 4
0
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 );
}
Exemplo n.º 5
0
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 );
}
Exemplo n.º 6
0
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()));
}
Exemplo n.º 7
0
Arquivo: main.cpp Projeto: 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;
}