OSDN Git Service

2006-10-03 Benjamin Kosnik <bkoz@redhat.com>
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 3 Oct 2006 14:26:14 +0000 (14:26 +0000)
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 3 Oct 2006 14:26:14 +0000 (14:26 +0000)
* testsuite/util/native_type/priority_queue/native_pq_tag.hpp: Remove.
* testsuite/util/statistic/sample_var.hpp: Rename to...
* testsuite/util/statistic/sample_variance.hpp: ... this.
* testsuite/util/statistic/res_recorder.hpp: Rename to...
* testsuite/util/statistic/result_recorder.hpp: ... this.
* testsuite/util/statistic/sample_mean.hpp: Format.
* testsuite/util/statistic/sample_mean_confidence_checker.hpp: Same.
* testsuite/util/regression/trait/priority_queue/trait.hpp: Same.
* testsuite/util/regression/trait/erase_if_fn.hpp: Same.
* testsuite/util/regression/trait/assoc/trait.hpp: Same.
* testsuite/util/native_type/priority_queue/
native_priority_queue.hpp: Same.
* testsuite/util/native_type/assoc/native_tree_tag.hpp: Same.
* testsuite/util/native_type/assoc/native_hash_tag.hpp: Same.
* testsuite/util/native_type/assoc/native_hash_map.hpp: Same.
* testsuite/util/performance/priority_queue/timing/join_test.hpp: Same.
* testsuite/util/performance/priority_queue/timing/
modify_test.hpp: Same.
* testsuite/util/performance/assoc/timing/
subscript_insert_test.hpp: Same.
* testsuite/util/performance/time/timing_test_base.hpp: Same.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@117397 138bc75d-0d04-0410-961f-82ee72b054a4

17 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/testsuite/util/native_type/assoc/native_hash_map.hpp
libstdc++-v3/testsuite/util/native_type/assoc/native_hash_tag.hpp
libstdc++-v3/testsuite/util/native_type/assoc/native_tree_tag.hpp
libstdc++-v3/testsuite/util/native_type/priority_queue/native_pq_tag.hpp [deleted file]
libstdc++-v3/testsuite/util/native_type/priority_queue/native_priority_queue.hpp
libstdc++-v3/testsuite/util/performance/assoc/timing/subscript_insert_test.hpp
libstdc++-v3/testsuite/util/performance/priority_queue/timing/join_test.hpp
libstdc++-v3/testsuite/util/performance/priority_queue/timing/modify_test.hpp
libstdc++-v3/testsuite/util/performance/time/timing_test_base.hpp
libstdc++-v3/testsuite/util/regression/trait/assoc/trait.hpp
libstdc++-v3/testsuite/util/regression/trait/erase_if_fn.hpp
libstdc++-v3/testsuite/util/regression/trait/priority_queue/trait.hpp
libstdc++-v3/testsuite/util/statistic/result_recorder.hpp [moved from libstdc++-v3/testsuite/util/statistic/res_recorder.hpp with 67% similarity]
libstdc++-v3/testsuite/util/statistic/sample_mean.hpp
libstdc++-v3/testsuite/util/statistic/sample_mean_confidence_checker.hpp
libstdc++-v3/testsuite/util/statistic/sample_variance.hpp [moved from libstdc++-v3/testsuite/util/statistic/sample_var.hpp with 90% similarity]

index dac9c9f..52f6cbd 100644 (file)
@@ -1,3 +1,27 @@
+2006-10-03  Benjamin Kosnik  <bkoz@redhat.com>
+
+       * testsuite/util/native_type/priority_queue/native_pq_tag.hpp: Remove.
+       * testsuite/util/statistic/sample_var.hpp: Rename to...
+       * testsuite/util/statistic/sample_variance.hpp: ... this.
+       * testsuite/util/statistic/res_recorder.hpp: Rename to...
+       * testsuite/util/statistic/result_recorder.hpp: ... this.
+       * testsuite/util/statistic/sample_mean.hpp: Format.
+       * testsuite/util/statistic/sample_mean_confidence_checker.hpp: Same.
+       * testsuite/util/regression/trait/priority_queue/trait.hpp: Same.
+       * testsuite/util/regression/trait/erase_if_fn.hpp: Same.
+       * testsuite/util/regression/trait/assoc/trait.hpp: Same.
+       * testsuite/util/native_type/priority_queue/
+       native_priority_queue.hpp: Same.
+       * testsuite/util/native_type/assoc/native_tree_tag.hpp: Same.
+       * testsuite/util/native_type/assoc/native_hash_tag.hpp: Same.
+       * testsuite/util/native_type/assoc/native_hash_map.hpp: Same.
+       * testsuite/util/performance/priority_queue/timing/join_test.hpp: Same.
+       * testsuite/util/performance/priority_queue/timing/
+       modify_test.hpp: Same.
+       * testsuite/util/performance/assoc/timing/
+       subscript_insert_test.hpp: Same.
+       * testsuite/util/performance/time/timing_test_base.hpp: Same.
+
 2006-10-02  Paolo Carlini  <pcarlini@suse.de>
 
        * include/ext/rc_string_base.h (_M_compare<wchar_t>):
index 889edf2..d6eb835 100644 (file)
@@ -134,5 +134,5 @@ namespace pb_ds
   } // namespace test
 } // namespace pb_ds
 
-#endif // #ifndef PB_DS_NATIVE_HASH_MAP_HPP
+#endif 
 
index 4c6c80b..d4a19c2 100644 (file)
@@ -55,4 +55,4 @@ namespace pb_ds
   } // namespace test
 } // namespace pb_ds
 
-#endif // #ifndef PB_DS_NATIVE_HASH_DS_TAG_HPP
+#endif 
index 079f148..e8f8e70 100644 (file)
@@ -56,4 +56,4 @@ namespace pb_ds
   } // namespace test
 } // namespace pb_ds
 
-#endif // #ifndef PB_DS_NATIVE_TREE_DS_TAG_HPP
+#endif 
diff --git a/libstdc++-v3/testsuite/util/native_type/priority_queue/native_pq_tag.hpp b/libstdc++-v3/testsuite/util/native_type/priority_queue/native_pq_tag.hpp
deleted file mode 100644 (file)
index 8b0357c..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-// -*- C++ -*-
-
-// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library.  This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License as published by the Free Software
-// Foundation; either version 2, or (at your option) any later
-// version.
-
-// This library is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING.  If not, write to
-// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
-// MA 02111-1307, USA.
-
-// As a special exception, you may use this file as part of a free
-// software library without restriction.  Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License.  This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
-
-// Permission to use, copy, modify, sell, and distribute this software
-// is hereby granted without fee, provided that the above copyright
-// notice appears in all copies, and that both that copyright notice
-// and this permission notice appear in supporting documentation. None
-// of the above authors, nor IBM Haifa Research Laboratories, make any
-// representation about the suitability of this software for any
-// purpose. It is provided "as is" without express or implied
-// warranty.
-
-/**
- * @file native_tree_tag.hpp
- * Contains a tag for native tree-based containers
- */
-
-#ifndef PB_DS_NATIVE_PQ_DS_TAG_HPP
-#define PB_DS_NATIVE_PQ_DS_TAG_HPP
-
-namespace pb_ds
-{
-
-  namespace test
-  {
-
-    struct native_pq_tag
-    { };
-
-  } // namespace test
-
-} // namespace pb_ds
-
-#endif // #ifndef PB_DS_NATIVE_PQ_DS_TAG_HPP
index d8a2865..88b2697 100644 (file)
 #ifndef PB_DS_NATIVE_PRIORITY_QUEUE_HPP
 #define PB_DS_NATIVE_PRIORITY_QUEUE_HPP
 
-#include <ext/pb_ds/detail/standard_policies.hpp>
-#include <ext/pb_ds/detail/type_utils.hpp>
-#include <native_type/priority_queue/native_pq_tag.hpp>
-#include <io/xml.hpp>
 #include <string>
 #include <vector>
 #include <queue>
 #include <deque>
+#include <ext/pb_ds/detail/standard_policies.hpp>
+#include <ext/pb_ds/detail/type_utils.hpp>
+#include <io/xml.hpp>
 
 namespace pb_ds
 {
-
   namespace test
   {
-
     namespace detail
     {
-
-      template<typename Value_Type, bool Vector, class Allocator>
+      template<typename Value_Type, bool Vector, typename Allocator>
       struct base_seq
       {
-       typedef
-        std::vector<
-         Value_Type,
-         typename Allocator::template rebind<
-         Value_Type>::other>
-        type;
+      private:
+       typedef typename Allocator::template rebind<Value_Type> value_rebind;
+
+      public:
+       typedef std::vector<Value_Type, typename value_rebind::other> type;
       };
 
-      template<typename Value_Type, class Allocator>
-      struct base_seq<
-       Value_Type,
-       false,
-       Allocator>
+      template<typename Value_Type, typename Allocator>
+      struct base_seq<Value_Type, false, Allocator>
       {
-       typedef
-        std::deque<
-         Value_Type,
-         typename Allocator::template rebind<
-         Value_Type>::other>
-        type;
-      };
+      private:
+       typedef typename Allocator::template rebind<Value_Type> value_rebind;
 
+      public:
+       typedef std::deque<Value_Type, typename value_rebind::other> type;
+      };
     } // namespace detail
 
-#define PB_DS_CLASS_C_DEC                                      \
-    native_priority_queue<                                     \
-                                               Value_Type,     \
-                                               Vector,         \
-                                               Cmp_Fn,         \
-                                               Allocator>
+    struct native_pq_tag
+    { };
+
+#define PB_DS_CLASS_C_DEC \
+    native_priority_queue<Value_Type, Vector, Cmp_Fn, Allocator>
 
-#define PB_DS_BASE_C_DEC                                               \
-    std::priority_queue<                                               \
-                                                                       Value_Type, \
-                                                                       typename detail::base_seq<Value_Type, Vector, Allocator>::type, \
-                                                                       Cmp_Fn>
+#define PB_DS_BASE_C_DEC \
+    std::priority_queue<Value_Type, typename detail::base_seq<Value_Type, Vector, Allocator>::type, Cmp_Fn>
 
     template<typename Value_Type,
             bool Vector,
-            class Cmp_Fn =
-            std::less<Value_Type>,
-            class Allocator = std::allocator<char> >
+            typename Cmp_Fn = std::less<Value_Type>,
+            typename Allocator = std::allocator<char> >
     class native_priority_queue : public PB_DS_BASE_C_DEC
     {
     private:
       typedef PB_DS_BASE_C_DEC base_type;
+      typedef typename Allocator::template rebind<Value_Type> value_rebind;
 
     public:
       typedef Value_Type value_type;
-
-      typedef
-      typename Allocator::template rebind<
-       value_type>::other::const_reference
-      const_reference;
-
+      typedef typename value_rebind::other::const_reference const_reference;
       typedef native_pq_tag container_category;
-
       typedef Cmp_Fn cmp_fn;
 
-    public:
       native_priority_queue() : base_type()
       { }
 
@@ -140,7 +119,6 @@ namespace pb_ds
       {
         if (Vector)
          return ("n_pq_vector");
-
         return ("n_pq_deque");
       }
 
@@ -148,44 +126,36 @@ namespace pb_ds
       desc()
       {
         if (Vector)
-         return (make_xml_tag(                "type",  "value",  "std::priority_queue_vector"));
-
-        return (make_xml_tag(            "type", "value", "std::priority_queue_deque"));
+         return make_xml_tag("type", "value", "std::priority_queue_vector");
+        return make_xml_tag("type", "value", "std::priority_queue_deque");
       }
 
       void
       clear()
-      {
-       * static_cast<base_type* >(this) = base_type();
-      }
+      { *static_cast<base_type*>(this) = base_type(); }
 
       void
       erase(const_reference r_val)
       {
         base_type tmp;
-
         Cmp_Fn cmp;
 
         while (cmp(base_type::top(), r_val) || cmp(r_val, base_type::top()))
          {
             tmp.push(base_type::top());
-
             base_type::pop();
          }
 
         if (!base_type::empty())
          {
             base_type::pop();
-
             while (!base_type::empty())
              {
                 tmp.push(base_type::top());
-
                 base_type::pop();
              }
          }
-
-       * static_cast<base_type* >(this) = tmp;
+       *static_cast<base_type* >(this) = tmp;
       }
 
       template<typename Pred>
@@ -193,21 +163,17 @@ namespace pb_ds
       erase_if(Pred pred)
       {
         base_type tmp;
-
         std::size_t ersd = 0;
-
         while (!base_type::empty())
          {
             if (!pred(base_type::top()))
              tmp.push(base_type::top());
             else
              ++ersd;
-
             base_type::pop();
          }
 
-       * static_cast<base_type* >(this) = tmp;
-
+       *static_cast<base_type*>(this) = tmp;
         return ersd;
       }
 
@@ -216,27 +182,22 @@ namespace pb_ds
       split(Pred pred, PB_DS_CLASS_C_DEC& other)
       {
         base_type tmp;
-
         other.clear();
-
         while (!base_type::empty())
          {
             if (!pred(base_type::top()))
              tmp.push(base_type::top());
             else
              other.push(base_type::top());
-
             base_type::pop();
          }
-
-       * static_cast<base_type* >(this) = tmp;
+       *static_cast<base_type*>(this) = tmp;
       }
 
       void
       modify(const_reference r_old, const_reference r_new)
       {
         erase(r_old);
-
         push(r_new);
       }
 
@@ -244,37 +205,30 @@ namespace pb_ds
       join(PB_DS_CLASS_C_DEC& other)
       {
         std::vector<value_type> a_tmp;
-
         while (!base_type::empty())
          {
             a_tmp.push_back(base_type::top());
-
             base_type::pop();
          }
 
         while (!other.empty())
          {
             a_tmp.push_back(other.top());
-
             other.pop();
          }
 
-       * static_cast<base_type* >(this) = base_type(a_tmp.begin(), a_tmp.end());
+       *static_cast<base_type*>(this) = base_type(a_tmp.begin(), a_tmp.end());
       }
 
       Cmp_Fn
       get_cmp_fn() const
-      {
-        return Cmp_Fn();
-      }
+      { return Cmp_Fn(); }
     };
 
 #undef PB_DS_BASE_C_DEC
-
 #undef PB_DS_CLASS_C_DEC
 
   } // namespace test
-
 } // namespace pb_ds
 
-#endif // #ifndef PB_DS_NATIVE_PRIORITY_QUEUE_HPP
+#endif 
index 1e067c0..3b9efb0 100644 (file)
@@ -50,7 +50,6 @@
 #include <performance/time/timing_test_base.hpp>
 #include <performance/io/xml_formatter.hpp>
 #include <common_type/assoc/string_form.hpp>
-#include <statistic/res_recorder.hpp>
 #include <iterator>
 
 namespace pb_ds
index 2e3dde2..d04f904 100644 (file)
@@ -128,6 +128,9 @@ namespace pb_ds
        using pb_ds::test::detail::double_push_functor;
        using pb_ds::test::detail::double_push_join_functor;
        typedef pb_ds::test::detail::timing_test_base base_type;
+       typedef double_push_functor<It, Cntnr> psh_fnct;
+       typedef double_push_join_functor<It, Cntnr> psh_jn_fnct;
+
        typedef xml_result_set_performance_formatter formatter_type;
        formatter_type res(string_form<Cntnr>::name(), 
                           string_form<Cntnr>::desc());
@@ -139,12 +142,12 @@ namespace pb_ds
            It e = m_ins_b;
            std::advance(e, v);
 
-           double_push_functor<It, Cntnr> double_push_fn(b, e);
-           const double double_push_res = base_type::operator()(double_push_fn);
-           double_push_join_functor<It, Cntnr> double_push_join_fn(b, e);
-           const double double_push_join_res = base_type::operator()(double_push_join_fn);
-             
-           const double effective_delta = std::max(double_push_join_res - double_push_res, base_type::min_time_res());
+           psh_fnct double_push_fn(b, e);
+           const double dbl_psh_res = base_type::operator()(double_push_fn);
+           psh_jn_fnct dbl_psh_jn_fn(b, e);
+           const double dbl_psh_jn_res = base_type::operator()(dbl_psh_jn_fn);
+           const double min_res = double(timing_test_base::min_time_res());
+           const double effective_delta = std::max(dbl_psh_jn_res - dbl_psh_res, min_res);
            res.add_res(v, effective_delta / v);
          }
       }
index 4e76bb5..33c7e58 100644 (file)
@@ -59,6 +59,7 @@ namespace pb_ds
   {
     namespace detail
     {
+      // Primary templates.
       template<typename It, class Cntnr, class Tag>
       class push_functor
       {
@@ -123,6 +124,7 @@ namespace pb_ds
        const value_type m_mod_val;
       };
 
+      // Specializations.
       template<typename It, class Cntnr>
       class push_functor<It, Cntnr, pb_ds::binary_heap_tag>
       {
@@ -149,6 +151,33 @@ namespace pb_ds
       };
 
       template<typename It, class Cntnr>
+      class push_functor<It, Cntnr, pb_ds::test::native_pq_tag>
+      {
+      public:
+        push_functor(It ins_it_b,  It ins_it_e) 
+       : m_ins_it_b(ins_it_b), m_ins_it_e(ins_it_e)
+       { }
+
+       void
+        operator()(std::size_t resolution)
+       {
+         typedef typename Cntnr::const_reference const_reference;
+         for (std::size_t i = 0; i < resolution; ++i)
+           {
+             Cntnr c;
+
+             for (It ins_it = m_ins_it_b; ins_it != m_ins_it_e; ++ins_it)
+                c.push(const_reference(ins_it->first));
+           }
+       }
+
+      private:
+       const It m_ins_it_b;
+       const It m_ins_it_e;
+      };
+
+
+      template<typename It, class Cntnr>
       class push_modify_functor<It, Cntnr, pb_ds::binary_heap_tag>
       {
       private:
@@ -191,32 +220,6 @@ namespace pb_ds
       };
 
       template<typename It, class Cntnr>
-      class push_functor<It, Cntnr, pb_ds::test::native_pq_tag>
-      {
-      public:
-        push_functor(It ins_it_b,  It ins_it_e) 
-       : m_ins_it_b(ins_it_b), m_ins_it_e(ins_it_e)
-       { }
-
-       void
-        operator()(std::size_t resolution)
-       {
-         typedef typename Cntnr::const_reference const_reference;
-         for (std::size_t i = 0; i < resolution; ++i)
-           {
-             Cntnr c;
-
-             for (It ins_it = m_ins_it_b; ins_it != m_ins_it_e; ++ins_it)
-                c.push(const_reference(ins_it->first));
-           }
-       }
-
-      private:
-       const It m_ins_it_b;
-       const It m_ins_it_e;
-      };
-
-      template<typename It, class Cntnr>
       class push_modify_functor<It, Cntnr, pb_ds::test::native_pq_tag>
       {
       private:
@@ -291,8 +294,9 @@ namespace pb_ds
       typedef typename Cntnr::value_type value_type;
       typedef typename Cntnr::container_category container_category;
       typedef typename Cntnr::const_reference const_reference;
-      typedef pb_ds::test::detail::timing_test_base timing_test_base;
-
+      typedef detail::timing_test_base timing_test_base;
+      typedef detail::push_functor<It, Cntnr, container_category> psh_fnct;
+      typedef detail::push_modify_functor<It, Cntnr, container_category> psh_mod_fnct;
       typedef xml_result_set_performance_formatter formatter_type;
       formatter_type res_set_fmt(string_form<Cntnr>::name(),
                                 string_form<Cntnr>::desc());
@@ -300,14 +304,12 @@ namespace pb_ds
       for (size_t i = 0; m_ins_vn + i * m_ins_vs < m_ins_vm; ++i)
        {
          const size_t v = m_ins_vn + i * m_ins_vs;
-         It  b = m_ins_b;
+         It b = m_ins_b;
          It e = m_ins_b;
          std::advance(e, v);
 
-         pb_ds::test::detail::push_functor<It, Cntnr, container_category>
-            push_fn( b, e);
-
-         const double push_res = timing_test_base::operator()(push_fn);
+         psh_fnct psh_fn(b, e);
+         const double psh_res = timing_test_base::operator()(psh_fn);
 
          value_type val = b->first;
          {
@@ -320,13 +322,12 @@ namespace pb_ds
              }
          }
 
-         pb_ds::test::detail::push_modify_functor<It, Cntnr, container_category>
-            push_modify_fn(b, e, val);
-
-         const double push_modify_res = timing_test_base::operator()(push_modify_fn);
+         psh_mod_fnct psh_mod_fn(b, e, val);
+         const double psh_mod_res = timing_test_base::operator()(psh_mod_fn);
 
-         const double effective_delta = std::max(push_modify_res - push_res,
-                                            timing_test_base::min_time_res());
+         const double min_res = double(timing_test_base::min_time_res());
+         const double effective_delta = std::max(psh_mod_res - psh_res,
+                                                 min_res);
 
          res_set_fmt.add_res(v, effective_delta / v);
        }
index c9121fe..a56d2c2 100644 (file)
@@ -48,7 +48,7 @@
 #define PB_DS_TIMING_TEST_BASE_HPP
 
 #include <performance/time/elapsed_timer.hpp>
-#include <statistic/res_recorder.hpp>
+#include <statistic/result_recorder.hpp>
 
 namespace pb_ds
 {
@@ -81,12 +81,12 @@ namespace pb_ds
       timing_test_base::operator()(Functor& fn)
       {
        const std::size_t resolution = get_min_resolution(fn);
-       pb_ds::test::detail::res_recorder<double> rec;
+       pb_ds::test::detail::result_recorder<double> rec;
        double res;
        do
          res = run_at_resolution(fn, resolution);
-       while (rec.add_res(res) == false);
-       res = rec.sample_mean() / resolution;
+       while (rec.add_result(res) == false);
+       res = rec.get_sample_mean() / resolution;
        return res;
       }
 
index 65a6363..9f57110 100644 (file)
@@ -101,22 +101,15 @@ namespace detail
   {
   private:
     typedef PB_DS_NATIVE_TYPE_TRAITS_C_DEC native_type_traits_base;
-
     typedef PB_DS_TYPE_TRAITS_C_DEC type_traits_base;
 
   public:
     typedef typename Cntnr::key_type key_type;
-
     typedef typename Cntnr::const_key_reference const_key_reference;
-
     typedef typename Cntnr::value_type value_type;
-
     typedef typename Cntnr::const_reference const_reference;
-
     typedef typename PB_DS_NATIVE_TYPE_TRAITS_C_DEC::type native_type;
-
     typedef typename native_type::key_type native_key_type;
-
     typedef typename native_type::value_type native_value_type;
 
     enum
@@ -153,73 +146,49 @@ namespace detail
 
     static void
     print_container(const Cntnr& r_c, std::ostream& r_os)
-    {
-      PB_DS_TYPE_TRAITS_C_DEC::print_container(r_c, r_os);
-    }
-
-  public:
+    { PB_DS_TYPE_TRAITS_C_DEC::print_container(r_c, r_os); }
 
     template<typename Gen>
     static key_type
     generate_key(Gen& r_gen, size_t max)
-    {
-      return PB_DS_TYPE_TRAITS_C_DEC::generate_key(r_gen, max);
-    }
+    { return PB_DS_TYPE_TRAITS_C_DEC::generate_key(r_gen, max); }
 
     template<typename Gen>
     static value_type
     generate_value(Gen& r_gen, size_t max)
-    {
-      return PB_DS_TYPE_TRAITS_C_DEC::generate_value(r_gen, max);
-    }
+    { return PB_DS_TYPE_TRAITS_C_DEC::generate_value(r_gen, max); }
 
     static const_key_reference
     extract_key(const_reference r_val)
-    {
-      return type_traits_base::extract_key(r_val);
-    }
+    { return type_traits_base::extract_key(r_val); }
 
     static native_key_type
     native_key(const_key_reference r_key)
-    {
-      return native_type_traits_base::native_key(r_key);
-    }
+    { return native_type_traits_base::native_key(r_key); }
 
     static native_value_type
     native_value(const_reference r_val)
-    {
-      return native_type_traits_base::native_value(r_val);
-    }
+    { return native_type_traits_base::native_value(r_val); }
 
     static const native_key_type& 
     extract_native_key(const native_value_type& r_val)
-    {
-      return native_type_traits_base::extract_key(r_val);
-    }
+    { return native_type_traits_base::extract_key(r_val); }
 
     static bool
     cmp(const_reference r_val, const native_value_type& r_native_val)
-    {
-      return val_to_string(r_val) == native_val_to_string(r_native_val);
-    }
+    { return val_to_string(r_val) == native_val_to_string(r_native_val); }
 
     static std::string
     val_to_string(const_reference r_val)
-    {
-      return to_string(r_val);
-    }
+    { return to_string(r_val); }
 
     static std::string
     key_to_string(const_key_reference r_key)
-    {
-      return to_string(r_key);
-    }
+    { return to_string(r_key); }
 
     static std::string
     native_val_to_string(const native_value_type& r_native_val)
-    {
-      return to_string(r_native_val);
-    }
+    { return to_string(r_native_val); }
 
     static bool
     prefix_match(const_key_reference r_key, const std::string& r_native_key)
@@ -232,7 +201,6 @@ namespace detail
 
       return native_substr == (const std::string&) r_key;
     }
-
   };
 
 #undef PB_DS_TYPE_TRAITS_C_DEC
index adab6b0..c583848 100644 (file)
 
 namespace pb_ds
 {
-
   namespace test
   {
-
     namespace detail
     {
-
       template<typename T>
-      struct regression_test_erase_if_fn : public std::unary_function<
-        T,
-        bool>
+      struct regression_test_erase_if_fn 
+      : public std::unary_function<T, bool>
       {
       private:
        typedef const T&  const_reference;
@@ -77,35 +73,23 @@ namespace pb_ds
       };
 
       template<typename Hd, class Tl>
-      struct regression_test_erase_if_fn<
-        std::pair<
-       Hd,
-       Tl> > : public std::unary_function<
-        std::pair<
-       Hd,
-       Tl>,
-        bool>
+      struct regression_test_erase_if_fn<std::pair<Hd, Tl> > 
+      : public std::unary_function<std::pair<Hd, Tl>, bool>
       {
       private:
        typedef const std::pair<Hd, Tl>&  const_reference;
-
-       typedef regression_test_erase_if_fn< Hd> hd_erase_if_fn;
-
-       typedef regression_test_erase_if_fn< Tl> tl_erase_if_fn;
+       typedef regression_test_erase_if_fn<Hd> hd_erase_if_fn;
+       typedef regression_test_erase_if_fn<Tl> tl_erase_if_fn;
 
       public:
        bool
         operator()(const_reference r_t) const
        {
-         return (hd_erase_if_fn()(r_t.first)&& 
-                 tl_erase_if_fn()(r_t.second));
+         return (hd_erase_if_fn()(r_t.first) && tl_erase_if_fn()(r_t.second));
        }
       };
-
     } // namespace detail
-
   } // namespace test
-
 } // namespace pb_ds
 
-#endif // #ifndef PB_DS_REGRESSION_TEST_ERASE_IF_FN_HPP
+#endif 
index 80ffe1f..641d929 100644 (file)
 
 namespace pb_ds
 {
-
   namespace test
   {
-
     namespace detail
     {
-
-#define PB_DS_CLASS_T_DEC                      \
-      template<typename Cntnr>
-
-#define PB_DS_CLASS_C_DEC                              \
-      regression_test_traits<                          \
-                                               Cntnr>
-
       template<typename Cntnr>
       struct regression_test_traits
       {
-
-      public:
-
        typedef typename Cntnr::value_type value_type;
-
        typedef typename Cntnr::const_reference const_reference;
-
-       typedef
-        pb_ds::test::native_priority_queue<
-         std::string,
-         true>
-        native_type;
-
+       typedef pb_ds::test::native_priority_queue<std::string, true> native_type;
        typedef typename native_type::value_type native_value_type;
 
        template<typename T>
-       struct erase_if_fn : public regression_test_erase_if_fn<
-         T>
-       {
-
-       };
-
-      public:
+       struct erase_if_fn : public regression_test_erase_if_fn<T>
+       { };
 
        template<typename Gen>
        static value_type
         generate_value(Gen& r_gen, size_t max)
-       {
-         return basic_type(r_gen, max);
-       }
+       { return basic_type(r_gen, max); }
 
        static native_value_type
         native_value(const_reference r_val)
-       {
-         return (native_value_type(r_val));
-       }
+       { return native_value_type(r_val); }
 
        static bool
         cmp(const_reference r_val, const native_value_type& r_native_val)
-       {
-         return (val_to_string(r_val) == r_native_val);
-       }
+       { return val_to_string(r_val) == r_native_val; }
 
        static std::string
         val_to_string(const_reference r_val)
-       {
-         return (std::string(r_val));
-       }
-
+       { return std::string(r_val); }
       };
-
-#undef PB_DS_CLASS_T_DEC
-
-#undef PB_DS_CLASS_C_DEC
-
     } // namespace detail
-
   } // namespace test
-
 } // namespace pb_ds
 
-#endif // #ifndef PB_DS_REGRESSION_TEST_TRAIT_HPP
+#endif 
@@ -40,7 +40,7 @@
 // warranty.
 
 /**
- * @file res_recorder.hpp
+ * @file result_recorder.hpp
  * Contains a class for recording results
  */
 
 #define PB_DS_RES_RECORDER_HPP
 
 #include <statistic/sample_mean.hpp>
-#include <statistic/sample_var.hpp>
+#include <statistic/sample_variance.hpp>
 #include <statistic/sample_mean_confidence_checker.hpp>
 
 namespace pb_ds
 {
-
   namespace test
   {
-
     namespace detail
     {
-
-#define PB_DS_CLASS_T_DEC                      \
-      template<typename Value_Type>
-
-#define PB_DS_CLASS_C_DEC                                      \
-      res_recorder<                                            \
-                                               Value_Type>
-
       /*
        * Records results until the probability that the sample mean is 10% away
-       *     from the true mean is ~ 0.05.
+       * from the true mean is ~ 0.05.
        */
-      template<typename Value_Type = double>
-      class res_recorder
+      template<typename Value_Type>
+      class result_recorder
       {
       public:
        typedef Value_Type value_type;
 
-      public:
-       res_recorder();
+       result_recorder()
+        : m_sample_mean(value_type()), m_sample_var(value_type())
+       { }
 
        bool
-        add_res(value_type res);
+        add_result(value_type res);
 
        inline value_type
-        sample_mean() const;
+        get_sample_mean() const
+       { return m_sample_mean; }
 
       private:
-       typedef std::list< value_type> list_t;
-
-      private:
-       list_t m_l;
+       typedef std::list<value_type> list_type;
 
+       list_type m_l;
        value_type m_sample_mean;
-
        value_type m_sample_var;
       };
 
-      PB_DS_CLASS_T_DEC
-      PB_DS_CLASS_C_DEC::
-      res_recorder() :
-        m_sample_mean(0)
-      { }
 
-      PB_DS_CLASS_T_DEC
-      inline typename PB_DS_CLASS_C_DEC::value_type
-      PB_DS_CLASS_C_DEC::
-      sample_mean() const
-      {
-       return (m_sample_mean);
-      }
-
-      PB_DS_CLASS_T_DEC
+      template<typename Value_Type>
       bool
-      PB_DS_CLASS_C_DEC::
-      add_res(value_type res)
+      result_recorder<Value_Type>::
+      add_result(value_type res)
       {
        m_l.push_back(res);
+       m_sample_mean = sample_mean(m_l.begin(), m_l.end());
+       m_sample_var = sample_variance(m_l.begin(), m_l.end(), m_sample_mean);
 
-       m_sample_mean = pb_ds::test::detail::sample_mean(m_l.begin(), m_l.end());
-
-       const value_type sample_var =
-         pb_ds::test::detail::sample_var(m_l.begin(), m_l.end(), m_sample_mean);
-
-       return (pb_ds::test::detail::sample_mean_confidence_checker(m_sample_mean,
-                                                                   sample_var,
-                                                                   std::distance(m_l.begin(), m_l.end()),
-                                                                   0.1));
+       size_t dist = std::distance(m_l.begin(), m_l.end());
+       return sample_mean_confidence_checker(m_sample_mean, m_sample_var,
+                                             dist, 0.1);
       }
-
-#undef PB_DS_CLASS_T_DEC
-
-#undef PB_DS_CLASS_C_DEC
-
     } // namespace detail
-
   } // namespace test
-
 } // namespace pb_ds
 
-#endif // #ifndef PB_DS_RES_RECORDER_HPP
+#endif 
 
index 26aa1f7..4c6c561 100644 (file)
 
 namespace pb_ds
 {
-
   namespace test
   {
-
     namespace detail
     {
-
-#define PB_DS_VTYPE                                                    \
-      typename std::iterator_traits<                                   \
-                                                       It>::value_type
+#define PB_DS_VTYPE typename std::iterator_traits<It>::value_type
 
       template<typename It>
       PB_DS_VTYPE
@@ -71,17 +66,14 @@ namespace pb_ds
       {
        const PB_DS_VTYPE total = std::accumulate(b, e, PB_DS_VTYPE(0));
        const size_t num = std::distance(b, e);
-
-       return (total / num);
+       return total / num;
       }
 
 #undef PB_DS_VTYPE
 
     } // namespace detail
-
   } // namespace test
-
 } // namespace pb_ds
 
-#endif // #ifndef PB_DS_SAMPLE_MEAN_HPP
+#endif 
 
index 5fa4607..074adc9 100644 (file)
 
 namespace pb_ds
 {
-
   namespace test
   {
-
     namespace detail
     {
-
       /*
        * Checks that a sample mean sm is in the relative interval
-       *     relative_interval of a true mean (assuming i.i.d. samples),
-       *     given a sample variance sv taken over num_samples samples,
-       *     with confidence ~ 0.95.
+       * relative_interval of a true mean (assuming i.i.d. samples),
+       * given a sample variance sv taken over num_samples samples,
+       * with confidence ~ 0.95.
        *
-       * See "Probability, Random Variables, and Stochastic Processes" (Third edition)
-       *     Athanasios Papoulis, Chapter 9.
+       * See "Probability, Random Variables, and Stochastic Processes"
+       * (Third edition) Athanasios Papoulis, Chapter 9.
        */
       template<typename Value_Type>
       bool
-      sample_mean_confidence_checker(Value_Type sm, Value_Type sv, std::size_t num_samples, double relative_interval)
+      sample_mean_confidence_checker(Value_Type sm, Value_Type sv, 
+                                    std::size_t num_samples, 
+                                    double relative_interval)
       {
        enum
          {
@@ -85,14 +84,11 @@ namespace pb_ds
        // This is z_u (normal-dist percentile) for u = 0.975.
        const Value_Type z = 1.976;
 
-       return (sv / ::sqrt(double(num_samples)) <= relative_interval sm / z);
+       return (sv / ::sqrt(double(num_samples)) <= relative_interval * sm / z);
       }
-
     } // namespace detail
-
   } // namespace test
-
 } // namespace pb_ds
 
-#endif // #ifndef PB_DS_SAMPLE_MEAN_CONFIDENCE_CHECKER_HPP
+#endif 
 
@@ -40,7 +40,7 @@
 // warranty.
 
 /**
- * @file sample_var.hpp
+ * @file sample_variance.hpp
  * Contains a function for calculating a sample variance
  */
 
 
 namespace pb_ds
 {
-
   namespace test
   {
-
     namespace detail
     {
-
-#define PB_DS_VTYPE                                                    \
-      typename std::iterator_traits<                                   \
-                                                       It>::value_type
+#define PB_DS_VTYPE typename std::iterator_traits<It>::value_type
 
       template<typename It>
       PB_DS_VTYPE
-      sample_var(It b, It e, PB_DS_VTYPE sm)
+      sample_variance(It b, It e, PB_DS_VTYPE sm)
       {
        PB_DS_VTYPE ss = 0;
-
        size_t num_res = 0;
 
        while (b != e)
          {
            const PB_DS_VTYPE d =* b - sm;
-
            ss += d*  d;
-
            ++num_res;
-
            ++b;
          }
 
        if (num_res == 1)
-         return (0);
+         return 0;
 
-       return (::sqrt(ss / (num_res - 1)));
+       return ::sqrt(ss / (num_res - 1));
       }
 
 #undef PB_DS_VTYPE
 
     } // namespace detail
-
   } // namespace test
-
 } // namespace pb_ds
 
-#endif // #ifndef PB_DS_SAMPLE_VAR_HPP
+#endif