<commit_before>#ifndef VIENNAGRID_STORAGE_CONTAINER_HPP
#define VIENNAGRID_STORAGE_CONTAINER_HPP

#include <vector>
#include <deque>
#include <list>
#include <set>

#include "viennagrid/meta/utils.hpp"
#include "viennagrid/storage/forwards.hpp"
#include "viennagrid/storage/hook.hpp"


namespace viennagrid
{
    namespace storage
    {
        namespace container
        {            
            template<typename base_iterator, typename hook_tag>
            class hook_iterator_impl {};
            
            template<typename base_iterator>
            class hook_iterator_impl<base_iterator, pointer_hook_tag> : public base_iterator
            {
            public:
                
                typedef typename std::iterator_traits<base_iterator>::difference_type difference_type;
                typedef typename std::iterator_traits<base_iterator>::value_type * value_type;
                typedef value_type * pointer;
                typedef value_type & reference;
                typedef typename std::iterator_traits<base_iterator>::iterator_category iterator_category;
                
                
                hook_iterator_impl(base_iterator it) : base_iterator(it) {}
                
                
                value_type operator* () { return & base_iterator::operator*(); }
                const value_type operator* () const { return & base_iterator::operator*(); }
            };
            
            template<typename base_iterator>
            class hook_iterator_impl<base_iterator, iterator_hook_tag> : public base_iterator
            {
            public:
                
                typedef typename std::iterator_traits<base_iterator>::difference_type difference_type;
                typedef base_iterator value_type;
                typedef value_type * pointer;
                typedef value_type & reference;
                typedef typename std::iterator_traits<base_iterator>::iterator_category iterator_category;
                
                
                hook_iterator_impl(base_iterator it) : base_iterator(it) {}
                
                
                value_type operator* () { return static_cast<base_iterator>(*this); }
                const value_type operator* () const { return static_cast<base_iterator>(*this); }
            };
            
            template<typename base_iterator, typename id_type>
            class hook_iterator_impl<base_iterator, id_hook_tag<id_type> > : public base_iterator
            {
            public:
                
                typedef typename std::iterator_traits<base_iterator>::difference_type difference_type;
                typedef id_type value_type;
                typedef id_type * pointer;
                typedef id_type & reference;
                typedef typename std::iterator_traits<base_iterator>::iterator_category iterator_category;
                
                
                hook_iterator_impl(base_iterator it) : base_iterator(it) {}
                
                
                value_type operator* () { return (*this)->id(); }
                const value_type operator* () const { return (*this)->id(); }
            };
            
            
            
            template<typename base_iterator, typename hook_tag>
            class const_hook_iterator_impl {};
            
            template<typename base_iterator>
            class const_hook_iterator_impl<base_iterator, pointer_hook_tag> : public base_iterator
            {
            public:
                
                typedef typename std::iterator_traits<base_iterator>::difference_type difference_type;
                typedef const typename std::iterator_traits<base_iterator>::value_type * value_type;
                typedef value_type * pointer;
                typedef value_type & reference;
                typedef typename std::iterator_traits<base_iterator>::iterator_category iterator_category;
                
                
                const_hook_iterator_impl(base_iterator it) : base_iterator(it) {}
                
                
                value_type operator* () { return & base_iterator::operator*(); }
                const value_type operator* () const { return & base_iterator::operator*(); }
            };
            
            template<typename base_iterator>
            class const_hook_iterator_impl<base_iterator, iterator_hook_tag> : public base_iterator
            {
            public:
                
                typedef typename std::iterator_traits<base_iterator>::difference_type difference_type;
                typedef base_iterator value_type;
                typedef value_type * pointer;
                typedef value_type & reference;
                typedef typename std::iterator_traits<base_iterator>::iterator_category iterator_category;
                
                
                const_hook_iterator_impl(base_iterator it) : base_iterator(it) {}
                
                
                value_type operator* () { return static_cast<base_iterator>(*this); }
                const value_type operator* () const { return static_cast<base_iterator>(*this); }
            };
            
            template<typename base_iterator, typename id_type>
            class const_hook_iterator_impl<base_iterator, id_hook_tag<id_type> > : public base_iterator
            {
            public:
                
                typedef typename std::iterator_traits<base_iterator>::difference_type difference_type;
                typedef id_type value_type;
                typedef id_type * pointer;
                typedef id_type & reference;
                typedef typename std::iterator_traits<base_iterator>::iterator_category iterator_category;
                
                
                const_hook_iterator_impl(base_iterator it) : base_iterator(it) {}
                
                
                value_type operator* () { return (*this)->id(); }
                const value_type operator* () const { return (*this)->id(); }
            };
        
        }
        
        
        
        template<typename base_container__, typename hook_tag>
        class hooked_container_t : public base_container__
        {
        public:
            typedef base_container__ container_type;
            typedef typename container_type::value_type value_type;
            
            typedef typename container_type::pointer pointer;
            typedef typename container_type::const_pointer const_pointer;            
            
            typedef typename container_type::reference reference;
            typedef typename container_type::const_reference const_reference;
            
            typedef typename container_type::iterator iterator;
            typedef typename container_type::const_iterator const_iterator;
            
            typedef typename viennagrid::storage::hook::hook_type<container_type, hook_tag>::type hook_type;
            typedef typename viennagrid::storage::hook::const_hook_type<container_type, hook_tag>::type const_hook_type;
            
            value_type & dereference_hook( hook_type hook )
            {
                return *hook;
            }
            
//             const value_type & dereference_hook( const_hook_type hook )
//             {
//                 return *hook;
//             }
        };
        
        template<typename base_container__, typename id_type>
        class hooked_container_t<base_container__, id_hook_tag<id_type> > : public base_container__
        {
        public:
            typedef base_container__ container_type;
            typedef typename container_type::value_type value_type;
            
            typedef typename container_type::pointer pointer;
            typedef typename container_type::const_pointer const_pointer;            
            
            typedef typename container_type::reference reference;
            typedef typename container_type::const_reference const_reference;
            
            typedef typename container_type::iterator iterator;
            typedef typename container_type::const_iterator const_iterator;
            
            typedef typename viennagrid::storage::hook::hook_type<container_type, id_hook_tag<id_type> >::type hook_type;
            typedef typename viennagrid::storage::hook::const_hook_type<container_type, id_hook_tag<id_type> >::type const_hook_type;
            
            value_type & dereference_hook( hook_type hook )
            {
                iterator it = container_type::begin();
                std::advance(it, hook);
                return *it;
                //return *hook;
            }
            
//             const value_type & dereference_hook( const_hook_type hook )
//             {
//                 return *hook;
//             }
        };
        
        
        <commit_msg>adapted to id_hook_tag without id_type<commit_after>#ifndef VIENNAGRID_STORAGE_CONTAINER_HPP
#define VIENNAGRID_STORAGE_CONTAINER_HPP

#include <vector>
#include <deque>
#include <list>
#include <set>

#include "viennagrid/meta/utils.hpp"
#include "viennagrid/storage/forwards.hpp"
#include "viennagrid/storage/hook.hpp"


namespace viennagrid
{
    namespace storage
    {
        namespace container
        {            
            template<typename base_iterator, typename hook_tag>
            class hook_iterator_impl {};
            
            template<typename base_iterator>
            class hook_iterator_impl<base_iterator, pointer_hook_tag> : public base_iterator
            {
            public:
                
                typedef typename std::iterator_traits<base_iterator>::difference_type difference_type;
                typedef typename std::iterator_traits<base_iterator>::value_type * value_type;
                typedef value_type * pointer;
                typedef value_type & reference;
                typedef typename std::iterator_traits<base_iterator>::iterator_category iterator_category;
                
                
                hook_iterator_impl(base_iterator it) : base_iterator(it) {}
                
                
                value_type operator* () { return & base_iterator::operator*(); }
                const value_type operator* () const { return & base_iterator::operator*(); }
            };
            
            template<typename base_iterator>
            class hook_iterator_impl<base_iterator, iterator_hook_tag> : public base_iterator
            {
            public:
                
                typedef typename std::iterator_traits<base_iterator>::difference_type difference_type;
                typedef base_iterator value_type;
                typedef value_type * pointer;
                typedef value_type & reference;
                typedef typename std::iterator_traits<base_iterator>::iterator_category iterator_category;
                
                
                hook_iterator_impl(base_iterator it) : base_iterator(it) {}
                
                
                value_type operator* () { return static_cast<base_iterator>(*this); }
                const value_type operator* () const { return static_cast<base_iterator>(*this); }
            };
            
            template<typename base_iterator>
            class hook_iterator_impl<base_iterator, id_hook_tag> : public base_iterator
            {
            public:
                
                //typedef smart_id< typename std::iterator_traits<base_iterator>::value_type, base_id_type > id_type;
                //typedef typename viennagrid::storage::result_of::id<typename std::iterator_traits<base_iterator>::value_type, id_tag>::type id_type;
                typedef typename std::iterator_traits<base_iterator>::value_type::id_type id_type;
                
                typedef typename std::iterator_traits<base_iterator>::difference_type difference_type;
                typedef id_type value_type;
                typedef id_type * pointer;
                typedef id_type & reference;
                typedef typename std::iterator_traits<base_iterator>::iterator_category iterator_category;
                
                
                hook_iterator_impl(base_iterator it) : base_iterator(it) {}
                
                
                value_type operator* () { return (*this)->id(); }
                const value_type operator* () const { return (*this)->id(); }
            };
            
            
            
            template<typename base_iterator, typename hook_tag>
            class const_hook_iterator_impl {};
            
            template<typename base_iterator>
            class const_hook_iterator_impl<base_iterator, pointer_hook_tag> : public base_iterator
            {
            public:
                
                typedef typename std::iterator_traits<base_iterator>::difference_type difference_type;
                typedef const typename std::iterator_traits<base_iterator>::value_type * value_type;
                typedef value_type * pointer;
                typedef value_type & reference;
                typedef typename std::iterator_traits<base_iterator>::iterator_category iterator_category;
                
                
                const_hook_iterator_impl(base_iterator it) : base_iterator(it) {}
                
                
                value_type operator* () { return & base_iterator::operator*(); }
                const value_type operator* () const { return & base_iterator::operator*(); }
            };
            
            template<typename base_iterator>
            class const_hook_iterator_impl<base_iterator, iterator_hook_tag> : public base_iterator
            {
            public:
                
                typedef typename std::iterator_traits<base_iterator>::difference_type difference_type;
                typedef base_iterator value_type;
                typedef value_type * pointer;
                typedef value_type & reference;
                typedef typename std::iterator_traits<base_iterator>::iterator_category iterator_category;
                
                
                const_hook_iterator_impl(base_iterator it) : base_iterator(it) {}
                
                
                value_type operator* () { return static_cast<base_iterator>(*this); }
                const value_type operator* () const { return static_cast<base_iterator>(*this); }
            };
            
            template<typename base_iterator>
            class const_hook_iterator_impl<base_iterator, id_hook_tag> : public base_iterator
            {
            public:
                
                //typedef smart_id< typename std::iterator_traits<base_iterator>::value_type, base_id_type > id_type;
                //typedef typename viennagrid::storage::result_of::id<typename std::iterator_traits<base_iterator>::value_type, id_tag>::type id_type;
                typedef typename std::iterator_traits<base_iterator>::value_type::id_type id_type;
                
                typedef typename std::iterator_traits<base_iterator>::difference_type difference_type;
                typedef id_type value_type;
                typedef id_type * pointer;
                typedef id_type & reference;
                typedef typename std::iterator_traits<base_iterator>::iterator_category iterator_category;
                
                
                const_hook_iterator_impl(base_iterator it) : base_iterator(it) {}
                
                
                value_type operator* () { return (*this)->id(); }
                const value_type operator* () const { return (*this)->id(); }
            };
        
        }
        
        
        
        template<typename base_container__, typename hook_tag>
        class hooked_container_t : public base_container__
        {
        public:
            typedef base_container__ container_type;
            typedef typename container_type::value_type value_type;
            
            typedef typename container_type::pointer pointer;
            typedef typename container_type::const_pointer const_pointer;            
            
            typedef typename container_type::reference reference;
            typedef typename container_type::const_reference const_reference;
            
            typedef typename container_type::iterator iterator;
            typedef typename container_type::const_iterator const_iterator;
            
            typedef typename viennagrid::storage::hook::hook_type<container_type, hook_tag>::type hook_type;
            typedef typename viennagrid::storage::hook::const_hook_type<container_type, hook_tag>::type const_hook_type;
            
            value_type & dereference_hook( hook_type hook )
            {
                return *hook;
            }
            
//             const value_type & dereference_hook( const_hook_type hook )
//             {
//                 return *hook;
//             }
        };
        
        template<typename base_container__>
        class hooked_container_t<base_container__, id_hook_tag> : public base_container__
        {
        public:
            typedef base_container__ container_type;
            typedef typename container_type::value_type value_type;
            
            typedef typename container_type::pointer pointer;
            typedef typename container_type::const_pointer const_pointer;            
            
            typedef typename container_type::reference reference;
            typedef typename container_type::const_reference const_reference;
            
            typedef typename container_type::iterator iterator;
            typedef typename container_type::const_iterator const_iterator;
            
            typedef typename viennagrid::storage::hook::hook_type<container_type, id_hook_tag>::type hook_type;
            typedef typename viennagrid::storage::hook::const_hook_type<container_type, id_hook_tag>::type const_hook_type;
            
            value_type & dereference_hook( hook_type hook )
            {
                iterator it = container_type::begin();
                std::advance(it, hook.get());
                return *it;
                //return *hook;
            }
            
//             const value_type & dereference_hook( const_hook_type hook )
//             {
//                 return *hook;
//             }
        };
        
        
        
{'fraction_non_alphanumeric': 0.06936291668910549, 'fraction_numerical': 0.0, 'mean_word_length': 1.7937415375357304, 'pattern_counts': {'":': 0, '<': 104, '<?xml version=': 0, '>': 112, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '501029', 'n_tokens_mistral': 4481, 'n_tokens_neox': 4195, 'n_words': 842}