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 22
22
#include " stamp_dict.h"
23
23
24
24
int
25
- StampDict::ChooseStampSize (DictBase & dict)
25
+ StampDict::ChooseStampSize (std::shared_ptr< DictBase> dict)
26
26
{
27
- if (dict. size ()<= UCHAR_MAX+1 )
27
+ if (dict-> size () <= UCHAR_MAX+1 )
28
28
{
29
29
stamp_max_value = UCHAR_MAX;
30
30
return 1 ;
31
31
}
32
- if (dict. size ()<= USHRT_MAX+1 )
32
+ if (dict-> size () <= USHRT_MAX+1 )
33
33
{
34
34
stamp_max_value = USHRT_MAX;
35
35
return 2 ;
36
36
}
37
- if (dict. size ()<= UINT_MAX+1 )
37
+ if (dict-> size () <= UINT_MAX+1 )
38
38
{
39
39
stamp_max_value = UINT_MAX;
40
40
return 4 ;
@@ -75,7 +75,7 @@ StampDict::ExtractStr(Blob &blob)
75
75
printf (" StampDict::ExtractStr: Something is really wrong\n " ); // FIXME better to throw something here :-)
76
76
exit (1 );
77
77
}
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);
81
81
}
Original file line number Diff line number Diff line change 25
25
#include " stamp.h"
26
26
#include " stamp_arithm.h"
27
27
#include " dict.h"
28
+ #include < memory>
28
29
29
30
class StampDict : public StampBaseStr
30
31
{
@@ -34,13 +35,13 @@ class StampDict: public StampBaseStr
34
35
StampArithm<unsigned int > stamp32;
35
36
StampArithm<unsigned long long > stamp64;
36
37
int stamp_size;
37
- DictBase& dict;
38
+ std::shared_ptr< DictBase> dict;
38
39
unsigned long long stamp_max_value;
39
40
40
- int ChooseStampSize (DictBase & dict);
41
+ int ChooseStampSize (std::shared_ptr< DictBase> dict);
41
42
42
43
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)) {};
44
45
std::string ExtractStr (Blob &blob) override ;
45
46
int minSize () override {return stamp_size;}
46
47
int maxSize () override {return stamp_size;}
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ char data[] =
54
54
55
55
StampArithm<unsigned char > stampс;
56
56
57
- DictLCAlphaSmall dict;
57
+ auto dict = std::make_shared<DictLCAlphaSmall>() ;
58
58
StampDict stamp_dict (dict);
59
59
60
60
StampLottery4Recursion<StampBaseStr> stamp_lot ({stampс, stamp_dict});
Original file line number Diff line number Diff line change 48
48
{
49
49
TEST_START (4 );
50
50
{ /* 1..4 */
51
- DictTest dict;
51
+ auto dict = std::make_shared<DictTest>() ;
52
52
StampDict stamp (dict);
53
53
Blob blob ((char *) sample, 4 );
54
54
std::string s;
You can’t perform that action at this time.
0 commit comments