summaryrefslogtreecommitdiff
path: root/examples/Map_Manager
diff options
context:
space:
mode:
authorlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-03-09 22:10:51 +0000
committerlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-03-09 22:10:51 +0000
commitb7071da306d7d8fcddaf984036ddfa3ef592973b (patch)
tree290ad958d36b2007bef1cfe5ba2a8d80c9281859 /examples/Map_Manager
parent14df2aa7bd767352a9d0db5903c77c244472d0e5 (diff)
downloadATCD-b7071da306d7d8fcddaf984036ddfa3ef592973b.tar.gz
added #include of ace/SString.h and template instantiations, and replaced gets with ACE_OS::fgets
Diffstat (limited to 'examples/Map_Manager')
-rw-r--r--examples/Map_Manager/test_hash_map_manager.cpp91
1 files changed, 55 insertions, 36 deletions
diff --git a/examples/Map_Manager/test_hash_map_manager.cpp b/examples/Map_Manager/test_hash_map_manager.cpp
index eb5618e7003..85d36d0f001 100644
--- a/examples/Map_Manager/test_hash_map_manager.cpp
+++ b/examples/Map_Manager/test_hash_map_manager.cpp
@@ -1,63 +1,67 @@
+// $Id$
+
+#include "ace/Hash_Map_Manager.h"
#include "ace/ACE.h"
+#include "ace/SString.h"
#include "ace/Synch.h"
-#include "ace/Hash_Map_Manager.h"
const int MAX_KEY_LEN = 1000;
typedef ACE_Hash_Map_Manager<ACE_CString, ACE_CString, ACE_RW_Mutex> MAP_MANAGER;
int
-main (int argc, char *argv[])
+main (int argc, char *argv[])
{
- if (argc != 4)
+ if (argc != 4)
cerr << "usage: " << argv[0] << " tablesize file1 file2\n";
- else
+ else
{
int total = ACE_OS::atoi (argv[1]);
- if (!freopen (argv[2], "r", stdin))
- ACE_OS::perror (argv[0]), ACE_OS::exit (1);
+ if (!freopen (argv[2], "r", stdin))
+ ACE_OS::perror (argv[0]), ACE_OS::exit (1);
MAP_MANAGER hash (total);
char key[MAX_KEY_LEN];
- while (gets (key)) // stream ops are just too slow!!
- {
- ACE_CString string (key);
- hash.bind (string, string);
- }
+ while (ACE_OS::fgets (key, sizeof key, ACE_STDIN))
+ // stream ops are just too slow!!
+ {
+ ACE_CString string (key);
+ hash.bind (string, string);
+ }
fclose (stdin);
MAP_MANAGER::ITERATOR iterator (hash);
for (MAP_MANAGER::ENTRY *entry = 0;
- iterator.next (entry) != 0;
- iterator.advance ())
- ACE_DEBUG ((LM_DEBUG, "%s %s\n",
- entry->ext_id_.fast_rep (),
- entry->int_id_.fast_rep ()));
-
- if (!freopen (argv[3], "r", stdin))
- perror (argv[0]), exit (1);
-
- while (gets (key))
- {
- ACE_CString name (key);
- ACE_CString value;
- assert (hash.find (name, value) != -1);
- assert (name == value);
- }
-
- if (!freopen (argv[3], "r", stdin))
- perror (argv[0]), exit (1);
-
- while (gets (key))
- {
- ACE_CString string (key);
- assert (hash.unbind (string) != -1);
- }
+ iterator.next (entry) != 0;
+ iterator.advance ())
+ ACE_DEBUG ((LM_DEBUG, "%s %s\n",
+ entry->ext_id_.fast_rep (),
+ entry->int_id_.fast_rep ()));
+
+ if (!freopen (argv[3], "r", stdin))
+ perror (argv[0]), exit (1);
+
+ while (ACE_OS::fgets (key, sizeof key, ACE_STDIN))
+ {
+ ACE_CString name (key);
+ ACE_CString value;
+ assert (hash.find (name, value) != -1);
+ assert (name == value);
+ }
+
+ if (!freopen (argv[3], "r", stdin))
+ perror (argv[0]), exit (1);
+
+ while (ACE_OS::fgets (key, sizeof key, ACE_STDIN))
+ {
+ ACE_CString string (key);
+ assert (hash.unbind (string) != -1);
+ }
assert (hash.current_size () == 0);
@@ -66,3 +70,18 @@ main (int argc, char *argv[])
return 0;
}
+
+
+#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
+template class ACE_Hash_Map_Entry<ACE_CString, ACE_CString>;
+template class ACE_Hash_Map_Iterator_Base<ACE_CString, ACE_CString, ACE_RW_Mutex>;
+template class ACE_Hash_Map_Iterator<ACE_CString, ACE_CString, ACE_RW_Mutex>;
+template class ACE_Hash_Map_Reverse_Iterator<ACE_CString, ACE_CString, ACE_RW_Mutex>;
+template class ACE_Hash_Map_Manager<ACE_CString, ACE_CString, ACE_RW_Mutex>;
+#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
+#pragma instantiate ACE_Hash_Map_Entry<ACE_CString, ACE_CString>
+#pragma instantiate ACE_Hash_Map_Iterator_Base<ACE_CString, ACE_CString, ACE_RW_Mutex>
+#pragma instantiate ACE_Hash_Map_Iterator<ACE_CString, ACE_CString, ACE_RW_Mutex>
+#pragma instantiate ACE_Hash_Map_Reverse_Iterator<ACE_CString, ACE_CString, ACE_RW_Mutex>
+#pragma instantiate ACE_Hash_Map_Manager<ACE_CString, ACE_CString, ACE_RW_Mutex>
+#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */