|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r55886 - sandbox/statistics/tree/boost/tree
From: erwann.rogard_at_[hidden]
Date: 2009-08-30 17:56:17
Author: e_r
Date: 2009-08-30 17:56:16 EDT (Sun, 30 Aug 2009)
New Revision: 55886
URL: http://svn.boost.org/trac/boost/changeset/55886
Log:
modif
Text files modified:
sandbox/statistics/tree/boost/tree/stage.hpp | 64 ++++-----------------------------------
1 files changed, 7 insertions(+), 57 deletions(-)
Modified: sandbox/statistics/tree/boost/tree/stage.hpp
==============================================================================
--- sandbox/statistics/tree/boost/tree/stage.hpp (original)
+++ sandbox/statistics/tree/boost/tree/stage.hpp 2009-08-30 17:56:16 EDT (Sun, 30 Aug 2009)
@@ -1,17 +1,17 @@
///////////////////////////////////////////////////////////////////////////////
-// tree::stage.hpp //
+// tree_view::stage.hpp //
// //
// Copyright 2009 Erwann Rogard. Distributed under the Boost //
// Software License, Version 1.0. (See accompanying file //
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
///////////////////////////////////////////////////////////////////////////////
-#ifndef BOOST_TREE_STAGE_HPP_ER_2009
-#define BOOST_TREE_STAGE_HPP_ER_2009
+#ifndef BOOST_TREE_VIEW_STAGE_HPP_ER_2009
+#define BOOST_TREE_VIEW_STAGE_HPP_ER_2009
#include <stdexcept>
#include <boost/format.hpp>
namespace boost{
-namespace tree{
+namespace tree_view{
// This class maps a position in a tree structure to a position in a vector
//
@@ -20,7 +20,7 @@
// The nodes are stored in a vector, starting with the root node,
// followed by those in stage1, then those in stage 2 etc.
- // i : stage
+ // j : stage
// n : number of branches per node
template<unsigned j,unsigned n>
struct stage{
@@ -42,25 +42,6 @@
template<typename T> struct position_last_{ static unsigned get(); };
template<typename T> struct number_nodes_{ static unsigned get(); };
-
- template<unsigned n>
- class dynamic_stage{
- // TODO boost::switch to allow for abitrary # stages?
- typedef stage<0,n> s0_;
- typedef stage<1,n> s1_;
- typedef stage<2,n> s2_;
- typedef stage<3,n> s3_;
-
- public:
- static unsigned position_first(unsigned i);
- static unsigned position_last(unsigned i);
- static unsigned number_nodes(unsigned i);
-
- private:
- template<template<typename> class F>
- static unsigned switch_(unsigned i);
- };
-
// Implementation //
// Initialization
@@ -87,6 +68,7 @@
unsigned stage<j,n>::number_nodes
= stage<j-1,n>::number_nodes * n;
+ // T = stage
template<typename T>
unsigned position_first_<T>::get(){ return T::position_first; }
template<typename T>
@@ -94,39 +76,7 @@
template<typename T>
unsigned number_nodes_<T>::get(){ return T::number_nodes; }
- template<unsigned n>
- template<template<typename> class F>
- unsigned dynamic_stage<n>::switch_(unsigned j){
- static const char* msg = "dynamic_stage<n>::switch(%1%)";
-
- switch(j){
- case 0 : return F<s0_>::get();
- case 1 : return F<s1_>::get();
- case 2 : return F<s2_>::get();
- case 3 : return F<s3_>::get();
- default : format f(msg); f % j;
- throw std::out_of_range(
- f.str()
- );
- }
- }
-
-
- template<unsigned n>
- unsigned dynamic_stage<n>::position_first(unsigned j){
- return switch_<position_first_>(j);
- }
- template<unsigned n>
- unsigned dynamic_stage<n>::position_last(unsigned j){
- return switch_<position_last_>(j);
- }
-
- template<unsigned n>
- unsigned dynamic_stage<n>::number_nodes(unsigned j){
- return switch_<number_nodes_>(j);
- }
-
-}// tree_navigation
+}// tree_view
}// boost
#endif
\ No newline at end of file
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk