File tree Expand file tree Collapse file tree 4 files changed +13
-12
lines changed
Expand file tree Collapse file tree 4 files changed +13
-12
lines changed Original file line number Diff line number Diff line change 2222#include " stamp_dict.h"
2323
2424int
25- StampDict::ChooseStampSize (DictBase & dict)
25+ StampDict::ChooseStampSize (std::shared_ptr< DictBase> dict)
2626{
27- if (dict. size ()<= UCHAR_MAX+1 )
27+ if (dict-> size () <= UCHAR_MAX+1 )
2828 {
2929 stamp_max_value = UCHAR_MAX;
3030 return 1 ;
3131 }
32- if (dict. size ()<= USHRT_MAX+1 )
32+ if (dict-> size () <= USHRT_MAX+1 )
3333 {
3434 stamp_max_value = USHRT_MAX;
3535 return 2 ;
3636 }
37- if (dict. size ()<= UINT_MAX+1 )
37+ if (dict-> size () <= UINT_MAX+1 )
3838 {
3939 stamp_max_value = UINT_MAX;
4040 return 4 ;
@@ -75,7 +75,7 @@ StampDict::ExtractStr(Blob &blob)
7575 printf (" StampDict::ExtractStr: Something is really wrong\n " ); // FIXME better to throw something here :-)
7676 exit (1 );
7777 }
78- long long actual_index = ((double ) index_oracle) / stamp_max_value * dict. size ();
79- if ( actual_index == dict. size ()) actual_index--; /* If we hit the boundary step inside a bit*/
80- return dict. get (actual_index);
78+ long long actual_index = ((double ) index_oracle) / stamp_max_value * dict-> size ();
79+ if ( actual_index == dict-> size ()) actual_index--; /* If we hit the boundary step inside a bit*/
80+ return dict-> get (actual_index);
8181}
Original file line number Diff line number Diff line change 2525#include " stamp.h"
2626#include " stamp_arithm.h"
2727#include " dict.h"
28+ #include < memory>
2829
2930class StampDict : public StampBaseStr
3031{
@@ -34,13 +35,13 @@ class StampDict: public StampBaseStr
3435 StampArithm<unsigned int > stamp32;
3536 StampArithm<unsigned long long > stamp64;
3637 int stamp_size;
37- DictBase& dict;
38+ std::shared_ptr< DictBase> dict;
3839 unsigned long long stamp_max_value;
3940
40- int ChooseStampSize (DictBase & dict);
41+ int ChooseStampSize (std::shared_ptr< DictBase> dict);
4142
4243 public:
43- StampDict (DictBase & dict_arg) : dict{ dict_arg} , stamp_size{ ChooseStampSize (dict_arg)} {};
44+ StampDict (std::shared_ptr< DictBase> dict_arg) : dict( dict_arg) , stamp_size( ChooseStampSize(dict_arg)) {};
4445 std::string ExtractStr (Blob &blob) override ;
4546 int minSize () override {return stamp_size;}
4647 int maxSize () override {return stamp_size;}
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ char data[] =
5454
5555 StampArithm<unsigned char > stampс;
5656
57- DictLCAlphaSmall dict;
57+ auto dict = std::make_shared<DictLCAlphaSmall>() ;
5858 StampDict stamp_dict (dict);
5959
6060 StampLottery4Recursion<StampBaseStr> stamp_lot ({stampс, stamp_dict});
Original file line number Diff line number Diff line change 4848{
4949 TEST_START (4 );
5050 { /* 1..4 */
51- DictTest dict;
51+ auto dict = std::make_shared<DictTest>() ;
5252 StampDict stamp (dict);
5353 Blob blob ((char *) sample, 4 );
5454 std::string s;
You can’t perform that action at this time.
0 commit comments