本文整理汇总了C++中SimpleList::add方法的典型用法代码示例。如果您正苦于以下问题:C++ SimpleList::add方法的具体用法?C++ SimpleList::add怎么用?C++ SimpleList::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleList
的用法示例。
在下文中一共展示了SimpleList::add方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testListIterator
void AbstractListTest::testListIterator() {
int tempValue;
SimpleList<int> list;
list.add( 3 );
list.add( 15 );
list.add( 5 );
list.add( 1 );
list.add( 7 );
std::auto_ptr< ListIterator<int> > iter( list.listIterator() );
CPPUNIT_ASSERT_MESSAGE( "Should not have previous", !iter->hasPrevious() );
CPPUNIT_ASSERT_MESSAGE( "Should have next", iter->hasNext() );
tempValue = iter->next();
CPPUNIT_ASSERT_MESSAGE( std::string( "next returned wrong value. Wanted 3, got: " ) +
Integer::toString( tempValue ), tempValue == 3 );
tempValue = iter->previous();
SimpleList<std::string> list2;
list2.add( std::string("1") );
std::auto_ptr< ListIterator<std::string> > iter2( list2.listIterator() );
iter2->add( std::string("2") );
iter2->next();
CPPUNIT_ASSERT_MESSAGE( "Should contain two elements", list2.size() == 2 );
SimpleList<int> list3;
std::auto_ptr< ListIterator<int> > it( list3.listIterator() );
it->add( 1 );
it->add( 2 );
CPPUNIT_ASSERT_MESSAGE( "Should contain two elements", list3.size() == 2 );
}
示例2: testRemove
void AbstractSequentialListTest::testRemove() {
SimpleList<int> list;
list.add(1);
CPPUNIT_ASSERT_EQUAL( 1, list.removeAt( 0 ) );
list.add( 2 );
CPPUNIT_ASSERT_EQUAL( 2, list.removeAt( 0 ) );
// remove index is out of bounds
try {
list.removeAt( list.size() );
CPPUNIT_FAIL("Should throw IndexOutOfBoundsException.");
} catch( IndexOutOfBoundsException& e ) {
// expected
}
try {
list.removeAt( -1 );
CPPUNIT_FAIL("Should throw IndexOutOfBoundsException.");
} catch( IndexOutOfBoundsException& e ) {
// expected
}
// list dont't support remove operation
try {
MockAbstractSequentialList<int> mylist;
mylist.removeAt( 0 );
CPPUNIT_FAIL("Should throw UnsupportedOperationException.");
} catch( UnsupportedOperationException& e ) {
// expected
}
}
示例3: 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
}
}
示例4: testIterator
void AbstractListTest::testIterator() {
SimpleList<int> list;
list.add( 10 );
list.add( 20 );
std::auto_ptr< Iterator<int> > iter( list.iterator() );
CPPUNIT_ASSERT_EQUAL( 10, iter->next() );
iter->remove();
CPPUNIT_ASSERT_EQUAL( 20, iter->next() );
}
示例5: testLastIndexOf
void AbstractListTest::testLastIndexOf() {
SimpleList<int> array;
for( int i = 1; i < 6; i++ ) {
array.add(i);
}
for( int i = 5; i > 0; i-- ) {
array.add(i);
}
CPPUNIT_ASSERT( array.size() == 10 );
MockArrayList<int> list;
list.addAll( array );
CPPUNIT_ASSERT( list.size() == 10 );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "find 6 in the list do not contain 6",
-1, list.lastIndexOf( 6 ) );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "did not return the right location of element 4",
6, list.lastIndexOf( 4 ) );
}
示例6: testIndexOf
void AbstractListTest::testIndexOf() {
SimpleList<int> array;
for( int i = 1; i < 6; i++ ) {
array.add(i);
}
MockArrayList<int> list;
list.addAll( array );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "find 0 in the list do not contain 0", -1, list.indexOf( 0 ) );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "did not return the right location of element 3", 2, list.indexOf( 3 ) );
}
示例7: 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;
}