OSDN Git Service

indexer_iterator.hpp 修正やっとこでげだー!
authorMyun2 <myun2@nwhite.info>
Thu, 3 Jun 2010 02:51:49 +0000 (11:51 +0900)
committerMyun2 <myun2@nwhite.info>
Thu, 3 Jun 2010 02:51:49 +0000 (11:51 +0900)
roast/include/roast/container/begin_end_iterator.hpp
roast/include/roast/container/indexer_iterator.hpp
roast/include/roast/container/linear_iterator_base.hpp
roast/test/roast_test_VC90/iterator_test.cpp

index 5002cb3..972eba3 100644 (file)
@@ -13,13 +13,13 @@ namespace roast
        /////////////////////////////////////////////////////////
 
        template <typename _Iterator>
-       class _begin_end_iterator_impl : public linear_iterator_base<_Iterator>
+       class _begin_end_iterator_impl : public _linear_iterator_impl_base<_Iterator>
        {
-               typedef linear_iterator_base<_Iterator> _Base;
+               typedef _linear_iterator_impl_base<_Iterator> _Base;
        public:
                typedef _Iterator _IteratorType;
                //typedef T _T, _Ty, _Value, _ValueType, ValueType;
-               typedef _Iterator _ValueType, ValueType;
+               typedef _Iterator ValueType;
        protected:
                _Iterator m_end;
 
@@ -36,7 +36,7 @@ namespace roast
                }
 
                //      Value
-               _ValueType get_value_ref() const
+               ValueType get_value_ref() const
                {
                        return m_it;
                }
index aca257e..ba99eaa 100644 (file)
@@ -24,7 +24,7 @@ namespace roast{
                typedef _IndexType IndexType;
                
        protected:
-               _ContainerType *m_pcon;
+               _ContainerType m_con;
 
        public:
                //////////////////////////////////////////
@@ -34,19 +34,19 @@ namespace roast{
                        : _Base(IndexType(0),IndexType(0)),
                          m_pcon(NULL)
                {}
-               indexer_iterator_impl(ContainerType &array_in, const IndexType& length)
+               indexer_iterator_impl(ContainerType con_in, const IndexType& length)
                        : _Base(IndexType(0),length),
-                         m_pcon(&array_in)
+                         m_con(con_in)
                {}
-               indexer_iterator_impl(ContainerType &array_in, const IndexType& start, const IndexType& end)
+               indexer_iterator_impl(ContainerType con_in, const IndexType& start, const IndexType& end)
                        : _Base(start,end),
-                         m_pcon(&array_in)
+                         m_con(con_in)
                {}
 
                //////////////////////////////////////////
                
                //      Value
-               ValueType& get_value_ref() const { return m_pcon->operator[](m_index); }
+               ValueType& get_value_ref() const { return m_con[m_it]; }
                
                //////////////////////////////////////////
 
@@ -60,7 +60,7 @@ namespace roast{
                indexer_iterator_impl operator =(const indexer_iterator_impl& from)
                {
                        _Base::operator =(from);
-                       m_pcon = from.m_pcon;
+                       m_con = from.m_con;
                        return *this;
                }
        };
index f4f4d24..82bb7e8 100644 (file)
@@ -18,8 +18,8 @@ namespace roast
        class _linear_iterator_impl_base
        {
        public:
-               typedef T _IteratorType, IteratorType;
-               typedef T _ValueType, ValueType;
+               typedef T IteratorType;
+               typedef T ValueType;
        protected:
                T m_it;
 
index b82c494..5a79727 100644 (file)
@@ -1,5 +1,6 @@
 #include "stdafx.h"
 #include "roast/container/indexer_iterator.hpp"
+#include <stdio.h>
 
 using namespace roast;
 
@@ -10,6 +11,12 @@ void main()
        indexer_iterator<char*, char>::type a = indexer_iterator_impl<char*, char>(work, (size_t)32);
        do
        {
-               work
+               *a = 0;
+       }while(a.in_dowhile());
+
+       a = indexer_iterator_impl<char*, char>(work, (size_t)32);
+       do
+       {
+               printf("%d, ", *a);
        }while(a.in_dowhile());
 }