コード例 #1
0
int main(int argc, const char * argv[])
{
    cout << "Beginning the testing with SortedArrayList..." << endl << endl;
    SortedArrayList * a = new SortedArrayList();
    insertAllWords("random.txt", a);
    cout << "WERE ALL WORDS FOUND?: " << findAllWords("words.txt", a) << endl;
    removeAllWords("random.txt", a);

    cout << endl << endl << "Beginning the testing with SortedLinkedList..." << endl << endl;
    SortedLinkedList * b = new SortedLinkedList();
    b->insert("zygote");
    insertAllWords("random.txt", b);
    cout << "WERE ALL WORDS FOUND?: " << findAllWords("words.txt", b) << endl;
    removeAllWords("random.txt", b);

    return 0;
}
コード例 #2
0
void insertAllWords(SortedLinkedList &A,  char *file)	//O(n^2)
{
    ifstream in;
    in.open(file);
    Timer t;
    string word;
    double etime;
    t.start();
    while(in>>word)
    {
        A.insert(word);
    }
    t.elapsedUserTime(etime);
    cout<<etime<<endl;


}
コード例 #3
0
void testSLL(){
    SortedLinkedList * a = new SortedLinkedList();
    a->insert("zxc");
    a->insert("cat");
    a->insert("dog");
    a->insert("sup");
    a->insert("mom");
    a->insert("apple");
    a->insert("moma");
    a->insert("zz");
    a->print();
    cout << endl << endl << "REMOVED AFTER THIS :" << endl << endl;
    a->remove("zxc");
    a->remove("apple");
    a->remove("sup");
    a->remove("zz");
    a->print();
}