wcvt7.cpp

来自「开放源码的编译器open watcom 1.6.0版的源代码」· C++ 代码 · 共 67 行

CPP
67
字号
// test Ordered insert, append, insertAt, prepend
#include <iostream.h>
#include <wcvector.h>
#include <string.hpp>

void test1();
void test2();

int main(){
    test1();
    test2();
    cout.flush();
    return 0;
}

void test1(){
    WCValOrderedVector< String > vect;

    cout << "Inserting one\n";
    vect.insert( "one" );
    cout << "Prepending two\n";
    vect.prepend( "two" );
    cout << "Appending three\n";
    vect.append( "three" );
    cout << "Inserting four at 1\n";
    vect.insertAt( 1, "four" );
    cout << "prepending five\n";
    vect.prepend( "five" );
    cout << "Inserting six\n";
    vect.insert( "six" );

    for( int i = 0; i < vect.entries(); i++ ){
	cout << vect[ i ] << ' ';
    }
    cout << "\n";
}

    
void test2(){
    WCPtrOrderedVector< String > vect;
    String one = "one";
    String two = "two";
    String three = "three";
    String four = "four";
    String five = "five";
    String six = "six";

    cout << "Inserting one\n";
    vect.insert( &one );
    cout << "Prepending two\n";
    vect.prepend( &two );
    cout << "Appending three\n";
    vect.append( &three );
    cout << "Inserting four at 1\n";
    vect.insertAt( 1, &four );
    cout << "prepending five\n";
    vect.prepend( &five );
    cout << "Inserting six\n";
    vect.insert( &six );

    for( int i = 0; i < vect.entries(); i++ ){
	cout << *vect[ i ] << ' ';
    }
    cout << "\n";
}
    

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?