/** Intializes the PartResizerWidget
	@param d the Device the Partition is on
	@param p the Partition to show and/or resize
	@param minFirst the minimum value for the first sector
	@param maxLast the maximum value for the last sector
*/
void PartResizerWidget::init(Device& d, Partition& p, qint64 minFirst, qint64 maxLast, bool read_only, bool move_allowed)
{
    setDevice(d);
    setPartition(p);

    setMinimumFirstSector(minFirst);
    setMaximumLastSector(maxLast);

    setReadOnly(read_only);
    setMoveAllowed(move_allowed);

    setMinimumLength(qMax(partition().sectorsUsed(), partition().minimumSectors()));
    setMaximumLength(qMin(totalSectors(), partition().maximumSectors()));

    // set margins to accommodate to top/bottom button asymmetric layouts
    QStyleOptionButton bOpt;
    bOpt.initFrom(this);

    QRect buttonRect(style()->subElementRect(QStyle::SE_PushButtonContents, &bOpt));

    int asym = (rect().bottom() - buttonRect.bottom()) - (buttonRect.top() - rect().top());
    if (asym > 0)
        setContentsMargins(0, asym, 0, 0);
    else
        setContentsMargins(0, 0, 0, asym);

    if (!readOnly())
    {
        QPixmap pixmap(handleWidth(), handleHeight());
        pixmap.fill(Qt::transparent);
        QPainter p(&pixmap);
        QStyleOption opt;
        opt.state |= QStyle::State_Horizontal;
        opt.rect = pixmap.rect().adjusted(0, 2, 0, -2);
        style()->drawControl(QStyle::CE_Splitter, &opt, &p, this);

        leftHandle().setPixmap(pixmap);
        rightHandle().setPixmap(pixmap);

        leftHandle().setFixedSize(handleWidth(), handleHeight());
        rightHandle().setFixedSize(handleWidth(), handleHeight());
    }

    delete m_PartWidget;
    m_PartWidget = new PartWidget(this, &partition());

    if (!readOnly())
    {
        leftHandle().setCursor(Qt::SizeHorCursor);
        rightHandle().setCursor(Qt::SizeHorCursor);
    }

    if (moveAllowed())
        partWidget().setCursor(Qt::SizeAllCursor);

    partWidget().setToolTip(QString());

    updatePositions();
}
vector<vector<string> > Solution::partition(string A) {
    // Do not write main() function.
    // Do not read input, instead use the arguments to the function.
    // Do not print the output, instead return values as specified
    // Still have a doubt. Checkout www.interviewbit.com/pages/sample_codes/ for more details
    vector<vector<string> > result;
    vector<string> curStrVec;
    
    setPartition(result, curStrVec, A, 0);
    
    return result;
}
Example #3
0
void BaseObject::init()
{
#ifdef SOFA_SMP
    if(!context_||!context_->is_partition())
        setPartition(new Iterative::IterativePartition());
#endif

	for(VecData::const_iterator iData = this->m_vecData.begin(); iData != this->m_vecData.end(); ++iData)
	{
		if ((*iData)->isRequired() && !(*iData)->isSet())
		{
            serr << "Required data \"" << (*iData)->getName() << "\" has not been set. (Current value is " << (*iData)->getValueString() << ")" << sendl;
		}
	}
}
void setPartition(vector<vector<string> > &result, vector<string> &curStrVec, string A, int low) {
    if(low == A.size())
    {
        result.push_back(curStrVec);
        return;
    }
    
    for(int high = low+1; high <= A.size(); high++) {
        
        string curStr(A.begin()+low, A.begin()+high);
        
        if(isParlin(curStr)) {
            // save the current vector information
            //int curSize = curStrVec.size();
            // put the current string to the current vector
            curStrVec.push_back(curStr);
            // check from the next position
            setPartition(result, curStrVec, A, high);
            // set back
            //curStrVec.resize(curSize);
            curStrVec.pop_back();
        }
    }
}