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


C++ DynamicArray::getLength方法代码示例

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


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

示例1:

TEST( DynamicArray, equalOperator ){
	DynamicArray<string> arrayEqOp = testArrayOne;
	EXPECT_EQ( testArrayOne.getLength(), arrayEqOp.getLength() );
	for( int i = 0; i < testArrayOne.getLength(); ++i ){
		EXPECT_TRUE( testArrayOne[i] == arrayEqOp[i] );
	}
}
开发者ID:curtisai,项目名称:CS585MKII,代码行数:7,代码来源:test_dynamic_array.cpp

示例2: arrayPushFront

TEST( DynamicArray, pushFront ){
	DynamicArray<string> arrayPushFront( &testAlloc );
	for(size_t i = 0; i < testArrayOne.getLength(); ++i){
		arrayPushFront.pushFront( testArrayOne[i] );
		EXPECT_EQ( testArrayOne[i], arrayPushFront[0] );
	}
	EXPECT_EQ( testArrayOne.getLength(), arrayPushFront.getLength() );
}
开发者ID:curtisai,项目名称:CS585MKII,代码行数:8,代码来源:test_dynamic_array.cpp

示例3: arrayInsertAt

TEST( DynamicArray, insertAt ){
	DynamicArray<string> arrayInsertAt(&testAlloc);
	string temp = "hello";
	for ( int i = 0; i < 5; ++i )
	{
		arrayInsertAt.push(temp);
	}
	for( size_t i = 0; i < testArrayOne.getLength(); ++i){
		arrayInsertAt.insertAt( i + 2, testArrayOne[i] );
	}
	EXPECT_EQ( arrayInsertAt.getLength(), 1005 );
	for( size_t i = 0; i < testArrayOne.getLength(); ++i ){
		EXPECT_EQ(arrayInsertAt[i + 2], testArrayOne[i]);
	}
}
开发者ID:curtisai,项目名称:CS585MKII,代码行数:15,代码来源:test_dynamic_array.cpp

示例4: pointerArray

TEST(DynamicArray, pointerArray){
	StevensDev::sgdm::DefaultAllocator<string*> strPtrAlloc;
	DynamicArray<string*> pointerArray(&strPtrAlloc);
	for( int i = 0; i < 100; ++i ){
		string* strPtr =  new string( std::to_string(i) );
		pointerArray.push( strPtr );
		EXPECT_EQ( *(pointerArray[i]), *strPtr );
		delete strPtr;
	}
	for( int i = 0; i < 100; ++i ){
		string* strPtr =  new string( std::to_string(i) );
		string* frontPtr = pointerArray.popFront();
		EXPECT_EQ( *strPtr, *frontPtr );
		delete strPtr;
		delete frontPtr;
	}

	for( int i = 0; i < 100; ++i ){
		string* strPtr =  new string( std::to_string( i ) );
		pointerArray.pushFront(strPtr);
		EXPECT_EQ( *(pointerArray[0]), *strPtr );
		delete strPtr;
	}

	for( int i = 0; i < 100; ++i ){
		string* strPtr =  new string( std::to_string( i ) );
		string* frontPtr = pointerArray.pop();
		EXPECT_EQ(*strPtr, *frontPtr);
		delete strPtr;
		delete frontPtr;
	}

	for( int i = 0; i < 100; ++i ){
		string* strPtr =  new string( std::to_string( i ) );
		pointerArray.push( strPtr);
		delete strPtr;
	}

	string* temp = pointerArray.removeAt( 20 );
	EXPECT_EQ( "20", *temp );
	EXPECT_EQ( 99, pointerArray.getLength() );
	delete temp;

	string* tempToInsert = new string( "hello, world" );
	pointerArray.insertAt( 30, tempToInsert );
	EXPECT_EQ( *tempToInsert, *(pointerArray[30]) );
	delete tempToInsert;

	DynamicArray<string*> cpArray = pointerArray;
	for(size_t i = 0; i < pointerArray.getLength(); ++i)
		EXPECT_EQ( *(cpArray[i]), *(pointerArray[i]) );

	cpArray.clear();
	EXPECT_EQ( 0, cpArray.getLength() );
}
开发者ID:curtisai,项目名称:CS585MKII,代码行数:55,代码来源:test_dynamic_array.cpp


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