Skip to content

Commit

Permalink
Bump dtl version to fix compile issues.
Browse files Browse the repository at this point in the history
Closes #44.
  • Loading branch information
kuzi117 committed Sep 8, 2024
1 parent 6c7324d commit 3ae96d5
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
30 changes: 22 additions & 8 deletions include/dtl/Diff.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ namespace dtl {
bool editDistanceOnly;
uniHunkVec uniHunks;
comparator cmp;
long long ox;
long long oy;
public :
Diff () {}

Expand Down Expand Up @@ -162,7 +164,7 @@ namespace dtl {
return trivial;
}

void enableTrivial () const {
void enableTrivial () {
this->trivial = true;
}

Expand Down Expand Up @@ -260,7 +262,8 @@ namespace dtl {
if (isHuge()) {
pathCordinates.reserve(MAX_CORDINATES_SIZE);
}

ox = 0;
oy = 0;
long long p = -1;
fp = new long long[M + N + 3];
fill(&fp[0], &fp[M + N + 3], -1);
Expand Down Expand Up @@ -340,6 +343,15 @@ namespace dtl {
sesElemVec ses_v = ses.getSequence ();
for_each (ses_v.begin (), ses_v.end(), PT < sesElem, stream > (out));
}

/**
* store difference between A and B as an SES with custom storage
*/
template < typename storedData, template < typename SEET, typename STRT > class ST >
void storeSES(storedData& sd) const {
sesElemVec ses_v = ses.getSequence();
for_each(ses_v.begin(), ses_v.end(), ST < sesElem, storedData >(sd));
}

/**
* print difference between A and B in the Unified Format
Expand Down Expand Up @@ -586,29 +598,29 @@ namespace dtl {
while(px_idx < v[i].x || py_idx < v[i].y) {
if (v[i].y - v[i].x > py_idx - px_idx) {
if (!wasSwapped()) {
ses.addSequence(*y, 0, y_idx, SES_ADD);
ses.addSequence(*y, 0, y_idx + oy, SES_ADD);
} else {
ses.addSequence(*y, y_idx, 0, SES_DELETE);
ses.addSequence(*y, y_idx + oy, 0, SES_DELETE);
}
++y;
++y_idx;
++py_idx;
} else if (v[i].y - v[i].x < py_idx - px_idx) {
if (!wasSwapped()) {
ses.addSequence(*x, x_idx, 0, SES_DELETE);
ses.addSequence(*x, x_idx + ox, 0, SES_DELETE);
} else {
ses.addSequence(*x, 0, x_idx, SES_ADD);
ses.addSequence(*x, 0, x_idx + ox, SES_ADD);
}
++x;
++x_idx;
++px_idx;
} else {
if (!wasSwapped()) {
lcs.addSequence(*x);
ses.addSequence(*x, x_idx, y_idx, SES_COMMON);
ses.addSequence(*x, x_idx + ox, y_idx + oy, SES_COMMON);
} else {
lcs.addSequence(*y);
ses.addSequence(*y, y_idx, x_idx, SES_COMMON);
ses.addSequence(*y, y_idx + oy, x_idx + ox, SES_COMMON);
}
++x;
++y;
Expand Down Expand Up @@ -649,6 +661,8 @@ namespace dtl {
fp = new long long[M + N + 3];
fill(&fp[0], &fp[M + N + 3], -1);
fill(path.begin(), path.end(), -1);
ox = x_idx - 1;
oy = y_idx - 1;
return false;
}
return true;
Expand Down
14 changes: 14 additions & 0 deletions include/dtl/functors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,20 @@ namespace dtl {
private :
stream& out_;
};

/**
* storage class template
*/
template <typename sesElem, typename storedData >
class Storage
{
public:
Storage(storedData& sd) : storedData_(sd) {}
virtual ~Storage() {}
virtual void operator() (const sesElem& se) const = 0;
protected:
storedData& storedData_;
};

/**
* compare class template
Expand Down
2 changes: 1 addition & 1 deletion include/dtl/variables.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace dtl {
/**
* version string
*/
const string version = "1.19";
const string version = "1.21";

/**
* type of edit for SES
Expand Down

0 comments on commit 3ae96d5

Please sign in to comment.