예제 #1
0
int main()
{
  Hash<int,string> h;

  if(h.find(111)!=0)
    cout<<*(h.find(111))<<endl;
  else
    cout<<111<<" Not exist"<<endl;

  h.insert(111,"111");
  h.insert(222,"222");
  h.insert(333,"333");

  if(h.find(111)!=0)
    cout<<*(h.find(111))<<endl;
  else
    cout<<111<<"Not exist"<<endl;
  
  if(h.find(222)!=0)
    cout<<*(h.find(222))<<endl;
  else
    cout<<222<<"Not exist"<<endl;
  
  h.remove(111);
  cout<<"Remove 111 ..."<<endl;
  
  if(h.find(111)!=0)
    cout<<*(h.find(111))<<endl;
  else
    cout<<111<<" Not exist"<<endl;

}
예제 #2
0
int main(){
 Hash<int>* h = new Hash<int>();

 h->insert("one", 1);

 std::cout << "inserted (\"one\", 1)\nresult: " << h->get("one") << std::endl;

 h->insert("one", 2);

 std::cout << "replaced 1 with 2\n" << h->get("one") << std::endl;

 h->insert("noe", 3);
 
 std::cout << "inserted (\"noe\", 3) (should create the same hash as \"one\", but with value of 3)\nresult: " << h->get("noe") << std::endl;

 h->insert("ZZZZZZzZzZzZzzzZUHcuhu", 239);
 h->insert("ZZZZZZzZzZZzzzzZUHcuhu", 13);

 std::cout << "inserted (\"ZZZZZZzZzZzZzzzZUHcuhu\", 239)\n" << h->get("ZZZZZZzZzZzZzzzZUHcuhu") << std::endl;
 
 h->remove("noe");

 std::cout << "removed (\"noe\"\n" << std::endl;
 h->print();

 return 0;
}
예제 #3
0
int main(){

  Hash<int>* tab = new Hash<int>(100);
  tab->insert("chickin" , 5);
  tab->insert("car" , 1);
  tab->insert("asdf", 3);
  cout << tab->find("chickin") <<  endl;
  cout << tab->find("asdf") << endl;
  tab->remove("car");
  cout << tab->find("car");
  delete tab;
  return 0;
}
예제 #4
0
Attachment::Hash Attachment::toHash(const Attachment::List &list)
{
    Hash hash;
    foreach (auto attachment, list)
        hash.insert(attachment.type(), attachment);
    return hash;
}
예제 #5
0
int main(int argc, char *argv[])
{
	string lineBuffer;
    	ifstream file;
	file.open(argv[1]);
	int count=0;
	Hash strHash;
	vector<string> wordArray;
	//insert strings into vector
	int g=0;
	while (!file.eof()){
		getline(file, lineBuffer);
		string str=new char[lineBuffer.length()]();
		if (lineBuffer.length() != 0)
			wordArray.push_back(lineBuffer);
	}
	for(int i=0;i<wordArray.size();i++)
		strHash.insert((char*)&wordArray.at(i)[0]);
	//sort vector by string length
	sort(wordArray.begin(),wordArray.end());
	sort(wordArray.begin(),wordArray.end(), stringCompare);
	for(int i=0;i<wordArray.size();i++){
		//check whether this word is made up of other words
		if(buildWord(wordArray.at(i), true, strHash)){
			count++;
			//only print first 2 longest word made up of other words
			if(count<3)	
				cout<<wordArray.at(i)<<endl;
		}
	}
	//printf how many of the words in the list can be constructed of other words in the list
	cout<<"There are "<<count<<" words that can be constructed of other words in the list"<<endl;
	return 0;
}
예제 #6
0
int main(void)
{
	int val;
	Hash<int, int>* h = new Hash<int, int>(11);
	h->insert(80);
	h->insert(40);
	h->insert(65);
	h->insert(24);
	h->insert(58);
	if (h->Search(80, val))
		cout << "the val exist: " << val << endl;
	else
		cout << "the val does not exist!" << endl;
	int a[] = {1,2,3,4,5,6,5,6,7,1,3,4,5,6,7,9,100,10};
	int b[] = {1,2,3,4,5,6,7,8,9,10};
	int c[] = {5,2,3,1,100,100};
	int d[] = {1};
	if (is_duplicate1(c, sizeof(c)/sizeof(int)))
		cout << "exist duplicate!" << endl;
	else
		cout << "does not exist duplicate!" << endl;
	return 0;
}
예제 #7
0
파일: mode.cpp 프로젝트: javang/mlearning
IntPair mode(const int *values, unsigned int size) {
  Hash::iterator it;
  Hash hash;
  for (int i = 0; i < size; i++) {
    it = hash.find(values[i]);
    if(it == hash.end()) {
      hash.insert( std::make_pair(values[i], 1));
    } else {
      it->second += 1;
    }
  }
  unsigned int counts = 0;
  Hash::iterator found;
  for (it = hash.begin(); it != hash.end(); ++it) {
    if(it->second > counts) {
      counts = it->second;
      found = it;
    }
  }
  return *found;
}
예제 #8
0
파일: main.cpp 프로젝트: rafaelhaertel/PBF
//------------------------------------------------------------------------------
void BuildHashTable(std::vector<Particle> &p_list, Hash &hash_table)
{
	int num_particles = p_list.size();
	int grid_x;
	int grid_y;
	int grid_z;

	float cell_size = (g_xmax - g_ymin) / GRID_RESOLUTION;

	hash_table.clear();

	for (int i = 0; i < num_particles; i++)
	{
		grid_x = floor(p_list[i].position[0] / cell_size);
		grid_y = floor(p_list[i].position[1] / cell_size);
		grid_z = floor(p_list[i].position[2] / cell_size);

		p_list[i].hash = ComputeHash(grid_x, grid_y, grid_z);

		hash_table.insert(Hash::value_type(p_list[i].hash, i));
	}
}
예제 #9
0
파일: 5.cpp 프로젝트: JS00000/acmCode
int main(int argc, char const *argv[])
{
    int n, q, a, b;
    char str[10], str2[10];
    while(~scanf("%d%d", &n, &q))
    {
        memset(head, 0, (n+1)*sizeof(int));
        memset(dist, 0, (n+1)*sizeof(int));
        memset(visit, 0, (n+1)*sizeof(bool));
        memset(qhead, 0, sizeof(qhead));
        memset(qmap, 0, sizeof(qmap));
        surnames.clear();
        qhead_hash.clear();
        qmap_hash.clear();
        for (int i = 0; i < maxn; ++i) id_to_name[i].clear();
        for (int i = 0; i < maxn; ++i) name_to_id[i].clear();

        for (int i = 0; i < n; ++i)
        {
            scanf("%s", str);
            id_to_name[i+1] = str;
            name_to_id[surnames.insert(str)].push_back(i+1);
        }
        for (int i = 1; i <= n-1; ++i)
        {
            scanf("%d%d", &a, &b);
            edge[i*2-1].to = b;
            edge[i*2-1].next = head[a];
            head[a] = i*2-1;
            edge[i*2].to = a;
            edge[i*2].next = head[b];
            head[b] = i*2;
        }
        for (int i = 1; i <= q; ++i)
        {
            scanf("%s%s", str, str2);
            if ((surnames.findHash(str) == -1) || (surnames.findHash(str2) == -1))
            {
                qq[i].a = qq[i].b = "";
                continue;
            }
            qq[i].a = str;
            qq[i].b = str2;
            if (qhead_hash.findHash(str) == -1) qhead[qhead_hash.insert(str)] = 0;
            if (qhead_hash.findHash(str2) == -1) qhead[qhead_hash.insert(str2)] = 0;

            qedge[i*2-1].to = str2;
            qedge[i*2-1].next = qhead[qhead_hash.findHash(str)];
            qhead[qhead_hash.findHash(str)] = i*2-1;
            qedge[i*2].to = str;
            qedge[i*2].next = qhead[qhead_hash.findHash(str2)];
            qhead[qhead_hash.findHash(str2)] = i*2;
            qmap[qmap_hash.insert(make_pair(str, str2))] = -1;
            qmap[qmap_hash.insert(make_pair(str2, str))] = -1;
        }
        LCA(1, 0);
        for (int i = 1; i <= q; ++i)
        {
            if (qq[i].a == "" || qq[i].b == "")
            {
                printf("-1\n");
            }
            else
            {
                printf("%d\n", qmap[qmap_hash.findHash(make_pair(qq[i].a, qq[i].b))] + 1);
            }
        }
    }
    return 0;
}
예제 #10
0
파일: tst_qhash.cpp 프로젝트: husninazer/qt
void tst_QHash::insert1()
{
    const char *hello = "hello";
    const char *world = "world";
    const char *allo = "allo";
    const char *monde = "monde";

    {
        typedef QHash<QString, QString> Hash;
        Hash hash;
        QString key;
        for (int i = 0; i < 10; ++i) {
            key[0] = i + '0';
            for (int j = 0; j < 10; ++j) {
                key[1] = j + '0';
                hash.insert(key, "V" + key);
            }
        }

        for (int i = 0; i < 10; ++i) {
            key[0] = i + '0';
            for (int j = 0; j < 10; ++j) {
                key[1] = j + '0';
                hash.remove(key);
            }
        }
    }

    {
        typedef QHash<int, const char *> Hash;
        Hash hash;
        hash.insert(1, hello);
        hash.insert(2, world);

        QVERIFY(hash.size() == 2);
        QVERIFY(!hash.isEmpty());

        {
            Hash hash2 = hash;
            hash2 = hash;
            hash = hash2;
            hash2 = hash2;
            hash = hash;
            hash2.clear();
            hash2 = hash2;
            QVERIFY(hash2.size() == 0);
            QVERIFY(hash2.isEmpty());
        }
        QVERIFY(hash.size() == 2);

        {
            Hash hash2 = hash;
            hash2[1] = allo;
            hash2[2] = monde;

            QVERIFY(hash2[1] == allo);
            QVERIFY(hash2[2] == monde);
            QVERIFY(hash[1] == hello);
            QVERIFY(hash[2] == world);

            hash2[1] = hash[1];
            hash2[2] = hash[2];

            QVERIFY(hash2[1] == hello);
            QVERIFY(hash2[2] == world);

            hash[1] = hash[1];
	    QVERIFY(hash[1] == hello);
	}
	        {
            Hash hash2 = hash;
            hash2.detach();
            hash2.remove(1);
            QVERIFY(hash2.size() == 1);
            hash2.remove(1);
            QVERIFY(hash2.size() == 1);
            hash2.remove(0);
            QVERIFY(hash2.size() == 1);
            hash2.remove(2);
            QVERIFY(hash2.size() == 0);
            QVERIFY(hash.size() == 2);
        }

        hash.detach();

        {
            Hash::iterator it1 = hash.find(1);
            QVERIFY(it1 != hash.end());

            Hash::iterator it2 = hash.find(0);
            QVERIFY(it2 != hash.begin());
            QVERIFY(it2 == hash.end());

            *it1 = monde;
            QVERIFY(*it1 == monde);
            QVERIFY(hash[1] == monde);

            *it1 = hello;
            QVERIFY(*it1 == hello);
            QVERIFY(hash[1] == hello);

            hash[1] = monde;
            QVERIFY(it1.key() == 1);
            QVERIFY(it1.value() == monde);
            QVERIFY(*it1 == monde);
            QVERIFY(hash[1] == monde);

            hash[1] = hello;
            QVERIFY(*it1 == hello);
            QVERIFY(hash[1] == hello);
        }

        {
            const Hash hash2 = hash;

            Hash::const_iterator it1 = hash2.find(1);
            QVERIFY(it1 != hash2.end());
            QVERIFY(it1.key() == 1);
            QVERIFY(it1.value() == hello);
            QVERIFY(*it1 == hello);

            Hash::const_iterator it2 = hash2.find(2);
            QVERIFY(it1 != it2);
            QVERIFY(it1 != hash2.end());
            QVERIFY(it2 != hash2.end());

            int count = 0;
            it1 = hash2.begin();
            while (it1 != hash2.end()) {
                count++;
                ++it1;
            }
            QVERIFY(count == 2);

            count = 0;
            it1 = hash.begin();
            while (it1 != hash.end()) {
                count++;
                ++it1;
            }
            QVERIFY(count == 2);
        }

        {
            QVERIFY(hash.contains(1));
            QVERIFY(hash.contains(2));
            QVERIFY(!hash.contains(0));
            QVERIFY(!hash.contains(3));
        }

        {
            QVERIFY(hash.value(1) == hello);
            QVERIFY(hash.value(2) == world);
            QVERIFY(hash.value(3) == 0);
            QVERIFY(hash.value(1, allo) == hello);
            QVERIFY(hash.value(2, allo) == world);
            QVERIFY(hash.value(3, allo) == allo);
            QVERIFY(hash.value(0, monde) == monde);
        }

        {
            QHash<int,Foo> hash;
            for (int i = 0; i < 10; i++)
                hash.insert(i, Foo());
            QVERIFY(Foo::count == 10);
            hash.remove(7);
            QVERIFY(Foo::count == 9);

        }
        QVERIFY(Foo::count == 0);
        {
            QHash<int, int*> hash;
            QVERIFY(((const QHash<int,int*>*) &hash)->operator[](7) == 0);
        }
    }
}
예제 #11
0
파일: Hash.cpp 프로젝트: IMCG/icoding
/* 测试主函数 */
int main()
{
	Hash<int> h;
	h.insert(4);
	h.insert(34);
	h.insert(54);

	h.insert(35);
	h.insert(8);
	h.insert(22);
	h.insert(48);
	h.insert(9);

	h.insert(32);
	h.insert(2);
	h.insert(3);
	h.insert(54);
	h.insert(37);
	h.insert(8);
	h.insert(54);
	h.insert(6);
	h.insert(9);
	h.insert(12);
	h.insert(12);
	h.insert(23);

	h.insert(37);
	h.insert(48);
	h.insert(54);
	h.insert(66);
	h.insert(9);
	h.insert(12);

	h.Print();


	system("pause");
	return 0;
}
int main()
{
	Hash<char> toTest (hasher, 10);

	// isEmpty() test
	cout << "\nisEmpty() Test" << endl;
	cout << "isEmpty(): " << toTest.isEmpty() << endl;
	cout << "isFull(): " << toTest.isFull() << endl;
	toTest.showStructure();

	// insert() test
	cout << "\ninsert() Test" << endl;

	for (char c = '0'; c <= 'z'; c++)
	{
		toTest.insert(c);
	}

	toTest.showStructure();

	// isFull() test
	cout << "\nisFull() Test" << endl;
	cout << "isEmpty(): " << toTest.isEmpty() << endl;
	cout << "isFull(): " << toTest.isFull() << endl;

	// remove() and retrieve() test
	cout << "\nremove() and retrieve() Test" << endl;
	char rtest = ' ';
	cout << "remove(3): " << toTest.remove(3) << endl;
	bool rreturn = toTest.retrieve(3, rtest);
	cout << "retrieve(3, rtest): " << rreturn << " | rtest = " << rtest << endl;
	toTest.showStructure();

	// clear() test
	cout << "\nclear() Test" << endl;
	toTest.clear();
	toTest.showStructure();

	// isEmpty() test
	cout << "\nisEmpty() Test" << endl;
	cout << "isEmpty(): " << toTest.isEmpty() << endl;
	cout << "isFull(): " << toTest.isFull() << endl;
	toTest.showStructure();

	// Int test version
	Hash<int> testTwo(hasher_two, 20);
	cout << "\n\nTesting with ints:" << endl;

	// insert() test
	cout << "\ninsert() Test" << endl;

	for (int i = 1; i <= 115; i++)
	{
		testTwo.insert(i);
	}

	testTwo.showStructure();

	// isFull() test
	cout << "\nisFull() Test" << endl;
	cout << "isEmpty(): " << testTwo.isEmpty() << endl;
	cout << "isFull(): " << testTwo.isFull() << endl;

	// remove() and retrieve() test
	cout << "\nremove() and retrieve() Test" << endl;
	cout << "remove(3): " << testTwo.remove(3) << endl;
	int itest;
	bool ireturn = testTwo.retrieve(3, itest);
	cout << "retrieve(3, rtest): " << ireturn << " | rtest = " << itest << endl;
	testTwo.showStructure();

	// clear() test
	cout << "\nclear() Test" << endl;
	testTwo.clear();
	testTwo.showStructure();

	system("pause");
}
예제 #13
0
int main(int argc, char *argv[])
{
    ofstream log; // to record log file
    log.open("log.txt", std::fstream::app);
    CommandLineParser clp(argv[1],',');   //instantiating the class CommandLineParser

    if (argc == 1) 
    {
        log << "Error: no argument is passed.\n" << endl;
        log.close();
        return -1;
    }

    //use CommandLineParser to get the script name
    char *script = clp.extract("script");
    if (script == NULL || *script == '\0')
    {
        log << "Error: no script file specified.\n" << endl;
        log.close();
        return -1;
    }
    
    //use ScriptParser to get the commands from script file
    ScriptParser SParser = ScriptParser();
    ifstream indata(script);
    if (!indata.is_open()) // check if script file is correctly opened.
    {
        log << "Error: Script file \'" << script << "\' cannot be opened or does not exist.\n" << endl;
        log.close();
        return -1;
    }

    //start parsing script file    
    int i = 0;
    int n;
    int size;
    int k;
    string line; // store each line in script file
    WordList *L; // array of word lists
    FreqList *F; // array of frequency lists which store the information of words and its frequency
    string *S; // array of strings which store the name of lists
    Hash HT; // hash table to store all the words
    L = new WordList[1000];
    F = new FreqList[1000];
    S = new string[1000];

    //initiate temporary lists and list nodes
    WordNode *tempWordNode;
    FreqNode *tempFreqNode;
    WordList tempWordList;
    WordList *tempWordListpt;
    FreqList tempFreqList;
    FreqList tempFreqList2;
    string tempString;
    Node *tempNode;

    int pos1;
    int pos2;

    log << "Begin parsing script file \'" << script << "\':\n" << endl;
    while(getline(indata, line))
    {
        log << line << '\n';
        SParser.ParseLine(line);

        //process to determine if listID exits
        int ID = -1; // cmd.listID, after following checking process, if it's still -1, then cmd.listID is a new list, otherwise cmd.listID is the word list L[ID] or frequency list F[ID]
        int ID2 = -1; // cmd.value1 (if it stores list name), same procesure as above
        int ID3 = -1; // cmd.value2 (if it stores list name), same procesure as above

        for (int j = 0; j < i; j++)
        {
            ID = (SParser.cmd.listID == S[j])?j:ID; // check if cmd.listID is already in S[]
        }

        if (SParser.operationCode() != 3 && SParser.operationCode() != 8 && SParser.operationCode() != 9 && SParser.operationCode() != 10 && SParser.operationCode() != 13 && SParser.operationCode() != 0 && ID == -1) 
        { 
            log << "Error: invalid operation, because list \'" << SParser.cmd.listID << "\' is not created yet.\n" << endl;
            if (SParser.operationCode() == 4 || SParser.operationCode() == 5)
            {
                ofstream output;
                output.open(SParser.cmd.value1.c_str());
                output << "List " << SParser.cmd.listID << " does not exist" << endl;
                output.close();
            }
            continue;
        }

        if ((SParser.operationCode() == 3 || SParser.operationCode() == 8 || SParser.operationCode() == 9 || SParser.operationCode() == 10 || SParser.operationCode() == 13) && ID > -1) 
        { 
            log << "Error: invalid operation, because list \'" << SParser.cmd.listID << "\' already exists.\n" << endl;
            continue;
        }

        // do all the list operations, such as read, insert, delete, write, intersection, union, load, filter, index and seach
        switch (SParser.operationCode())
        {
        case 1:
            n = L[ID].insert(SParser.cmd.value2, SParser.cmd.value1);
            if (n == -1) {
                log << "Warning: in insertion, " << '\'' << SParser.cmd.value1 << '\'' << " cannot be found, so insertion fails.\n";
            }
            else {
                log << '\'' << SParser.cmd.value2 << '\'' << " has been inserted after the first appeared word " << '\'' << SParser.cmd.value1 << "\'.\n";
                F[ID].clear(); // update frequency list based on updated word list
                F[ID].frequency_unsorted(L[ID]);
                F[ID].sort();
            }
                log << "Number of bytes used by list \'" << S[ID] << "\' is: " << L[ID].listSize() << ".\n" << endl;
            break;
        case 2:
            n = L[ID].erase(SParser.cmd.value1);
            if (n == 0) log << "Waring: ";
            log << n << " word(s) " << '\'' << SParser.cmd.value1 << '\'' << " have been deleted.\n";
            F[ID].clear(); // update frequency list based on updated word list
            F[ID].frequency_unsorted(L[ID]);
            F[ID].sort(); 
            log << "Number of bytes used by list \'" << S[ID] << "\' is: " << L[ID].listSize() << ".\n" << endl;
            break;
        case 3:
            S[i] = SParser.cmd.listID; // create a new listname in S[]
            n = L[i].read(SParser.cmd.value1); // create a new word list in L[]
            if (n == 0) {
                log << "Input file \'" << SParser.cmd.value1 << "\' is successfully read into list.\n";
            }
            else {
                log << "Error: fail to open input file \'" << SParser.cmd.value1 << "\'.\n" << endl;
                continue;
            }
            F[i].frequency_unsorted(L[i]); // create a new frequency list in F[]
            F[i].sort(); // sort the frequency list
            log << "Number of bytes used by list \'" << S[i] << "\' is: " << F[i].listSize() << ".\n" << endl;
            i++;
            break;
        case 4:
            n = F[ID].output_forward(SParser.cmd.value1);
            if (n == 0) {
                log << "List is successfully written to file " << '\'' << SParser.cmd.value1 << '\'' << " in forward order.\n";
            }
            else {
                log << "Error: fail to create output file " << SParser.cmd.value1 << ".\n";
            }
                log << "Number of bytes used by list \'" << S[ID] << "\' is: " << F[ID].listSize() << ".\n" << endl;
            break;
        case 5:
            n = F[ID].output_backward(SParser.cmd.value1);
            if (n == 0) {
                log << "List is successfully written to file " << '\'' << SParser.cmd.value1 << '\'' << " in reverse order.\n";
            }
            else {
                log << "Error: fail to create output file " << SParser.cmd.value1 << ".\n";
            }
                log << "Number of bytes used by list \'" << S[ID] << "\' is: " << F[ID].listSize() << ".\n" << endl;
            break;
        case 6:
            for (int j = 0; j < i; j++) {
                ID2 = (SParser.cmd.value1 == S[j])?j:ID2;
                ID3 = (SParser.cmd.value2 == S[j])?j:ID3;
            }
            if (ID2 < 0 ) {
                log << "Error: invalid operation, because list \'" << SParser.cmd.value1 << "\' is not created yet.\n" << endl;
                continue;
            }
            else if (ID3 != -1 ) { 
                log << "Error: invalid operation, because list \'" << SParser.cmd.value2 << "\' already exists.\n" << endl;
                continue;
            }
            else {
                S[i] = SParser.cmd.value2;
                size = (F[ID].size() > F[ID2].size())?F[ID].size():F[ID2].size();
                if (size < 100) F[i].list_union(F[ID],F[ID2],F[ID].head,F[ID2].head);
                else F[i].list_union_nonrec(F[ID],F[ID2]);
                log << "Number of bytes used by list \'" << S[i] << "\' is: " << F[i].listSize() << ".\n" << endl;
                i++;
            }
            break;
        case 7:
            for (int j = 0; j < i; j++) {
                ID2 = (SParser.cmd.value1 == S[j])?j:ID2;
                ID3 = (SParser.cmd.value2 == S[j])?j:ID3;
            }
            if (ID2 < 0 ) { 
                log << "Error: invalid operation, because list \'" << SParser.cmd.value1 << "\' is not created yet.\n" << endl;
                continue;
            }
            else if (ID3 != -1 ) { 
                log << "Error: invalid operation, because list \'" << SParser.cmd.value2 << "\' already exists.\n"  << endl;
                continue;
            }
            else {
                S[i] = SParser.cmd.value2;
                size = (F[ID].size() > F[ID2].size())?F[ID].size():F[ID2].size();
                if (size < 100) F[i].list_intersection(F[ID],F[ID2],F[ID].head,F[ID2].head);
                else F[i].list_intersection_nonrec(F[ID],F[ID2]);
                log << "Number of bytes used by list \'" << S[i] << "\' is: " << F[i].listSize() << ".\n" << endl;
                i++;
            }
            break;
        case 8:
            string *expression;
            expression = analysis(SParser.cmd.value1);
            if (expression == NULL) {
                log << "Error: invalid or too long arithmetic expression.\n"  << endl;
                continue;
            }
            S[i] = SParser.cmd.listID;
            n = arithmetic(expression, S, F, i); 
            if (n == -1) {
                log << "Error: one or more lists in above arithmetic expression do not exist, or invalid arithmetic expression which makes stack overflow or underflow.\n"  << endl;
                continue;
            }
            log << "Number of bytes used by list \'" << S[i] << "\' is: " << F[i].listSize() << ".\n" << endl;
            i++;
            delete[] expression;
            break;
        case 9:
            log << "Error: this program does not support \'check\' operation." << endl;
            break;
        case 10:
            S[i] = SParser.cmd.listID; // create a new listname in S[]
            n = L[i].read_keepUpper(SParser.cmd.value1); // create a new word list in L[]
            if (n != 0) {
                log << "Error: fail to open input file \'" << SParser.cmd.value1 << "\'.\n" << endl;
                continue;
            }
            tempWordNode = L[i].head;
            while (tempWordNode) {
                n = tempWordList.read(tempWordNode->word);
                if (n == 0) {
                    F[i].insert("*"+tempWordNode->word,1);
                    tempFreqList.frequency_unsorted(tempWordList);
                    tempFreqList.sort();
                    F[i].append(tempFreqList,tempFreqList.head);
                    tempWordList.clear();
                    tempFreqList.clear();
                }
                if (n != 0) {
                    log << "Error: fail to open file \'" << tempWordNode->word << "\', so words in this file are ignored." << endl;
                }
                tempWordNode = tempWordNode->pnext;
            }
/*cout << "At very beginning:" << endl;
F[i].print();
cout << endl;*/
            // then, eliminate all the nodes without any letter.
            tempFreqNode = F[i].head;
            while (tempFreqNode) {
                k = 0;
                tempString = tempFreqNode->word;
                for (int j = 0; j < tempString.length(); j++) {
                    if (isalpha(tempString[j])) {
                        k = 1;
                        break;
                    }
                }
                tempFreqNode = tempFreqNode->pnext;
                if (k == 0) F[i].deletenode(tempFreqNode->pprev);
            }
            log << "Files specified in \'" << SParser.cmd.value1 << "\' are successfully loaded into list \'" << SParser.cmd.listID << "\'.\n" << endl;
/*cout << "Before filter:" << endl;
F[i].print();
cout << endl;*/
            i++;
            break;
        case 11:
            n = tempWordList.read(SParser.cmd.value1);
            if (n != 0) {
                log << "Error: fail to open file \'" << SParser.cmd.value1 << "\'.\n" << endl;
                continue;
            }
            tempFreqList.frequency_unsorted(tempWordList);
            tempFreqList.sort();
            tempFreqNode = tempFreqList.head;
            while (tempFreqNode) {
                F[ID].erase(tempFreqNode->word);
                tempFreqNode = tempFreqNode->pnext;
            }
            tempWordList.clear();
            tempFreqList.clear();
            log << "Words from file \'" << SParser.cmd.value1 << "\' are successfully eliminated from list \'" << SParser.cmd.listID << "\'.\n" << endl;
/*cout << "After filter:" << endl;
F[ID].print();
cout << endl;*/
            break;
        case 12:
            tempFreqNode = F[ID].head;
            while (tempFreqNode) {
                if (tempFreqNode->word[0] == '*')
                    tempString = (tempFreqNode->word).substr(1,(tempFreqNode->word).length()-1);
                else
                    HT.insert(tempFreqNode->word,tempString);
                tempFreqNode = tempFreqNode->pnext;
            }
            log << "Hash table is sucessfully established (or updated).\n" << endl;

/*cout << "Words are stored in hash table as:" << endl;
for (int j = 0; j < HT.size; j++) {
    tempNode = (HT.Table[j]).head;
    if (tempNode == NULL) emp++;
    if (tempNode != NULL) occ++;
    while (tempNode) {
        if (tempNode->pnext != NULL) con++;
        cout << "position: " << j << ", word: " << tempNode->IndexWord << endl;
//        cout << "file(s): ";
//        (tempNode->FileName).print();
        tempNode = tempNode->pnext;
    }
}*/
            break;
        case 13:
            S[i] = SParser.cmd.listID;
            tempString = SParser.cmd.value1;
            transform(tempString.begin(),tempString.end(),tempString.begin(),::tolower); //transfer all the key words into lower case
            pos1 = 0;
            while (pos1 != string::npos) {
                pos2 = tempString.find(",");
                tempWordList.insert(tempString.substr(pos1,pos2));
                if (pos2 == string::npos) pos1 = pos2;
                else {
                    pos1 = 0;
                    tempString = tempString.substr(pos2+1,tempString.length()-pos2-1);
                }
            }
            tempWordNode = tempWordList.head;
            while (tempWordNode) {
                tempWordListpt = HT.search(tempWordNode->word);
                tempFreqList.frequency_unsorted(*tempWordListpt);
                tempFreqList.sort();
                if (tempWordNode->pprev == NULL) {
                    F[i].copy(tempFreqList);
                    tempFreqList.clear();
                }
                else {
                   tempFreqList2.copy(F[i]);
                   F[i].clear();
                   F[i].list_intersection_nonrec(tempFreqList,tempFreqList2);
                   tempFreqList.clear();
                   tempFreqList2.clear();
                }
                tempWordNode = tempWordNode->pnext;
            }
            tempWordList.clear();
            i++;
            log << "Names of those files which contain the words: '" << SParser.cmd.value1 << "' are successfully found and written into list " << SParser.cmd.listID << ".\n" << endl;
            break;
        case 0:
            log << "Error: above line is not a valid script form.\n" << endl;
            break;
        }
    }
  
  log << "End parsing script file \'" << script << "\'.\n" <<endl;
  log.close();
  delete[] L;
  delete[] F;
  delete[] S;
  return 0;
}