KDevelop API Documentation

test-string-trie.cxx

Go to the documentation of this file.
00001 //
00002 //
00003 // C++ Implementation for module: Test
00004 //
00005 // Description: 
00006 //
00007 //
00008 // Author: exa
00009 //
00010 // Copyright: See COPYING file that comes with this distribution
00011 //
00012 //
00013 
00014 #include "Trie.hxx"
00015 #include <string>
00016 
00017 inline char blank(const string& str) {
00018   return ' ';
00019 }
00020 
00021 inline char first(const string& str) {
00022   return str[0];
00023 }
00024 
00025 inline void strip(string& str) {
00026   str.erase(0,1);
00027 }
00028 
00029 inline bool empty(const string& str) {
00030   return str.empty();
00031 }
00032 
00033 inline int length(const string& str) {
00034   return str.size();
00035 }
00036 
00037 inline void add_prefix(string& str, const char& prefix) {
00038   str.insert(str.begin(), prefix);
00039 //   cout << "add_prefix: prefix=<" << prefix <<  ">" << endl;
00040 //   cout << "add_prefix: <" << str << ">" << endl;
00041 }
00042 
00043 int main()
00044 {
00045   Trie<char, string, int> A;
00046 
00047   A.insert("abd", 3);
00048   A.insert("abc", 2);
00049   A.insert("bcg", 1);
00050   A.insert("bug", 5);
00051 
00052   cout << "query abd ";
00053   int* comp = A.query("abd");
00054   if (comp) cout << "val " << *comp << endl;
00055   else cout << "not found" << endl;
00056 
00057   cout << "query abk ";
00058   comp = A.query("abk");
00059   if (comp) cout << "val " << *comp << endl;
00060   else cout << "not found" << endl;
00061 
00062   cout << "query abc ";
00063   comp = A.query("abc");
00064   if (comp) cout << "val " << *comp << endl;
00065   else cout << "not found" << endl;
00066 
00067   cout << "query bug ";
00068   comp = A.query("bug");
00069   if (comp) cout << "val " << *comp << endl;
00070   else cout << "not found" << endl;
00071   
00072 }
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Feb 22 09:22:36 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003