Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

PrefixArrayList.hpp

Go to the documentation of this file.
00001 
00009 #ifndef PREFIXARRAYLIST_HPP_050403
00010 #define PREFIXARRAYLIST_HPP_050403
00011 
00012 
00013 //#include "common/allocators.cpp"
00014 #include <algorithm>
00015 
00016 typedef std::vector< std::vector<itemvecCounterPair> > diag_array_row_t;
00017 typedef std::vector<diag_array_row_t> diag_array_t;
00018 
00019 template<unsigned int THRESHOLD = 100>
00020 class PrefixArrayList : public diag_array_t{
00021    protected:
00022 
00023       bool less(const std::pair<itemvector, counter_t>& f, 
00024                 const itemvector& s) const
00025       {
00026          return f.first < s;
00027       }
00028    public:
00029 
00030       PrefixArrayList(const size_t largest_item) 
00031       {
00032          diag_array_t::reserve(largest_item );
00033          diag_array_t::resize(largest_item);
00034          for( item_t index = 0; index < largest_item; ++index) 
00035          {
00036             diag_array_t::operator[](index).reserve(largest_item - index);
00037             diag_array_t::operator[](index).resize(largest_item - index);
00038          }
00039       }
00040 /*      void insert( const itemvector& itemset, 
00041         const counter_t multiplicity );*/
00042 };
00043 
00044 /*template<unsigned int THRESHOLD = 100> void
00045 PrefixArrayList<THRESHOLD>::insert( 
00046    const itemvector& itemset, const counter_t multiplicity )
00047 {
00048       assert(itemset.size()>1);
00049       itemvector itemset_wp(itemset.begin()+2, itemset.end());
00050       set_list_t::iterator it;
00051       register size_t i1 = itemset[0], i2 = itemset[1]-itemset[0]-1;
00052       if(prefixarraylist[i1][i2].size() < THRESHOLD)
00053       {
00054          it = prefixarraylist[i1][i2].begin();
00055          while (it != prefixarraylist[i1][i2].end())
00056             if( (*it).first < itemset_wp)
00057                ++it;
00058             else break;
00059       }
00060       else
00061       it = std::lower_bound( 
00062          prefixarraylist[i1][i2].begin(),
00063          prefixarraylist[i1][i2].end(), itemset_wp, less );
00064       
00065       if( it != prefixarraylist[i1][i2].end() && 
00066           (*it).first == itemset_wp )
00067          (*it).second += multiplicity;
00068       else
00069       prefixarraylist[i1][i2].insert(
00070          it, std::pair<itemvector, counter_t>(itemset_wp, multiplicity));
00071 }*/
00072 
00073 
00074 #endif //PREFIXARRAYLIST_HPP_050403

Generated on Sun Sep 17 17:50:39 2006 for FIM environment by  doxygen 1.4.4