Пример #1
0
void MainWindow::on_pushButton_2_clicked()
{
    QModelIndexList selection=ui->table_input->selectionModel()->selectedIndexes();
    if(ui->table_input->columnCount()>1) deleteIndeces(&selection);
    sortIndeces(&selection);
    for (int i = 0; i < selection.count(); ++i) {
        ui->table_input->removeRow(selection.at(i).row()-i);

    }
}
Пример #2
0
/**
 * Build a sparse array from the given indices and values with 
 * specific length.
 *
 * Arguments:
 * value    Array of values
 * index    Array of indices
 * length   Length of the above arrays
 *
 * Returns:
 * A sparse array.
 *
 * If a sparse array node has { value = 1000, index = 2 }, then that means that
 * the index "2" caries the value "1000". This is meant to convey an array of 1000 
 * "2s", but instead of creating 1000 nodes in your linked list, you only create
 * 1 node, and that note conceptually has 1000 "copies" of it. Hence 
 * each node in a sparse array has a "value" in addition to its "index".
 *
 * Note that an index can never carry the value of "0", because this would not make
 * any sense; however, negative values are fine. A negative value may seem odd
 * at first blush; however, this is like substraction, and makes sense for certain
 * cases.
 *
 * You need to insert nodes in ascending order by index.
 * See the notes to "List_insert_ascend"
 */
Node * List_build(int * value, int * index, int length)
{
	int i;
	Node* n = NULL;
	sortIndeces(value, index, length);
	for(i = 0;i < length;i++){
		n = List_insert_ascend(n, value[i], index[i]);
	}

  return n;
}