Skip to content

Commit 026fe04

Browse files
committed
Interface formatting (all hpp files)
1 parent 7a345fe commit 026fe04

File tree

9 files changed

+261
-328
lines changed

9 files changed

+261
-328
lines changed

include/buffer.hpp

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
#ifndef BUFFER
22
#define BUFFER
33

4-
/** Buffer class : declaration **/
4+
/*==============================================================================
5+
Includes
6+
==============================================================================*/
57
#include "data.hpp"
68
#include <vector>
79
#include <string>
810
#include <iostream>
911
#include <memory>
1012

13+
/*==============================================================================
14+
Class : template (D datas)
15+
Extensions :
16+
Aliases :
17+
Friends ->
18+
<-
19+
==============================================================================*/
1120
template <class D>
12-
class Buffer
13-
{
21+
class Buffer{
1422
public:
1523
// Constructor
1624
Buffer<D>(int size = 0);
@@ -40,12 +48,11 @@ class Buffer
4048
ExplicitPointer<D> mExplicit;
4149
};
4250

43-
44-
45-
/** Constructors **/
51+
/*==============================================================================
52+
Constructors
53+
==============================================================================*/
4654
template <class D>
47-
Buffer<D>::Buffer(int size)
48-
{
55+
Buffer<D>::Buffer(int size){
4956
mSize = size;
5057
mStart = 0;
5158

@@ -54,81 +61,77 @@ Buffer<D>::Buffer(int size)
5461
mExplicit = xplicit;
5562
}
5663

57-
/** Getters **/
64+
/*==============================================================================
65+
Getters
66+
==============================================================================*/
5867
template <class D>
59-
int Buffer<D>::getSize()
60-
{
68+
int Buffer<D>::getSize(){
6169
return mSize;
6270
}
6371
template <class D>
64-
int Buffer<D>::getStart()
65-
{
72+
int Buffer<D>::getStart(){
6673
return mStart;
6774
}
68-
6975
template <class D>
70-
Data<D> Buffer<D>::top(int k)
71-
{
76+
Data<D> Buffer<D>::top(int k){
7277
if (k < getSize()) {
7378
int index = (k + mStart - 1) % mSize; // -1 match the start of vectors at 0
7479
return *(mExplicit[index]);
7580
}
7681
throw "Access to a top element bigger than the size of the buffer";
7782
}
7883

79-
/** Setters **/
84+
/*==============================================================================
85+
Setters
86+
==============================================================================*/
8087
template <class D>
81-
void Buffer<D>::setStart(int start)
82-
{
88+
void Buffer<D>::setStart(int start){
8389
mStart = start;
8490
}
8591
template <class D>
86-
void Buffer<D>::setStart()
87-
{
92+
void Buffer<D>::setStart(){
8893
mStart = (mStart + 1) % mSize;
8994
}
9095
template <class D>
91-
void Buffer<D>::setData(std::shared_ptr<Data<D>> elt, int id)
92-
{
96+
void Buffer<D>::setData(std::shared_ptr<Data<D>> elt, int id){
9397
int index = (id + mStart - 1) % mSize; // -1 match the start of vectors at 0
9498
mExplicit[index] = elt;
9599
}
96100

97-
/** Push and Pop**/
101+
/*==============================================================================
102+
Stack Functions: push, pop
103+
==============================================================================*/
98104
template <class D>
99-
void Buffer<D>::push(std::shared_ptr<Data<D>> elt)
100-
{
105+
void Buffer<D>::push(std::shared_ptr<Data<D>> elt){
101106
if (mSize > 0) {
102107
setData(elt, mStart+1);
103108
}
104109
}
105110

106111
template <class D>
107-
void Buffer<D>::pop()
108-
{
112+
void Buffer<D>::pop(){
109113
setStart();
110114
}
111115

112-
/** IO **/
116+
/*==============================================================================
117+
IO : toString
118+
==============================================================================*/
113119
template <class D>
114-
std::string Buffer<D>::toString()
115-
{
120+
std::string Buffer<D>::toString(){
116121
std::string str;
117122
str = "\t\tBuffer size is " + std::to_string(mSize);
118123
str += " and start at index " + std::to_string(mStart) + "\n";
119124
str += explicitPointerToString(mExplicit);
120125
return str;
121126
}
122127
template <class D>
123-
void Buffer<D>::print()
124-
{
128+
void Buffer<D>::print(){
125129
std::string str;
126130
str = this->toString();
127131
std::cout << str;
128132
}
129133
template <class D>
130-
void Buffer<D>::println()
131-
{
134+
void Buffer<D>::println(){
132135
this->print();
133136
std::cout << "\n";
134137
}

include/component.hpp

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
#ifndef COMPONENT
22
#define COMPONENT
33

4-
/**** Compressed Stack: declarations ****/
4+
/*==============================================================================
5+
Includes
6+
==============================================================================*/
57
#include "sign.hpp"
68
#include "stack.hpp"
79
#include <string>
810
#include <memory>
911

10-
/* Component of a Compressed Stack */
12+
/*==============================================================================
13+
Class : template (T context, D datas)
14+
Extensions :
15+
Aliases :
16+
Friends ->
17+
<-
18+
==============================================================================*/
1119
template <class T, class D>
12-
class Component
13-
{
20+
class Component{
1421
public:
1522
Component<T,D>(int space, int depth);
1623

@@ -50,10 +57,11 @@ class Component
5057
std::shared_ptr<Signature<T>> mSign;
5158
};
5259

53-
/** Constructors **/
60+
/*==============================================================================
61+
Constructors
62+
==============================================================================*/
5463
template <class T, class D>
55-
Component<T,D>::Component(int space, int depth)
56-
{
64+
Component<T,D>::Component(int space, int depth){
5765
mSign = std::shared_ptr<Signature<T>> (nullptr);
5866

5967
Levels<T> partial = initLevels<T>(space, depth);
@@ -64,10 +72,11 @@ Component<T,D>::Component(int space, int depth)
6472
mExplicit = xplicit;
6573
}
6674

67-
/** IO **/
75+
/*==============================================================================
76+
IO
77+
==============================================================================*/
6878
template <class T>
69-
std::string levelsToStringInComponent(Levels<T> levels)
70-
{
79+
std::string levelsToStringInComponent(Levels<T> levels){
7180
std::string str;
7281
str = "";
7382
int index = 0;
@@ -81,8 +90,7 @@ std::string levelsToStringInComponent(Levels<T> levels)
8190
}
8291

8392
template <class T, class D>
84-
std::string Component<T,D>::toString()
85-
{
93+
std::string Component<T,D>::toString(){
8694
std::string str;
8795
str = levelsToStringInComponent(mPartial);
8896
str += "\t\t\tExplicit->\n";
@@ -115,7 +123,9 @@ bool Component<T,D>::isExplicitEmpty(){
115123
return (mExplicit.empty());
116124
}
117125

118-
/** Push and pop **/
126+
/*==============================================================================
127+
Stack Functions: push, pop, top, topIndex
128+
==============================================================================*/
119129
template <class T, class D>
120130
void Component<T,D>::pushExplicit(std::shared_ptr<Data<D>> elt){
121131
mExplicit.push_back(elt);
@@ -147,7 +157,9 @@ int Component<T,D>::topIndex(int lvl){
147157
return index;
148158
}
149159

150-
/** Setters **/
160+
/*==============================================================================
161+
Setters
162+
==============================================================================*/
151163
template <class T, class D>
152164
void Component<T,D>::setSignature(std::shared_ptr<Signature<T>> sign){
153165
mSign = sign;
@@ -169,7 +181,9 @@ void Component<T,D>::clearExplicit(int space){
169181
mExplicit.reserve(space);
170182
}
171183

172-
// Getters
184+
/*==============================================================================
185+
Getters
186+
==============================================================================*/
173187
template <class T, class D>
174188
Signature<T> Component<T,D>::getSign(){
175189
return *mSign;

include/compressedStack.hpp

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#ifndef COMPRESSEDSTACK
22
#define COMPRESSEDSTACK
33

4-
/**** Compressed Stack: declarations ****/
4+
/*==============================================================================
5+
Includes
6+
==============================================================================*/
57
#include "sign.hpp"
68
#include "stack.hpp"
79
#include "component.hpp"
@@ -11,10 +13,15 @@
1113
#include <cmath>
1214
#include <memory>
1315

14-
/* Compressed Stack itself */
16+
/*==============================================================================
17+
Class : template (T context, D datas)
18+
Extensions :
19+
Aliases :
20+
Friends ->
21+
<-
22+
==============================================================================*/
1523
template <class T, class D>
16-
class CompressedStack: public Stack<D>
17-
{
24+
class CompressedStack: public Stack<D>{
1825
public:
1926
CompressedStack<T,D>(int size, int space, int buffer, std::shared_ptr<T> context, std::streampos position);
2027

@@ -56,13 +63,12 @@ class CompressedStack: public Stack<D>
5663
std::shared_ptr<T> mContext;
5764
};
5865

59-
/** Constructors **/
66+
/*==============================================================================
67+
Constructors
68+
==============================================================================*/
6069
template <class T, class D>
6170
CompressedStack<T,D>::CompressedStack(int size, int space, int buffer, std::shared_ptr<T> context, std::streampos position)
62-
: mFirst(size,space)
63-
, mSecond(size,space)
64-
, mBuffer(buffer)
65-
{
71+
:mFirst(size,space), mSecond(size,space), mBuffer(buffer){
6672
mSize = size;
6773
mSpace = space;
6874
mDepth = (int) ceil(log(size)/log(space)-.1); // - 1;
@@ -74,10 +80,11 @@ CompressedStack<T,D>::CompressedStack(int size, int space, int buffer, std::shar
7480
mContext = context;
7581
}
7682

77-
/** IO **/
83+
/*==============================================================================
84+
IO : toString
85+
==============================================================================*/
7886
template <class T, class D>
79-
std::string CompressedStack<T,D>::toString()
80-
{
87+
std::string CompressedStack<T,D>::toString(){
8188
std::string str;
8289
str = "\tCompressed Stack with " + std::to_string(mSize) + " elements, ";
8390
str += std::to_string(mSpace) + " space order, ";
@@ -93,19 +100,19 @@ std::string CompressedStack<T,D>::toString()
93100
}
94101

95102
template <class T, class D>
96-
void CompressedStack<T,D>::print()
97-
{
103+
void CompressedStack<T,D>::print(){
98104
std::cout << this->toString();
99105
}
100106

101107
template <class T, class D>
102-
void CompressedStack<T,D>::println()
103-
{
108+
void CompressedStack<T,D>::println(){
104109
this->print();
105110
std::cout << std::endl;
106111
}
107112

108-
/** Pushes, pops and accesses **/
113+
/*==============================================================================
114+
Stack Functions: push, pop, isempty
115+
==============================================================================*/
109116
template <class T, class D>
110117
bool CompressedStack<T,D>::isempty(){
111118
return (mFirst.isempty() && mSecond.isempty());
@@ -195,24 +202,21 @@ void CompressedStack<T,D>::pushCompressed(std::shared_ptr<Data<D>> elt, int lvl)
195202
}
196203

197204
template <class T, class D>
198-
Data<D> CompressedStack<T,D>::pop()
199-
{
205+
Data<D> CompressedStack<T,D>::pop(){
200206
Data<D> d (1,1);
201207
return d;
202208
}
203209

204210
template <class T, class D>
205-
Data<D> CompressedStack<T,D>::top(int k)
206-
{
211+
Data<D> CompressedStack<T,D>::top(int k){
207212
if (k == 0) {
208213
return top();
209214
}
210215
return mBuffer.top(k);
211216
}
212217

213218
template <class T, class D>
214-
Data<D> CompressedStack<T,D>::top()
215-
{
219+
Data<D> CompressedStack<T,D>::top(){
216220
if (mFirst.isExplicitEmpty()) {
217221
return mSecond.top();
218222
}

0 commit comments

Comments
 (0)