[beast/devel: 3/77] BIRNET: add 'using namespace Rapicorn' to namespace Bse, remove binary lookup functions



commit 4e3a3e205f0abd29ffd2b0c0b58c948b1336dbfd
Author: Tim Janik <timj gnu org>
Date:   Thu Mar 28 18:32:37 2013 +0000

    BIRNET: add 'using namespace Rapicorn' to namespace Bse, remove binary lookup functions

 birnet/birnet.hh      |   13 +++++----
 birnet/birnetutils.hh |   69 -------------------------------------------------
 2 files changed, 7 insertions(+), 75 deletions(-)
---
diff --git a/birnet/birnet.hh b/birnet/birnet.hh
index 451d617..52cbc2b 100644
--- a/birnet/birnet.hh
+++ b/birnet/birnet.hh
@@ -8,10 +8,11 @@
 #include <birnet/birnetmath.hh>
 #include <birnet/birnetutf8.hh>
 #include <birnet/birnetutils.hh>
-/**
- * @namespace Birnet
- * Library with utility functions, carried forward in Rapicorn: http://dev.testbit.eu/rapicorn/latest/
- */
-namespace Birnet {}
+
+// We're migrating to Bse for everything and use Rapicorn core for the lower level stuff
+#include <rapicorn-core.hh>
+namespace Bse {
+using namespace Rapicorn;
+} // Bse
+
 #endif /* __BIRNET_H__ */
-/* vim:set ts=8 sts=2 sw=2: */
diff --git a/birnet/birnetutils.hh b/birnet/birnetutils.hh
index 14ee735..c4e39c8 100644
--- a/birnet/birnetutils.hh
+++ b/birnet/birnetutils.hh
@@ -233,75 +233,6 @@ protected:
 /* --- ReferenceCountImpl --- */
 typedef Rapicorn::ReferenceCountable ReferenceCountImpl;
 
-/* --- Binary Lookups --- */
-template<typename RandIter, class Cmp, typename Arg, int case_lookup_or_sibling_or_insertion>
-static inline std::pair<RandIter,bool>
-binary_lookup_fuzzy (RandIter  begin,
-                     RandIter  end,
-                     Cmp       cmp_elements,
-                     const Arg &arg)
-{
-  RandIter current = end;
-  size_t n_elements = end - begin, offs = 0;
-  const bool want_lookup = case_lookup_or_sibling_or_insertion == 0;
-  // const bool want_sibling = case_lookup_or_sibling_or_insertion == 1;
-  const bool want_insertion_pos = case_lookup_or_sibling_or_insertion > 1;
-  ssize_t cmp = 0;
-  while (offs < n_elements)
-    {
-      size_t i = (offs + n_elements) >> 1;
-      current = begin + i;
-      cmp = cmp_elements (arg, *current);
-      if (cmp == 0)
-        return want_insertion_pos ? std::make_pair (current, true) : std::make_pair (current, /*ignored*/ 
false);
-      else if (cmp < 0)
-        n_elements = i;
-      else /* (cmp > 0) */
-        offs = i + 1;
-    }
-  /* check is last mismatch, cmp > 0 indicates greater key */
-  return (want_lookup
-          ? std::make_pair (end, /*ignored*/ false)
-          : (want_insertion_pos && cmp > 0)
-          ? std::make_pair (current + 1, false)
-          : std::make_pair (current, false));
-}
-template<typename RandIter, class Cmp, typename Arg>
-static inline std::pair<RandIter,bool>
-binary_lookup_insertion_pos (RandIter  begin,
-                             RandIter  end,
-                             Cmp       cmp_elements,
-                             const Arg &arg)
-{
-  /* return (end,false) for end-begin==0, or return (position,true) for exact match,
-   * otherwise return (position,false) where position indicates the location for
-   * the key to be inserted (and may equal end).
-   */
-  return binary_lookup_fuzzy<RandIter,Cmp,Arg,2> (begin, end, cmp_elements, arg);
-}
-template<typename RandIter, class Cmp, typename Arg>
-static inline RandIter
-binary_lookup_sibling (RandIter  begin,
-                       RandIter  end,
-                       Cmp       cmp_elements,
-                       const Arg &arg)
-{
-  /* return end for end-begin==0, otherwise return the exact match element, or,
-   * if there's no such element, return the element last visited, which is pretty
-   * close to an exact match (will be one off into either direction).
-   */
-  return binary_lookup_fuzzy<RandIter,Cmp,Arg,1> (begin, end, cmp_elements, arg).first;
-}
-template<typename RandIter, class Cmp, typename Arg>
-static inline RandIter
-binary_lookup (RandIter  begin,
-               RandIter  end,
-               Cmp       cmp_elements,
-               const Arg &arg)
-{
-  /* return end or exact match */
-  return binary_lookup_fuzzy<RandIter,Cmp,Arg,0> (begin, end, cmp_elements, arg).first;
-}
 /* --- generic named data --- */
 template<typename Type>
 class DataKey {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]