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


C++ SimpleList::get方法代码示例

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


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

示例1: testGet

void AbstractSequentialListTest::testGet() {

    SimpleList<int> list;

    list.add( 1 );
    list.add( 2 );

    CPPUNIT_ASSERT_EQUAL( 1, list.get( 0 ) );
    CPPUNIT_ASSERT_EQUAL( 2, list.get( 1 ) );

    // get value by index which is out of bounds
    try {
        list.get( list.size() );
        CPPUNIT_FAIL("Should throw IndexOutOfBoundsException.");
    } catch( IndexOutOfBoundsException& e ) {
        // expected
    }

    try {
        list.get( -1 );
        CPPUNIT_FAIL("Should throw IndexOutOfBoundsException.");
    } catch( IndexOutOfBoundsException& e ) {
        // expected
    }
}
开发者ID:apache,项目名称:activemq-cpp,代码行数:25,代码来源:AbstractSequentialListTest.cpp

示例2: ReadPolyLineData

/*-------------------------------------------------------------------*
 |  ReadPolyLineData                                                 |
 |  Inputs:                                                          |
 |      PDXF pDxf = pointer to the openning DXF file structure       |
 |      PDXFENTITYHEADER pEntityHeader =                             |
 |                  pointer to entity data header                    |
 |      PDXFENTLINE pPolyLine = pointer to PolyLine structure        |
 |  Output: TRUE if everything is ok                                 |
 *-------------------------------------------------------------------*/
BOOL ReadPolyLineData( PDXF pDxf, PDXFENTITYHEADER pEntityHeader, PDXFENTPOLYLINE pPolyLine )
{
	ZeroMemory(pPolyLine, sizeof(DXFENTPOLYLINE));

	pEntityHeader->EntityType = ENT_POLYLINE;
	pPolyLine->Flag = 0;

	ReadParamFromDxfFile(pDxf, GCode, strValue);	
	while(GCode!=0)
	{
		switch(GCode)
		{
		case 8:		// Layer Name
			strcpy(pEntityHeader->LayerName, strValue);
			break;
		case 62:	// Color
			pEntityHeader->Color = atoi(strValue);
			break;
		case 6:		// Line Type
			strcpy(pEntityHeader->LTypeName, strValue);
			break;
		case 39:	// Thickness
			pEntityHeader->Thickness = atof(strValue);
			break;	
		case 48:	// Linetype scale
			pEntityHeader->LineTypeScale = atof(strValue);
			break;
		case 70:	// Polyline flag (bit-coded); default is 0
			pPolyLine->Flag = atoi(strValue);
			break;	
 		}
		dxfStorePos(pDxf);
		ReadParamFromDxfFile(pDxf, GCode, strValue);
	}

	// Reading Vertex Data
	SimpleList<DXFENTVERTEX> vertices;
	DXFENTVERTEX Vertex;
	while((GCode==0) && (strcmp(strValue,"VERTEX")==0))
	{
		dxfStorePos(pDxf);
		ReadParamFromDxfFile(pDxf, GCode, strValue);	
		while(GCode!=0){
			switch(GCode)
			{
				case 10:	// Start point X
					Vertex.Point.x = atof(strValue);
					break;		
				case 20:	// Start point X
					Vertex.Point.y = atof(strValue);
					break;		
				case 30:	// Start point X
					Vertex.Point.z = atof(strValue);
					break;		
				case 42:	// Bulge (optional; default is 0)
					Vertex.Bulge = atof(strValue);
					break;		
 			}
			dxfStorePos(pDxf);
			ReadParamFromDxfFile(pDxf, GCode, strValue);
		}
		vertices.add(Vertex);		
	}

	pPolyLine->nVertex = vertices.getSize();
	pPolyLine->pVertex = new DXFENTVERTEX[pPolyLine->nVertex];
	int i=0;
	vertices.start();
	while (vertices.next()) {
		pPolyLine->pVertex[i] = vertices.get();		
		i++;
	}
	
	return TRUE;
}
开发者ID:malpharo,项目名称:AiPI,代码行数:84,代码来源:DREntities.cpp


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