Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67475 - in sandbox/SOC/2010/bit_masks: boost/integer lib/integer/test/bitfield_vector_testing
From: bbartmanboost_at_[hidden]
Date: 2010-12-28 12:35:14


Author: bbartman
Date: 2010-12-28 12:35:13 EST (Tue, 28 Dec 2010)
New Revision: 67475
URL: http://svn.boost.org/trac/boost/changeset/67475

Log:
working on completeing a the bitfiled_vectors implementation and testing facilities
Text files modified:
   sandbox/SOC/2010/bit_masks/boost/integer/bitfield_vector.hpp | 47 ++++++++++++++++++++++++++++++++-------
   sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/bitfield_vector_test.cpp | 24 ++++++++++++++++++++
   2 files changed, 62 insertions(+), 9 deletions(-)

Modified: sandbox/SOC/2010/bit_masks/boost/integer/bitfield_vector.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/bitfield_vector.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/bitfield_vector.hpp 2010-12-28 12:35:13 EST (Tue, 28 Dec 2010)
@@ -17,6 +17,8 @@
 namespace boost {
 
 namespace detail {
+
+
 /** Iterators. */
 //@{
 template<typename T, std::size_t Width>
@@ -53,8 +55,9 @@
 
     using _base::operator typename _base::bool_type;
 
- _self operator=(_self const& rhs) {
+ _self const& operator=(_self const& rhs) {
         this->assign(static_cast<_base>(rhs));
+ return *this;
     }
 
     reference operator*() const {
@@ -172,8 +175,9 @@
         return ret.const_deref();
     }
 
- _self operator=(_self const& rhs) {
+ _self const& operator=(_self const& rhs) {
         this->assign(static_cast<_base>(rhs));
+ return *this;
     }
 
 
@@ -282,8 +286,9 @@
         return ret.deref();
     }
 
- _self operator=(_self const& rhs) {
+ _self const& operator=(_self const& rhs) {
         this->assign(static_cast<_base>(rhs));
+ return *this;
     }
 
     _self& operator++() {
@@ -391,8 +396,9 @@
         return ret.const_deref();
     }
 
- _self operator=(_self const& rhs) {
+ _self const& operator=(_self const& rhs) {
         this->assign(static_cast<_base>(rhs));
+ return *this;
     }
 
     _self& operator++() {
@@ -460,7 +466,7 @@
 
 //@}
 
-
+/// TODO: Fix reverse iterator!!!!!!!
 template < typename T,
             std::size_t Width,
             typename Allocator = std::allocator<unsigned char>
@@ -714,9 +720,23 @@
 
 
 
+ /** Resize to a size given in elements. */
+ void resize(size_type sz, value_type c = value_type() ) {
+ size_type next_size_in_bits = Width * sz;
+
+ // fewer elements than needed.
+ if(next_size_in_bits <= this->m_impl.m_bits_in_use ) {
+ this->m_impl.m_bits_in_use = next_size_in_bits;
+ return;
+ }
 
- void resize(size_type sz, value_type c = value_type() );
- reference operator[](size_type n);
+ // not enough space
+ if(next_size_in_bits > ((this->m_impl.m_end - this->m_impl.m_start) * Width)) {
+ // while(
+ }
+
+ }
+ reference operator[](size_type n);
     const_reference operator[](size_type n) const;
     reference at(size_type n);
     const_reference at(size_type n) const;
@@ -725,7 +745,16 @@
     template <class InputIterator>
     void assign(InputIterator first, InputIterator last);
     void assign(size_type n, value_type const& u);
- void push_back(value_type const& x);
+
+ /**
+ *
+ */
+ void push_back(value_type const& x) {
+ check_for_resizing();
+ iterator iter = end();
+ *iter = x;
+ this->m_impl.m_bits_in_use += Width;
+ }
     void pop_back();
     iterator insert(iterator position, value_type const& x);
     void insert(iterator position, size_type n, value_type const& x);
@@ -778,7 +807,7 @@
         size_type size_of_alloc = (this->m_impl.m_end - this->m_impl.m_start);
         difference_type remaing_bits = ((size_of_alloc*CHAR_BIT) -
             this->m_impl.m_bits_in_use);
- if(remaing_bits < Width) {
+ if(size_type(remaing_bits) < Width) {
             std::size_t next_allocation_size =
                 detail::next_allocation_size<Width>()(
                     size_of_alloc, this->m_impl.m_bits_in_use);

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/bitfield_vector_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/bitfield_vector_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bitfield_vector_testing/bitfield_vector_test.cpp 2010-12-28 12:35:13 EST (Tue, 28 Dec 2010)
@@ -280,6 +280,17 @@
         this->clear();
         BOOST_TEST( this->m_impl.m_bits_in_use == 0);
     }
+
+ // resize
+ void test_resize() {
+ // BOOST_TEST( )
+ // test case size > the the resizing value.
+ }
+
+ // push_back
+ void test_push_back(T val) {
+ BOOST_TEST(this->back() == val);
+ }
 };
 
 
@@ -409,6 +420,19 @@
         Tester t2(8, 2);
         t2.test_clear();
     }
+
+ // resize test
+ {
+ Tester t1(8,2);
+ t1.test_resize();
+ }
+
+ // push_back test
+ {
+ Tester t1(8,2);
+ t1.push_back(3);
+ t1.test_push_back(3);
+ }
 }
 
 int main() {


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