Skip to content

Commit 0f22fdf

Browse files
committed
Added buffer in the signature and merge Yago's
1 parent 82da03e commit 0f22fdf

File tree

8 files changed

+20
-12
lines changed

8 files changed

+20
-12
lines changed

src/Point2D.h renamed to include/Point2D.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#include <iostream>
66
#include<string>
77

8-
#ifndef SMARTSTACK_POINT2D_H
9-
#define SMARTSTACK_POINT2D_H
8+
#ifndef SMARTSTACK_POINT2D
9+
#define SMARTSTACK_POINT2D
1010

1111

1212
class Point2D {
@@ -45,4 +45,4 @@ class Point2D {
4545
};
4646

4747

48-
#endif //SMARTSTACK_POINT2D_H
48+
#endif //SMARTSTACK_POINT2D

include/buffer.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@
1818
<-
1919
==============================================================================*/
2020
template <class T, class D> class CompressedStack; // Required for the friendship
21+
template <class T, class D> class Signature; // Required for the friendship
22+
template <class T, class D> class Component; // Required for the friendship
2123
template <class T, class D>
2224
class Buffer{
2325
friend class CompressedStack<T,D>;
26+
friend class Signature<T,D>;
27+
friend class Component<T,D>;
2428

2529
private:
2630
// Constructor

include/component.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Component{
5252
==============================================================================*/
5353
template <class T, class D>
5454
Component<T,D>::Component(int space, int depth)
55-
:mSign(0, std::streampos (0), std::shared_ptr<T>(nullptr)){
55+
:mSign(0, std::streampos (0), std::shared_ptr<T>(nullptr), Buffer<T,D>(0)){
5656

5757
Levels<T,D> partial = initLevels<T,D>(space, depth);
5858
mPartial = partial;

include/compressedStack.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ template <class T, class D>
214214
void CompressedStack<T,D>::pushExplicit(std::shared_ptr<Data<T,D>> elt){
215215
int index = elt->mIndex;
216216
std::shared_ptr<Data<T,D>> eltPtr = elt;
217-
Signature<T,D> sign (index, mPosition, mContext);
217+
Signature<T,D> sign (index, mPosition, mContext, mBuffer);
218218

219219
// If the explicit datas of component 1 are empty we push
220220
if (mFirst.isExplicitEmpty()) {
@@ -252,7 +252,7 @@ void CompressedStack<T,D>::pushCompressed(std::shared_ptr<Data<T,D>> elt, int lv
252252
int distSubBlock = std::pow(mSpace,(mDepth - lvl));
253253
int distBlock = distSubBlock * mSpace;
254254
int index = elt->mIndex;
255-
Signature<T,D> sign (index, position, mContext);
255+
Signature<T,D> sign (index, position, mContext, mBuffer);
256256

257257
if (mFirst.isempty(lvl)) {
258258
mFirst.push(sign, lvl);

include/createTestInput.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <fstream>
77
#include <sstream>
88
#include <string>
9-
#include "Point2D.h"
9+
#include "Point2D.hpp"
1010
#include <vector>
1111
#include <algorithm>
1212

include/sign.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <string>
99
#include <iostream>
1010
#include <memory>
11+
#include "buffer.hpp"
1112

1213
/*==============================================================================
1314
Class : template (T context, D datas)
@@ -29,13 +30,14 @@ class Signature{
2930

3031
private:
3132
// Constructors
32-
Signature<T,D>(int index, std::streampos position, std::shared_ptr<T> context);
33+
Signature<T,D>(int index, std::streampos position, std::shared_ptr<T> context, Buffer<T,D> buffer);
3334
Signature<T,D>(std::vector<Signature<T,D>> block);
3435

3536
int mFirst;
3637
int mLast;
3738
std::streampos mPosition;
3839
std::shared_ptr<T> mContext;
40+
Buffer<T,D> mBuffer;
3941
};
4042

4143
/* Derived types: Block and Levels */
@@ -51,11 +53,12 @@ template<class T, class D> Levels<T,D> initLevels(int space, int depth);
5153
Constructors : Signature, initBlock, initLevels
5254
==============================================================================*/
5355
template <class T, class D>
54-
Signature<T,D>::Signature(int index, std::streampos position, std::shared_ptr<T> context){
56+
Signature<T,D>::Signature(int index, std::streampos position, std::shared_ptr<T> context, Buffer<T,D> buffer){
5557
mFirst = index;
5658
mLast = index;
5759
mPosition = position;
5860
mContext = context;
61+
mBuffer = buffer;
5962
}
6063

6164
template <class T, class D>
@@ -66,6 +69,7 @@ Signature<T,D>::Signature(Block<T,D> block){
6669
mLast = backSign.mLast;
6770
mPosition = frontSign.mPosition;
6871
mContext = frontSign.mContext;
72+
mBuffer = frontSign.mBuffer;
6973
}
7074

7175
template <class T, class D>

src/Point2D.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Created by yago on 16/07/05.
33
//
44

5-
#include "Point2D.h"
5+
#include "../include/Point2D.hpp"
66

77
Point2D::Point2D() {}
88

src/createTestInput.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ void createTestInput::createTestInputFiles(int code, string fileName,int n,int p
117117
outfile << min << "," << min << endl;
118118

119119
// add the sorted points
120-
for(int i=0;i<pointsToSort.size();i++)
120+
for(int j=0;j< (int) pointsToSort.size();j++)
121121
{
122-
outfile << pointsToSort[i].GetX() << "," << pointsToSort[i].GetY() << endl;
122+
outfile << pointsToSort[j].GetX() << "," << pointsToSort[j].GetY() << endl;
123123
}
124124

125125
// add finally (max,min)

0 commit comments

Comments
 (0)