当前位置: 首页>>代码示例>>C++>>正文


C++ JArray::SetElement方法代码示例

本文整理汇总了C++中JArray::SetElement方法的典型用法代码示例。如果您正苦于以下问题:C++ JArray::SetElement方法的具体用法?C++ JArray::SetElement怎么用?C++ JArray::SetElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JArray的用法示例。


在下文中一共展示了JArray::SetElement方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetX

void
GDBPlot2DCommand::HandleSuccess
	(
	const JString& data
	)
{
	JArray<JFloat>* x = GetX();
	JArray<JFloat>* y = GetY();

	if ((GetLastResult()).BeginsWith("error,msg=\"No symbol"))
		{
		x->RemoveAll();
		y->RemoveAll();
		return;
		}

	const JIndex count = x->GetElementCount();

	JIndex i;
	JIndexRange r;
	JArray<JIndexRange> matchRange1, matchRange2;
	JString v1, v2;
	for (i=1; i<=count; i++)
		{
		if (!prefixPattern.MatchAfter(data, r, &matchRange1))
			{
			break;
			}
		r = matchRange1.GetElement(1);

		if (!prefixPattern.MatchAfter(data, r, &matchRange2))
			{
			break;
			}
		r = matchRange2.GetElement(1);

		v1 = data.GetSubstring(matchRange1.GetElement(2));
		v1.TrimWhitespace();

		v2 = data.GetSubstring(matchRange2.GetElement(2));
		v2.TrimWhitespace();

		JFloat x1, y1;
		if (!v1.ConvertToFloat(&x1) ||
			!v2.ConvertToFloat(&y1))
			{
			break;
			}

		x->SetElement(i, x1);
		y->SetElement(i, y1);
		}

	if (i <= count)
		{
		const JSize delta = count - (i-1);
		x->RemoveNextElements(count - delta + 1, delta);
		y->RemoveNextElements(count - delta + 1, delta);
		}
}
开发者ID:jafl,项目名称:jx_application_framework,代码行数:60,代码来源:GDBPlot2DCommand.cpp

示例2:

void
GRaggedFloatTableData::SetElement
	(
	const JIndex	row,
	const JIndex	col,
	const JFloat	data
	)
{
	CreateCellIfNeeded(row, col);
	JArray<JFloat>* dataCol = itsCols->NthElement(col);
	dataCol->SetElement(row, data);
	if (itsBroadcast)
		{
		Broadcast(JTableData::RectChanged(row,col));
		}
}
开发者ID:jafl,项目名称:jx_application_framework,代码行数:16,代码来源:GRaggedFloatTableData.cpp

示例3: GetDataColCount

void
GRaggedFloatTableData::SetRow
	(
	const JIndex				index,
	const JArray<JFloat>&	rowData
	)
{
	const JSize colCount = GetDataColCount();
	assert( rowData.GetElementCount() == colCount );

	for (JIndex i=1; i<=colCount; i++)
		{
		JArray<JFloat>* dataCol = itsCols->NthElement(i);
		dataCol->SetElement(index, rowData.GetElement(i));
		}

	Broadcast(JTableData::RectChanged(JRect(index, 1, index+1, colCount+1)));
}
开发者ID:jafl,项目名称:jx_application_framework,代码行数:18,代码来源:GRaggedFloatTableData.cpp

示例4: rect

void
GRaggedFloatTableData::SetCol
	(
	const JIndex			index,
	const JOrderedSet<JFloat>&	colData
	)
{
	JArray<JFloat>* dataCol = itsCols->NthElement(index);
	const JSize rowCount = colData.GetElementCount();
	CreateCellIfNeeded(rowCount, index);

	for (JIndex i=1; i<=rowCount; i++)
		{
		dataCol->SetElement(i, colData.GetElement(i));
		}

	JRect rect(1, index, rowCount + 1, index + 1);
	if (itsBroadcast)
		{
		Broadcast(JTableData::RectChanged(rect));
		}
}
开发者ID:jafl,项目名称:jx_application_framework,代码行数:22,代码来源:GRaggedFloatTableData.cpp

示例5: if

JBoolean
JPartition::SetCompartmentSize
	(
	const JIndex		index,
	const JCoordinate	reqSize
	)
{
	const JCoordinate origSize = GetCompartmentSize(index);

	JArray<JCoordinate> newSizes;
	JCoordinate trueSize;
	if (reqSize > origSize &&
		CreateSpace(*itsSizes, *itsMinSizes, itsElasticIndex,
					reqSize - origSize, reqSize - origSize,
					&newSizes, &trueSize))
		{
		assert( trueSize == reqSize - origSize );
		newSizes.SetElement(index, reqSize);

		*itsSizes = newSizes;
		SetCompartmentSizes();
		return kJTrue;
		}
	else if (reqSize < origSize)
		{
		itsSizes->SetElement(index, reqSize);
		FillSpace(*itsSizes, itsElasticIndex, origSize - reqSize, &newSizes);
		*itsSizes = newSizes;
		SetCompartmentSizes();
		return kJTrue;
		}
	else
		{
		return JI2B(reqSize == origSize);
		}
}
开发者ID:dllaurence,项目名称:jx_application_framework,代码行数:36,代码来源:JPartition.cpp

示例6: ellipseRect


//.........这里部分代码省略.........
		}
	p.SetLineWidth(1);
*/
	textPt.Set(340, 200);
	p.SetFontName("Times");
	p.SetFontStyle(colormap->GetBlueColor());
	p.String(  0.0, textPt, "Hello");
	p.String( 90.0, textPt, "Hello");
	p.SetFontStyle(colormap->GetYellowColor());
	p.String(180.0, textPt, "Hello");
	p.String(270.0, textPt, "Hello");

	p.SetPenColor(colormap->GetYellowColor());
	r.Set(0,11,80,91);
	p.Rect(r);
	r.Shrink(1,1);
	p.SetPenColor(colormap->GetBlueColor());
	p.Ellipse(r);
	r.Shrink(1,1);
	p.SetPenColor(colormap->GetRedColor());
	p.Arc(r, 270.0-45.0, -270.0);

	JPolygon poly;
	poly.AppendElement(JPoint(0,85));
	poly.AppendElement(JPoint(10,85));
	poly.AppendElement(JPoint(5,95));
	p.Polygon(poly);

	p.Line(0,100, 2,98);
	p.LineTo(4,100);
	p.LineTo(2,102);
	p.LineTo(0,100);

	poly.SetElement(1, JPoint(0,5));
	poly.SetElement(2, JPoint(2,0));
	poly.SetElement(3, JPoint(4,5));
	p.Polygon(2,105, poly);

	// test filling rule

	p.SetPenColor(colormap->GetRedColor());
	p.SetFilling(kJTrue);

	JPolygon fillRulePoly;
	fillRulePoly.AppendElement(JPoint(175,45));
	fillRulePoly.AppendElement(JPoint(165,65));
	fillRulePoly.AppendElement(JPoint(190,50));
	fillRulePoly.AppendElement(JPoint(160,50));
	fillRulePoly.AppendElement(JPoint(185,65));
	p.Polygon(fillRulePoly);

	p.SetFilling(kJFalse);

	// dashed lines

	p.DrawDashedLines(kJTrue);

	p.SetPenColor(colormap->GetBlackColor());

	JArray<JSize> dashList;			// pixel rulers
	dashList.AppendElement(1);
	dashList.AppendElement(1);
	p.SetDashList(dashList);
	p.Line(100,110, 200,110);
	p.Line(100,114, 200,114);
	p.Line(100,118, 200,118);
开发者ID:jafl,项目名称:jx_application_framework,代码行数:67,代码来源:TestWidget.cpp

示例7: ellipseRect


//.........这里部分代码省略.........
    p.String( 90.0, 310,150, "Hello", 80, JPainter::kHAlignCenter,
              80, JPainter::kVAlignCenter);
    p.String(180.0, 390,150, "Hello", 80, JPainter::kHAlignCenter,
             80, JPainter::kVAlignCenter);
    p.String(270.0, 390, 70, "Hello", 80, JPainter::kHAlignCenter,
             80, JPainter::kVAlignCenter);

    p.Rect(200, 10, 100, 50);
    p.String(200, 10, "Hello", 100, JPainter::kHAlignLeft);
    p.String(200, 10+p.GetLineHeight(), "Hello", 100, JPainter::kHAlignCenter);
    p.String(200, 10+2*p.GetLineHeight(), "Hello", 100, JPainter::kHAlignRight);

    p.SetPenColor(colormap->GetYellowColor());
    JRect r(0,11,80,91);
    p.Rect(r);
    r.Shrink(1,1);
    p.SetPenColor(colormap->GetBlueColor());
    p.Ellipse(r);
    r.Shrink(1,1);
    p.SetPenColor(colormap->GetRedColor());
    p.Arc(r, 270.0-45.0, -270.0);

    JPolygon poly;
    poly.AppendElement(JPoint(0,85));
    poly.AppendElement(JPoint(10,85));
    poly.AppendElement(JPoint(5,95));
    p.Polygon(poly);

    p.Line(0,100, 2,98);
    p.LineTo(4,100);
    p.LineTo(2,102);
    p.LineTo(0,100);

    poly.SetElement(1, JPoint(0,5));
    poly.SetElement(2, JPoint(2,0));
    poly.SetElement(3, JPoint(4,5));
    p.Polygon(2,105, poly);

    // test filling rule

    p.SetPenColor(colormap->GetRedColor());
    p.SetFilling(kJTrue);

    JPolygon fillRulePoly;
    fillRulePoly.AppendElement(JPoint(175,45));
    fillRulePoly.AppendElement(JPoint(165,65));
    fillRulePoly.AppendElement(JPoint(190,50));
    fillRulePoly.AppendElement(JPoint(160,50));
    fillRulePoly.AppendElement(JPoint(185,65));
    p.Polygon(fillRulePoly);

    p.SetFilling(kJFalse);

    // dashed lines

    p.DrawDashedLines(kJTrue);

    p.SetPenColor(colormap->GetBlackColor());

    JArray<JSize> dashList;			// pixel rulers
    dashList.AppendElement(1);
    dashList.AppendElement(1);
    p.SetDashList(dashList);
    p.Line(100,110, 200,110);
    p.Line(100,114, 200,114);
    p.Line(100,118, 200,118);
开发者ID:mta1309,项目名称:mulberry-lib-jx,代码行数:67,代码来源:TestWidget.cpp

示例8: odata

void
JPlotFitQuad2::CalculateFirstPass()
{
	JFloat Y, X, X2, YX, X3, YX2, X4, Sig;
	JFloat tempa, tempb, tempc, det;
	JSize i,j, k;
	JArray<JFloat> yAdjError;
	
	const JPlotDataBase* data = GetData();
	J2DDataPoint point;
	JSize rcount = GetRealElementCount();
	for (i=1; i<= rcount; i++)
		{
		J2DDataPoint point = GetRealElement(i);
		JFloat newVal = 1;
		if (point.yerr != 0)
			{
			newVal = point.yerr;
			}
		yAdjError.AppendElement(newVal);
		}

	JMatrix odata(rcount, 3, 1.0);
	JVector yData(rcount);
	for (i=1; i<= rcount; i++)
		{
		point = GetRealElement(i);
		JFloat yerr = yAdjError.GetElement(i);
		odata.SetElement(i, 1, 1/(yerr*yerr));
		odata.SetElement(i, 2, point.x/(yerr*yerr));
		odata.SetElement(i, 3, point.x*point.x/(yerr*yerr));
		yData.SetElement(i, point.y/(yerr*yerr));
		}
	JMatrix tData = odata.Transpose();
	JMatrix lData = tData * odata;
	JMatrix rData = tData * yData;
	JMatrix parms(3,1);
	JGaussianElimination(lData, rData, &parms);

	for (k=1; k<= 4; k++)
		{
		Y = 0;
		X = 0;
		X2 = 0;
		YX = 0;
		X3 = 0;
		YX2 = 0;
		X4 = 0;
		Sig = 0;
		for (i=1; i<= rcount; i++)
			{
			point = GetRealElement(i);
			JFloat yerr = yAdjError.GetElement(i);
			Y += point.y/(yerr*yerr);
			X += point.x/(yerr*yerr);
			X2 += point.x*point.x/(yerr*yerr);
			YX += point.y*point.x/(yerr*yerr);
			X3 += point.x*point.x*point.x/(yerr*yerr);
			YX2 += point.x*point.x*point.y/(yerr*yerr);
			X4 += point.x*point.x*point.x*point.x/(yerr*yerr);
			Sig += 1/(yerr*yerr);
			}
		JFloat cv1 = 0, cv2 = 0, cv3 = 0;
		for (i=1; i<= rcount; i++)
			{
			point = GetRealElement(i);
			JFloat syi = yAdjError.GetElement(i);
			JFloat yi = point.y;
			JFloat xi = point.x;
			for (j = 1; j <= rcount; j++)
				{
				point = GetRealElement(j);
				JFloat syj = yAdjError.GetElement(j);
				JFloat yj = point.y;
				JFloat xj = point.x;
				cv1 += xi*xj*xj*(xi*yj-yi*xj)/(syi*syi*syj*syj);
				cv2 += (xi*xj*xj*(yi - yj))/(syi*syi*syj*syj);
				cv3 += (xi*xj*xj*(xj - xi))/(syi*syi*syj*syj);
				}
			}
		det = Sig*(X2*X4-X3*X3) + X*(X3*X2-X*X4) + X2*(X*X3-X2*X2);
		tempa = (Y*(X2*X4-X3*X3) + X*(X3*YX2-YX*X4) + X2*(YX*X3-X2*YX2))/det;
		tempb = (Sig*(YX*X4-YX2*X3) + Y*(X3*X2-X*X4) + X2*(X*YX2-YX*X2))/det;
		tempc = (Sig*cv1 + X*cv2 + Y*cv3)/det;

		for (i=1; i<=rcount; i++)
			{
			J2DDataPoint point = GetRealElement(i);
			JFloat newVal = 
				sqrt(point.yerr*point.yerr + (tempb+2*tempc*point.x)*(tempb+2*tempc*point.x)*point.xerr*point.xerr);
			if (newVal == 0)
				{
				newVal = 1;
				}
			yAdjError.SetElement(i, newVal);
			}
		}
//	itsAParameter	= tempa;
//	itsBParameter	= tempb;
//	itsCParameter	= tempc;
//.........这里部分代码省略.........
开发者ID:jafl,项目名称:jx_application_framework,代码行数:101,代码来源:JPlotFitQuad2.cpp

示例9: main


//.........这里部分代码省略.........
		iter.MoveTo(kJIteratorStartAtBeginning, 0);
		while (iter.Next(&index))
			{
			h.IncrementCount(index, 1);
			}
		}

	JProbDistr p = h.ConvertToProbabilities();

	cout << endl;
	cout << "Probability of each element (2-8) being in the subset:" << endl;
	cout << "(averaged over ensemble of 5000 subsets)" << endl << endl;
	cout << p << endl;

// JSubset::GetRandomSample()

	JBoolean ok = JGetRandomSample(&s1, 7);
	assert( ok );

	h.Clear();
	for (i=1; i<=5000; i++)
		{
		s1.GetRandomSample(&s3, 3);

		iter.MoveTo(kJIteratorStartAtBeginning, 0);
		while (iter.Next(&index))
			{
			h.IncrementCount(index, 1);
			}
		}

	p = h.ConvertToProbabilities();

	cout << endl;
	cout << "Probability of each element (sample of 7) being in the subset:" << endl;
	cout << "(averaged over ensemble of 5000 subsets)" << endl << endl;
	cout << p << endl;

// JSubset::GetRandomDisjointSamples()

	JPtrArray<JSubset> sampleList(JPtrArrayT::kDeleteAll);

	JArray<JSize> sampleSizeList;
	sampleSizeList.AppendElement(2);
	sampleSizeList.AppendElement(2);

	JHistogram<JSize> h1(10), h2(10);
	JHistogram<JSize>* hist[] = { &h1, &h2 };
	for (i=1; i<=5000; i++)
		{
		s1.GetRandomDisjointSamples(&sampleList, sampleSizeList);

		for (JIndex j=1; j<=2; j++)
			{
			JSubsetIterator iter = (sampleList.NthElement(j))->NewIterator();
			while (iter.Next(&index))
				{
				hist[j-1]->IncrementCount(index, 1);
				assert( !(sampleList.NthElement(3-j))->Contains(index) );
				}
			}
		}

	cout << endl;
	cout << "Probability of each element (2 from sample of 7) being in the subset:" << endl;
	cout << "(averaged over ensemble of 5000 subsets)" << endl << endl;
	cout << "1) " << h1.ConvertToProbabilities() << endl;
	cout << "2) " << h2.ConvertToProbabilities() << endl;

// JSubset::GetRandomDisjointSamples() -- partitioning

	sampleSizeList.SetElement(1, 3);
	sampleSizeList.SetElement(2, 4);

	h1.Clear();
	h2.Clear();
	for (i=1; i<=5000; i++)
		{
		s1.GetRandomDisjointSamples(&sampleList, sampleSizeList);

		for (JIndex j=1; j<=2; j++)
			{
			JSubsetIterator iter = (sampleList.NthElement(j))->NewIterator();
			while (iter.Next(&index))
				{
				hist[j-1]->IncrementCount(index, 1);
				assert( !(sampleList.NthElement(3-j))->Contains(index) );
				}
			}
		}
	sampleList.DeleteAll();

	cout << endl;
	cout << "Probability of each element (3,4 from sample of 7) being in the subset:" << endl;
	cout << "(averaged over ensemble of 5000 subsets)" << endl << endl;
	cout << "1) " << h1.ConvertToProbabilities() << endl;
	cout << "2) " << h2.ConvertToProbabilities() << endl;

	return 0;
}
开发者ID:dllaurence,项目名称:jx_application_framework,代码行数:101,代码来源:test_JSubset.cpp


注:本文中的JArray::SetElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。