summaryrefslogtreecommitdiff
path: root/tests/Map_Test.cpp
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>1999-03-16 01:24:48 +0000
committerSteve Huston <shuston@riverace.com>1999-03-16 01:24:48 +0000
commit6a3e86da7f8be8986575ba63010c13697d6ca1e8 (patch)
tree80cc33b0b270011df4048faa9c5327fff12c3659 /tests/Map_Test.cpp
parent77b86a90891c4293ef060d29b47fcaffd8b56aa8 (diff)
downloadATCD-6a3e86da7f8be8986575ba63010c13697d6ca1e8.tar.gz
Template defs split off to Map_Test.h.
Diffstat (limited to 'tests/Map_Test.cpp')
-rw-r--r--tests/Map_Test.cpp125
1 files changed, 1 insertions, 124 deletions
diff --git a/tests/Map_Test.cpp b/tests/Map_Test.cpp
index 8de0bee3a87..f59178295ee 100644
--- a/tests/Map_Test.cpp
+++ b/tests/Map_Test.cpp
@@ -18,7 +18,7 @@
// ============================================================================
#include "test_config.h"
-#include "ace/Containers.h"
+#include "Map_Test.h"
#include "ace/Map_T.h"
#include "ace/Profile_Timer.h"
#include "ace/Synch.h"
@@ -30,129 +30,6 @@ USELIB("..\ace\aced.lib");
//---------------------------------------------------------------------------
#endif /* defined(__BORLANDC__) && __BORLANDC__ >= 0x0530 */
-// Key data type.
-typedef ACE_Array<char> KEY;
-
-////////////////////////////////////////////////////////////////////////////////
-
-class Key_Generator
-{
- // = TITLE
- // Defines a key generator.
- //
- // = DESCRIPTION
- // This class is used in adapters of maps that do not produce keys.
-public:
-
- Key_Generator (void)
- : counter_ (0)
- {
- }
-
- int operator() (KEY &key)
- {
- // Keep original information in the key intact.
- size_t original_size = key.size ();
-
- // Size of this counter key.
- size_t counter_key_size = sizeof this->counter_;
-
- // Resize to accommodate both the original data and the new key.
- key.size (counter_key_size + original_size);
-
- // Add new key data.
- ACE_OS::memcpy (&key[original_size],
- &++this->counter_,
- sizeof this->counter_);
-
- // Success.
- return 0;
- }
-
-private:
- u_long counter_;
-};
-
-////////////////////////////////////////////////////////////////////////////////
-
-class Hash_Key
-{
-public:
- u_long operator () (const KEY &key) const
- {
- // Recover system generated part of key.
- u_long value;
- size_t counter_key_size = sizeof (u_long);
-
- // Copy system key from user key.
- ACE_OS::memcpy (&value,
- &key[key.size () - counter_key_size],
- sizeof value);
-
- // Return the system key value as the hash value.
- return value;
- }
-};
-
-////////////////////////////////////////////////////////////////////////////////
-
-class Key_Adapter
-{
-public:
-
- int encode (const KEY &original_key,
- const ACE_Active_Map_Manager_Key &active_key,
- KEY &modified_key)
- {
- // Keep original information in the key intact.
- modified_key = original_key;
- size_t original_size = modified_key.size ();
-
- // Size of active key.
- size_t active_key_size = active_key.size ();
-
- // Resize to accommodate both the original data and the new active key.
- modified_key.size (active_key_size + original_size);
-
- // Copy active key data into user key.
- active_key.encode (&modified_key[original_size]);
-
- // Success.
- return 0;
- }
-
- int decode (const KEY &modified_key,
- ACE_Active_Map_Manager_Key &active_key)
- {
- // Read the active key data from the back of the key.
- size_t active_key_size = active_key.size ();
- size_t original_size = modified_key.size () - active_key_size;
-
- // Read off value of index and generation.
- active_key.decode (&modified_key[original_size]);
-
- // Success.
- return 0;
- }
-
- int decode (const KEY &modified_key,
- KEY &original_key)
- {
- // Read the original user key data from the front of the
- // modified key.
- size_t active_key_size = ACE_Active_Map_Manager_Key::size ();
-
- // Copy all the data.
- original_key = modified_key;
-
- // Resize to ignore active key data.
- original_key.size (original_key.size () - active_key_size);
-
- // Success.
- return 0;
- }
-};
-
////////////////////////////////////////////////////////////////////////////////
// Value type.