OSDN Git Service

33_あーだめだこれ。無限再帰やん・・・
authorMyun2 <myun2@nwhite.info>
Tue, 1 Jun 2010 02:22:45 +0000 (11:22 +0900)
committerMyun2 <myun2@nwhite.info>
Tue, 1 Jun 2010 02:22:45 +0000 (11:22 +0900)
include/roast/container/33_\82 \81[\82¾\82ß\82¾\82±\82ê\81B\96³\8cÀ\8dÄ\8bA\82â\82ñ\81E\81E\81E/linear_iterator_base.hpp [new file with mode: 0644]
include/roast/container/33_\82 \81[\82¾\82ß\82¾\82±\82ê\81B\96³\8cÀ\8dÄ\8bA\82â\82ñ\81E\81E\81E/ptr_iterator_base.hpp [new file with mode: 0644]
include/roast/container/33_\82 \81[\82¾\82ß\82¾\82±\82ê\81B\96³\8cÀ\8dÄ\8bA\82â\82ñ\81E\81E\81E/tokenize.hpp [new file with mode: 0644]

diff --git a/include/roast/container/33_\82 \81[\82¾\82ß\82¾\82±\82ê\81B\96³\8cÀ\8dÄ\8bA\82â\82ñ\81E\81E\81E/linear_iterator_base.hpp b/include/roast/container/33_\82 \81[\82¾\82ß\82¾\82±\82ê\81B\96³\8cÀ\8dÄ\8bA\82â\82ñ\81E\81E\81E/linear_iterator_base.hpp
new file mode 100644 (file)
index 0000000..84cc345
--- /dev/null
@@ -0,0 +1,113 @@
+//     Roast+ License
+
+/*
+       
+*/
+#ifndef __SFJP_ROAST__container__linear_iterator_base_HPP__
+#define __SFJP_ROAST__container__linear_iterator_base_HPP__
+
+#include "roast/container/iterator_base.hpp"
+
+namespace roast
+{
+       /////////////////////////////////////////////////////////
+       
+       //      !! Not Implemented is_valid() Method. !!
+
+       template <typename T, typename _Self >
+       class _linear_iterator_impl_base
+       {
+       public:
+               typedef T _IteratorType, IteratorType;
+               typedef T _ValueType, ValueType;
+       protected:
+               T m_it;
+
+       public:
+               _linear_iterator_impl_base(){}
+               _linear_iterator_impl_base(const T& _beg)
+                       : m_it(_beg)
+                       {}
+               ///////////////////////////////////////////////////////////////////////
+               
+               void setup(const T& _beg)
+               {
+                       m_it = _beg;
+               }
+               
+               ///////////////////////////////////////////////////////////////////////
+               
+               int compare(const _linear_iterator_impl_base& target) const 
+               {
+                       return m_it - target.m_it;
+               }
+               
+               //      Next (Like iterator ++)
+               void next() {
+                       m_it++;
+               }
+
+               //      Value
+               T& get_value_ref() const
+               {
+                       return m_it;
+               }
+               
+               ///////////////////////////////////////////////////////////////////////
+               
+               //      Arithmetic operators
+               
+               _Self operator -(const _Self& target) const
+               {
+                       return _Self(m_it - target.m_it);
+               }
+               _Self operator -(const T& target) const
+               {
+                       return _Self(m_it - target);
+               }
+               _Self operator -(int n) const
+               {
+                       return _Self(m_it - n);
+               }
+               _Self operator --() {
+                       _Self old = *this;
+                       m_it--;
+                       return old;
+               }
+               _Self operator --(int) {
+                       m_it--;
+                       return *this;
+               }
+               
+               _Self operator +(const _Self& target) const
+               {
+                       return _Self(m_it + target.m_it);
+               }
+               _Self operator +(const T& target) const
+               {
+                       return _Self(m_it + target);
+               }
+               _Self operator +(int n) const
+               {
+                       return _Self(m_it + n);
+               }
+       };
+       
+       /////////////////////////////////////////////////////////
+
+       template <typename T, typename _Self>
+       class linear_iterator_base :
+               public _iterator< _linear_iterator_impl_base<T,_Self> >
+       {
+       private:
+               typedef _linear_iterator_impl_base<T,_Self> _Impl;
+               typedef _iterator<_Impl> _Base;
+       public:
+               linear_iterator_base(){}
+               linear_iterator_base(const _Impl& impl) : _Base(impl){}
+               linear_iterator_base(T& _beg)
+                       : _Base(_Impl(_beg)) {}
+       };
+}
+
+#endif//__SFJP_ROAST__container__linear_iterator_base_HPP__
diff --git a/include/roast/container/33_\82 \81[\82¾\82ß\82¾\82±\82ê\81B\96³\8cÀ\8dÄ\8bA\82â\82ñ\81E\81E\81E/ptr_iterator_base.hpp b/include/roast/container/33_\82 \81[\82¾\82ß\82¾\82±\82ê\81B\96³\8cÀ\8dÄ\8bA\82â\82ñ\81E\81E\81E/ptr_iterator_base.hpp
new file mode 100644 (file)
index 0000000..c6a0fc0
--- /dev/null
@@ -0,0 +1,55 @@
+//     Roast+ License
+
+/*
+       
+*/
+#ifndef __SFJP_ROAST__container__ptr_iterator_base_HPP__
+#define __SFJP_ROAST__container__ptr_iterator_base_HPP__
+
+#include "roast/container/linear_iterator_base.hpp"
+
+namespace roast
+{
+       /////////////////////////////////////////////////////////
+       
+       //      !! Not Implemented is_valid() Method. !!
+
+       template <typename T, typename _Self>
+       class _ptr_iterator_impl_base : public _linear_iterator_impl_base<T*,_Self>
+       {
+       public:
+               typedef T _ValueType, ValueType;
+       private:
+               typedef _linear_iterator_impl_base<T*,_Self> _Base;
+       public:
+               _ptr_iterator_impl_base(){}
+               _ptr_iterator_impl_base(T* _beg)
+                       : _Base(_beg)
+                       {}
+               ///////////////////////////////////////////////////////////////////////
+               
+               //      Value
+               T& get_value_ref() const
+               {
+                       return *m_it;
+               }
+       };
+       
+       /////////////////////////////////////////////////////////
+
+       template <typename T, typename _Self>
+       class ptr_iterator_base :
+               public _iterator< _ptr_iterator_impl_base<T,_Self> >
+       {
+       private:
+               typedef _ptr_iterator_impl_base<T,_Self> _Impl;
+               typedef _iterator<_Impl> _Base;
+       public:
+               ptr_iterator_base(){}
+               ptr_iterator_base(const _Impl& impl) : _Base(impl){}
+               ptr_iterator_base(T* _beg)
+                       : _Base(_Impl(_beg)) {}
+       };
+}
+
+#endif//__SFJP_ROAST__container__ptr_iterator_base_HPP__
diff --git a/include/roast/container/33_\82 \81[\82¾\82ß\82¾\82±\82ê\81B\96³\8cÀ\8dÄ\8bA\82â\82ñ\81E\81E\81E/tokenize.hpp b/include/roast/container/33_\82 \81[\82¾\82ß\82¾\82±\82ê\81B\96³\8cÀ\8dÄ\8bA\82â\82ñ\81E\81E\81E/tokenize.hpp
new file mode 100644 (file)
index 0000000..70c8d52
--- /dev/null
@@ -0,0 +1,73 @@
+//     Roast+ License
+
+/*
+       
+*/
+#ifndef __SFJP_ROAST__container__tokenize_HPP__
+#define __SFJP_ROAST__container__tokenize_HPP__
+
+#include <map>
+
+namespace roast
+{
+       //template <typename _Container>
+       template <typename _Iterator, typename _Separaters>
+       class _tokenize_iterator_impl
+       {
+       protected:
+               _Iterator m_token_head;
+               _Iterator m_it;
+               _Separaters m_seps;
+               
+               int compare(const _tokenize_iterator_impl& target) const 
+               {
+                       return m_it - target.m_it;
+               }
+               
+       public:
+               typedef ::std::pair<_Iterator,_Iterator> _IteratorPair, IteratorPair, _ValueType, ValueType;
+               
+               /////////////////////////////////////////////////
+               
+               _tokenize_iterator_impl(){}
+               _tokenize_iterator_impl(const _Iterator& it_start, const _Separaters& _seps)
+                       : m_it(it_start), m_seps(_seps)
+               {
+                       next();
+               }
+               
+               /////////////////////////////////////////////////
+               
+               //      Next (Like iterator ++)
+               __forceinline void next()
+               {
+                       //      Head Iterator Backup
+                       m_token_head = m_it;
+                       
+                       //      Find Separater
+                       while( m_it.is_valid() )
+                       {
+                               m_it++;
+                               if ( m_seps.find(*m_it).is_valid() ){
+                                       m_it++;
+                                       break;
+                               }
+                       }
+               }
+               
+               //      Iterator pointer iValid?
+               bool is_valid() const {
+                       //return ( m_it != m_end );
+                       //return ( m_token_head != m_end );
+                       return m_token_head.is_valid();
+               }
+               
+               //      Value (::std::pair<HeadIterator, TailIterator>)
+               ValueType get_value_ref() const {
+                       return ::std::make_pair(m_token_head, m_it); }
+               
+               //////////////////////////////////////////
+       };
+}
+
+#endif//__SFJP_ROAST__container__tokenize_HPP__