|
Boost-Commit : |
From: phil_at_[hidden]
Date: 2008-08-12 06:03:11
Author: pbouchard
Date: 2008-08-12 06:03:09 EDT (Tue, 12 Aug 2008)
New Revision: 48098
URL: http://svn.boost.org/trac/boost/changeset/48098
Log:
Improved T100 and removed Boost license from STL headers.
Added:
sandbox/shifted_ptr/libs/smart_ptr/example/t100_test1.cpp (contents, props changed)
Removed:
sandbox/shifted_ptr/libs/smart_ptr/example/regex_test1.cpp
Text files modified:
sandbox/shifted_ptr/bits/list.tcc | 11 --------
sandbox/shifted_ptr/bits/list.tcc.patch | 29 ++------------------
sandbox/shifted_ptr/bits/stl_list.h | 11 --------
sandbox/shifted_ptr/bits/stl_list.h.patch | 54 +++++++++++----------------------------
sandbox/shifted_ptr/boost/shifted_allocator.hpp | 2
sandbox/shifted_ptr/libs/smart_ptr/example/t100.h | 39 +++++++++++++++++++---------
6 files changed, 47 insertions(+), 99 deletions(-)
Modified: sandbox/shifted_ptr/bits/list.tcc
==============================================================================
--- sandbox/shifted_ptr/bits/list.tcc (original)
+++ sandbox/shifted_ptr/bits/list.tcc 2008-08-12 06:03:09 EDT (Tue, 12 Aug 2008)
@@ -53,17 +53,6 @@
* purpose. It is provided "as is" without express or implied warranty.
*/
-/**
- Copyright (c) 2008 Phil Bouchard <phil_at_[hidden]>.
-
- 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
-
- See http://www.boost.org/libs/smart_ptr/doc/index.html for documentation.
-*/
-
/** @file list.tcc
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
Modified: sandbox/shifted_ptr/bits/list.tcc.patch
==============================================================================
--- sandbox/shifted_ptr/bits/list.tcc.patch (original)
+++ sandbox/shifted_ptr/bits/list.tcc.patch 2008-08-12 06:03:09 EDT (Tue, 12 Aug 2008)
@@ -1,27 +1,6 @@
--- /local/include/c++/3.4.5/bits/list.tcc Wed Jan 18 11:06:46 2006
-+++ list.tcc Mon Aug 4 08:26:07 2008
-@@ -51,35 +51,72 @@
- * in supporting documentation. Silicon Graphics makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- */
-
-+/**
-+ Copyright (c) 2008 Phil Bouchard <phil_at_[hidden]>.
-+
-+ 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
-+
-+ See http://www.boost.org/libs/smart_ptr/doc/index.html for documentation.
-+*/
-+
- /** @file list.tcc
- * This is an internal header file, included by other library headers.
- * You should not attempt to use it directly.
- */
-
++++ list.tcc Tue Aug 12 02:58:56 2008
+@@ -61,25 +61,51 @@
#ifndef _LIST_TCC
#define _LIST_TCC 1
@@ -82,7 +61,7 @@
typename list<_Tp,_Alloc>::iterator
list<_Tp,_Alloc>::
insert(iterator __position, const value_type& __x)
-@@ -235,12 +272,12 @@
+@@ -235,12 +261,12 @@
void
list<_Tp,_Alloc>::
sort()
@@ -97,7 +76,7 @@
list __tmp[64];
list * __fill = &__tmp[0];
list * __counter;
-@@ -339,12 +376,12 @@
+@@ -339,12 +365,12 @@
void
list<_Tp,_Alloc>::
sort(_StrictWeakOrdering __comp)
Modified: sandbox/shifted_ptr/bits/stl_list.h
==============================================================================
--- sandbox/shifted_ptr/bits/stl_list.h (original)
+++ sandbox/shifted_ptr/bits/stl_list.h 2008-08-12 06:03:09 EDT (Tue, 12 Aug 2008)
@@ -53,17 +53,6 @@
* purpose. It is provided "as is" without express or implied warranty.
*/
-/**
- Copyright (c) 2008 Phil Bouchard <phil_at_[hidden]>.
-
- 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
-
- See http://www.boost.org/libs/smart_ptr/doc/index.html for documentation.
-*/
-
/** @file stl_list.h
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
Modified: sandbox/shifted_ptr/bits/stl_list.h.patch
==============================================================================
--- sandbox/shifted_ptr/bits/stl_list.h.patch (original)
+++ sandbox/shifted_ptr/bits/stl_list.h.patch 2008-08-12 06:03:09 EDT (Tue, 12 Aug 2008)
@@ -1,28 +1,6 @@
--- /local/include/c++/3.4.5/bits/stl_list.h Wed Jan 18 11:06:54 2006
-+++ stl_list.h Mon Aug 4 08:34:46 2008
-@@ -51,10 +51,21 @@
- * in supporting documentation. Silicon Graphics makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- */
-
-+/**
-+ Copyright (c) 2008 Phil Bouchard <phil_at_[hidden]>.
-+
-+ 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
-+
-+ See http://www.boost.org/libs/smart_ptr/doc/index.html for documentation.
-+*/
-+
- /** @file stl_list.h
- * This is an internal header file, included by other library headers.
- * You should not attempt to use it directly.
- */
-
-@@ -69,62 +80,82 @@
++++ stl_list.h Tue Aug 12 02:58:50 2008
+@@ -69,62 +69,82 @@
// latter publicly inherits from the former in an effort to reduce code
// duplication. This results in some "needless" static_cast'ing later on,
// but it's all safe downcasting.
@@ -116,7 +94,7 @@
// Must downcast from List_node_base to _List_node to get to _M_data.
reference
operator*() const
-@@ -171,37 +202,37 @@
+@@ -171,37 +191,37 @@
bool
operator!=(const _Self& __x) const
{ return _M_node != __x._M_node; }
@@ -160,7 +138,7 @@
_List_const_iterator(const iterator& __x)
: _M_node(__x._M_node) { }
-@@ -216,11 +247,11 @@
+@@ -216,11 +236,11 @@
{ return &static_cast<_Node*>(_M_node)->_M_data; }
_Self&
@@ -173,7 +151,7 @@
_Self
operator++(int)
-@@ -252,23 +283,23 @@
+@@ -252,23 +272,23 @@
bool
operator!=(const _Self& __x) const
{ return _M_node != __x._M_node; }
@@ -204,7 +182,7 @@
/**
* @if maint
-@@ -290,41 +321,43 @@
+@@ -290,41 +310,43 @@
//
// We put this to the test in the constructors and in
// get_allocator, where we use conversions between
@@ -258,7 +236,7 @@
// This is what actually destroys the list.
~_List_base()
{ _M_clear(); }
-@@ -333,12 +366,12 @@
+@@ -333,12 +355,12 @@
_M_clear();
void
@@ -273,7 +251,7 @@
/**
* @brief A standard container with linear time access to elements,
-@@ -393,26 +426,26 @@
+@@ -393,26 +415,26 @@
typedef _List_base<_Tp, _Alloc> _Base;
@@ -307,7 +285,7 @@
* One data member plus two memory-handling functions. If the
* _Alloc type requires separate instances, then one of those
* will also be included, accumulated from the topmost parent.
-@@ -427,21 +460,21 @@
+@@ -427,21 +449,21 @@
* @param x An instance of user data.
*
* Allocates space for a new node and constructs a copy of @a x in it.
@@ -333,7 +311,7 @@
return __p;
}
-@@ -449,21 +482,21 @@
+@@ -449,21 +471,21 @@
* @if maint
* Allocates space for a new node and default-constructs a new
* instance of @c value_type in it.
@@ -359,7 +337,7 @@
return __p;
}
-@@ -595,37 +628,37 @@
+@@ -595,37 +617,37 @@
* Returns a read/write iterator that points to the first element in the
* %list. Iteration is done in ordinary element order.
*/
@@ -401,7 +379,7 @@
* Returns a read/write reverse iterator that points to the last
* element in the %list. Iteration is done in reverse element
* order.
-@@ -666,11 +699,11 @@
+@@ -666,11 +688,11 @@
* Returns true if the %list is empty. (Thus begin() would equal
* end().)
*/
@@ -414,7 +392,7 @@
size_type
size() const
{ return std::distance(begin(), end()); }
-@@ -795,11 +828,11 @@
+@@ -795,11 +817,11 @@
* Note that no data is returned, and if the last element's data
* is needed, it should be retrieved before pop_back() is called.
*/
@@ -427,7 +405,7 @@
* @brief Inserts given value into %list before specified iterator.
* @param position An iterator into the %list.
* @param x Data to be inserted.
-@@ -908,11 +941,11 @@
+@@ -908,11 +930,11 @@
* specialized such that std::swap(l1,l2) will feed to this
* function.
*/
@@ -440,7 +418,7 @@
* Erases all the elements. Note that this function only erases
* the elements, and that if the elements themselves are
* pointers, the pointed-to memory is not touched in any way.
-@@ -1071,11 +1104,11 @@
+@@ -1071,11 +1093,11 @@
*
* Reverse the order of elements in the list in linear time.
*/
@@ -453,7 +431,7 @@
* @brief Sort the elements.
*
* Sorts the elements of this list in NlogN time. Equivalent
-@@ -1158,12 +1191,13 @@
+@@ -1158,12 +1180,13 @@
// Inserts new element at position given and with value given.
void
Modified: sandbox/shifted_ptr/boost/shifted_allocator.hpp
==============================================================================
--- sandbox/shifted_ptr/boost/shifted_allocator.hpp (original)
+++ sandbox/shifted_ptr/boost/shifted_allocator.hpp 2008-08-12 06:03:09 EDT (Tue, 12 Aug 2008)
@@ -48,7 +48,7 @@
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef shifted_ptr<T> pointer;
- typedef const shifted_ptr<T> const_pointer;
+ typedef shifted_ptr<const T> const_pointer;
typedef value_type & reference;
typedef const value_type & const_reference;
Deleted: sandbox/shifted_ptr/libs/smart_ptr/example/regex_test1.cpp
==============================================================================
--- sandbox/shifted_ptr/libs/smart_ptr/example/regex_test1.cpp 2008-08-12 06:03:09 EDT (Tue, 12 Aug 2008)
+++ (empty file)
@@ -1,24 +0,0 @@
-/**
- @file
- regex_test1.cpp
-*/
-
-#include <vector>
-#include <string>
-#include <iostream>
-#include <boost/regex.hpp>
-#include <boost/shifted_ptr.hpp>
-
-#include "t100.h"
-
-using namespace std;
-using namespace boost;
-using boost::detail::sh::neuron_sight;
-
-
-int main(int argv, char * argc[])
-{
- shifted_ptr<neuron_sight> t100 = new shifted<neuron_sight>("I eat ([a-z]+) then drink ([a-z]+)", new shifted<neuron_sight>("beef|chicken"), new shifted<neuron_sight>("vodka|water"));
-
- cout << ((* t100)("I eat beef then drink water") > .5 ? "true" : "false") << endl;
-}
Modified: sandbox/shifted_ptr/libs/smart_ptr/example/t100.h
==============================================================================
--- sandbox/shifted_ptr/libs/smart_ptr/example/t100.h (original)
+++ sandbox/shifted_ptr/libs/smart_ptr/example/t100.h 2008-08-12 06:03:09 EDT (Tue, 12 Aug 2008)
@@ -42,7 +42,7 @@
enum sense_t {sight, sound, touch, smell, taste};
boost::regex exp_;
- std::vector<pointer> sub_;
+ std::vector< std::pair<double, pointer> > sub_;
neuron_base(std::string const & s) : exp_(s), sub_(exp_.mark_count()) {}
virtual ~neuron_base() {};
@@ -66,9 +66,9 @@
{
search_[s] = reinterpret_cast<pointee *>(this); /// FIXME
- if (p1) sub_[0] = p1;
- if (p2) sub_[1] = p2;
- if (p3) sub_[2] = p3;
+ if (p1) sub_[0].second = p1;
+ if (p2) sub_[1].second = p2;
+ if (p3) sub_[2].second = p3;
}
double operator () (std::string const & input)
@@ -77,20 +77,31 @@
if (! boost::regex_match(input, what, exp_, boost::match_default | boost::match_partial))
return 0;
-
+
if (! what[0].matched)
return 0;
// ponderate
- double accuracy = 0;
+ double accuracy = what.size() > 1 ? 0 : 1;
for (int i = 1; i < what.size(); i ++)
+ {
if (what[i].matched)
- accuracy += (* sub_[i])(what[i].str()) / (what.size() - 1);
-
+ {
+ sub_[i - 1].first = (* sub_[i - 1].second)(what[i].str()) / (what.size() - 1);
+ accuracy += sub_[i - 1].first;
+ }
+ }
+
+/*
+ if (accuracy < .7)
+ return accuracy;
+*/
+
// learn if sounds equitable, God tells you to or "energy" spent is still low
- if (accuracy > .7)
- for (int i = 1; i < what.size(); i ++)
- if (! what[i].matched)
+ for (int i = 1; i < what.size(); i ++)
+ if (what[i].matched)
+ {
+ if (sub_[i - 1].first == 0)
{
typename map_sn_t::iterator j = search_.find(what[i].str());
@@ -102,15 +113,17 @@
- calculate difference between all proposals
- create new regular expression when demand is too high
*/
- sub_[i] = j->second;
+ sub_[i - 1].second = j->second;
}
else
{
/**
- Over here we should start guessing
+ Learn
*/
+ sub_[i - 1].second->exp_.str() = sub_[i - 1].second->exp_.str() + "|" + input;
}
}
+ }
return accuracy;
}
Added: sandbox/shifted_ptr/libs/smart_ptr/example/t100_test1.cpp
==============================================================================
--- (empty file)
+++ sandbox/shifted_ptr/libs/smart_ptr/example/t100_test1.cpp 2008-08-12 06:03:09 EDT (Tue, 12 Aug 2008)
@@ -0,0 +1,25 @@
+/**
+ @file
+ regex_test1.cpp
+*/
+
+#include <vector>
+#include <string>
+#include <iostream>
+#include <boost/regex.hpp>
+#include <boost/shifted_ptr.hpp>
+
+#include "t100.h"
+
+using namespace std;
+using namespace boost;
+using boost::detail::sh::neuron_sight;
+
+
+int main(int argv, char * argc[])
+{
+ shifted_ptr<neuron_sight> t100 = new shifted<neuron_sight>("I eat ([a-z]+) then drink ([a-z]+)", new shifted<neuron_sight>("beef|chicken"), new shifted<neuron_sight>("vodka|water"));
+
+ cout << (* t100)("I eat beef then drink wine") << endl;
+ cout << (* t100)("I eat beef then drink wine") << endl;
+}
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