Skip to content

Commit e271608

Browse files
committed
End Rename of Block into Level
1 parent c961936 commit e271608

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

include/compressedStack.hpp

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ template <class T, class D> class CompressedStack : public Stack<T, D> {
5252
// Setters required as from virtual functions in Stack.hpp
5353
void setContext(std::shared_ptr<T> context);
5454
void setPosition(std::streampos position);
55-
void setCompressed(Block<T, D> block);
55+
void setCompressed(Level<T, D> block);
5656

5757
// Getters required as from virtual functions in Stack.hpp
58-
Block<T, D> getFirstPartial(int lvl);
59-
Block<T, D> getCompressed();
58+
Level<T, D> getFirstPartial(int lvl);
59+
Level<T, D> getCompressed();
6060
ExplicitPointer<T, D> getFirstExplicit();
6161
Signature<T, D> getFirstSign();
6262
int getBufferSize ();
@@ -79,8 +79,8 @@ template <class T, class D> class CompressedStack : public Stack<T, D> {
7979
/* Push related */
8080
void pushExplicit(SPData<T, D> elt);
8181
void pushCompressed(SPData<T, D> elt, int lvl, int headIndex);
82-
void compress(Block<T, D> block);
83-
void resetBlock(Signature<T, D> sign, int lvl);
82+
void compress(Level<T, D> block);
83+
void resetLevel(Signature<T, D> sign, int lvl);
8484

8585
/* Pop related */
8686
void popBuffer();
@@ -92,7 +92,7 @@ template <class T, class D> class CompressedStack : public Stack<T, D> {
9292

9393
// Other getters
9494
SPData<T, D> getExplicitData(int k);
95-
Block<T, D> getSmartCompress(int lvl);
95+
Level<T, D> getSmartCompress(int lvl);
9696
Signature<T, D> getBottomSign();
9797

9898
// Structure constraints
@@ -110,7 +110,7 @@ template <class T, class D> class CompressedStack : public Stack<T, D> {
110110
// First, Second, and Compressed components
111111
Component<T, D> mFirst;
112112
Component<T, D> mSecond;
113-
Block<T, D> mCompressed;
113+
Level<T, D> mCompressed;
114114

115115
// Buffer to read the top k elements
116116
Buffer<T, D> mBuffer;
@@ -130,7 +130,7 @@ CompressedStack<T, D>::CompressedStack(int size, int space, int buffer,
130130
mSpace = space;
131131
mDepth = int(ceil(log(size) / log(space) - .001) - 1);
132132
mPosition = position;
133-
mCompressed = initBlock<T, D>(mSpace);
133+
mCompressed = initLevel<T, D>(mSpace);
134134
mContext = context;
135135
}
136136

@@ -143,7 +143,7 @@ CompressedStack<T, D>::CompressedStack(int size, int space, int buffer,
143143
mSize = size;
144144
mSpace = space;
145145
mDepth = int(ceil(log(size) / log(space) - .001) - 1);
146-
mCompressed = initBlock<T, D>(mSpace);
146+
mCompressed = initLevel<T, D>(mSpace);
147147

148148
mPosition = sign.mPosition;
149149
mContext = sign.mContext;
@@ -348,25 +348,25 @@ void CompressedStack<T, D>::setPosition(std::streampos position) {
348348
}
349349

350350
template <class T, class D>
351-
void CompressedStack<T, D>::setCompressed(Block<T, D> block) {
351+
void CompressedStack<T, D>::setCompressed(Level<T, D> block) {
352352
mCompressed = block;
353353
}
354354

355355
/*==============================================================================
356356
Getters : getFirstPartial, getCompressed, getFirstExplicit, getExplicitData
357357
==============================================================================*/
358358
template <class T, class D>
359-
Block<T, D> CompressedStack<T, D>::getFirstPartial(int lvl) {
359+
Level<T, D> CompressedStack<T, D>::getFirstPartial(int lvl) {
360360
return mFirst.mPartial[lvl - 1];
361361
}
362362

363-
template <class T, class D> Block<T, D> CompressedStack<T, D>::getCompressed() {
363+
template <class T, class D> Level<T, D> CompressedStack<T, D>::getCompressed() {
364364
return mCompressed;
365365
}
366366

367367
template <class T, class D>
368-
Block<T, D> CompressedStack<T, D>::getSmartCompress(int lvl) {
369-
Block<T, D> compressed(mCompressed);
368+
Level<T, D> CompressedStack<T, D>::getSmartCompress(int lvl) {
369+
Level<T, D> compressed(mCompressed);
370370
for (int i = lvl; i >= 0; i--) {
371371
if (empty(i + 1, 1)) {
372372
int s = mSecond.mPartial[i].size();
@@ -440,7 +440,7 @@ template <class T, class D> std::string CompressedStack<T, D>::toString() {
440440
str += "\t\tSecond Component\n";
441441
str += mSecond.toString();
442442
str += "\t\tFully Compressed -> ";
443-
str += blockToString(mCompressed);
443+
str += levelToString(mCompressed);
444444
str += mBuffer.toString();
445445
return str;
446446
}
@@ -450,17 +450,17 @@ template <class T, class D> std::string CompressedStack<T, D>::toString() {
450450
1) push
451451
2) pushExplicit
452452
3) pushCompressed
453-
4) resetBlock
453+
4) resetLevel
454454
==============================================================================*/
455455
// Function push that push the data in explicit and index in partial/compressed
456456
template <class T, class D>
457457
void CompressedStack<T, D>::push(const Data<T, D> &elt) {
458458
// update the buffer (if buffer size is bigger than 0)
459459
SPData<T, D> ptr_elt = std::make_shared<Data<T, D>>(elt);
460460
mBuffer.push(ptr_elt);
461-
// update the explicit Blocks, with possibly shifting first to second
461+
// update the explicit Level, with possibly shifting first to second
462462
pushExplicit(ptr_elt);
463-
// update the compressed Blocks at each levels (including fully compressed)
463+
// update the compressed Levels at each level (including fully compressed)
464464
for (int lvl = mDepth - 1; lvl > 0; lvl--) {
465465
int headIndex = getLast(lvl);
466466
pushCompressed(ptr_elt, lvl, headIndex);
@@ -486,8 +486,8 @@ void CompressedStack<T, D>::pushExplicit(SPData<T, D> elt) {
486486
// We check if thoses explicit datas are full
487487
else {
488488
int headIndex = mFirst.topIndex();
489-
int startBlock = headIndex - (headIndex - 1) % mSpace;
490-
if (index - startBlock < mSpace) {
489+
int startLevel = headIndex - (headIndex - 1) % mSpace;
490+
if (index - startLevel < mSpace) {
491491
mFirst.pushExplicit(eltPtr);
492492
mFirst.mSign.mLast = index;
493493
} else {
@@ -515,23 +515,23 @@ void CompressedStack<T, D>::pushExplicit(SPData<T, D> elt) {
515515
template <class T, class D>
516516
void CompressedStack<T, D>::pushCompressed(SPData<T, D> elt, int lvl,
517517
int headIndex) {
518-
int distSubBlock = std::pow(mSpace, (mDepth - lvl));
519-
int distBlock = distSubBlock * mSpace;
518+
int distBlock = std::pow(mSpace, (mDepth - lvl));
519+
int distLevel = distBlock * mSpace;
520520
int index = elt->mIndex;
521521
Signature<T, D> sign(index, mPosition, mFirst.mSign.mContext, mBuffer);
522522

523523
if (empty(lvl, 1)) {
524524
mFirst.push(sign, lvl);
525525
} else {
526-
int startBlock = headIndex - (headIndex - 1) % distBlock;
526+
int startLevel = headIndex - (headIndex - 1) % distLevel;
527527
// distance of the new index and current block
528-
int delta = index - startBlock;
529-
if (delta < distBlock) {
530-
// Distance with the current subblock
531-
int startSubBlock = headIndex - (headIndex - 1) % distSubBlock;
532-
int eta = index - startSubBlock;
533-
// compress new element in the top of the current Block
534-
if (eta < distSubBlock) {
528+
int delta = index - startLevel;
529+
if (delta < distLevel) {
530+
// Distance with the current Block
531+
int startBlock = headIndex - (headIndex - 1) % distBlock;
532+
int eta = index - startBlock;
533+
// compress new element in the top Block of the current Level
534+
if (eta < distBlock) {
535535
setLast(1, index, lvl);
536536
} else {
537537
mFirst.push(sign, lvl);
@@ -548,13 +548,13 @@ void CompressedStack<T, D>::pushCompressed(SPData<T, D> elt, int lvl,
548548
}
549549
}
550550
mSecond.mPartial[lvl - 1] = mFirst.mPartial[lvl - 1];
551-
resetBlock(sign, lvl);
551+
resetLevel(sign, lvl);
552552
}
553553
}
554554
}
555555

556556
template <class T, class D>
557-
void CompressedStack<T, D>::resetBlock(Signature<T, D> sign, int lvl) {
557+
void CompressedStack<T, D>::resetLevel(Signature<T, D> sign, int lvl) {
558558
mFirst.mPartial[lvl - 1].clear();
559559
mFirst.mPartial[lvl - 1].reserve(mSpace);
560560
mFirst.mPartial[lvl - 1].push_back(sign);
@@ -574,9 +574,9 @@ template <class T, class D> void CompressedStack<T, D>::compress() {
574574
topSecond = mSecond.mExplicit.back()->mIndex;
575575
}
576576
int topCompressed = mCompressed.back().mLast;
577-
int sizeBlock = std::pow(mSpace, mDepth);
578-
int startSecond = topSecond + 1 - (topSecond % sizeBlock);
579-
int startCompressed = topCompressed + 1 - (topCompressed % sizeBlock);
577+
int sizeLevel = std::pow(mSpace, mDepth);
578+
int startSecond = topSecond + 1 - (topSecond % sizeLevel);
579+
int startCompressed = topCompressed + 1 - (topCompressed % sizeLevel);
580580
if (startSecond > startCompressed) {
581581
mCompressed.push_back(mSecond.mSign);
582582
} else {
@@ -587,17 +587,17 @@ template <class T, class D> void CompressedStack<T, D>::compress() {
587587

588588
// Function that compress the top block of mSecond to a sign in mCompressed
589589
template <class T, class D>
590-
void CompressedStack<T, D>::compress(Block<T, D> block) {
590+
void CompressedStack<T, D>::compress(Level<T, D> block) {
591591
if (empty(0)) {
592592
mCompressed = block;
593593
} else {
594-
for (typename Block<T, D>::iterator it = block.begin(); it != block.end();
594+
for (typename Level<T, D>::iterator it = block.begin(); it != block.end();
595595
++it) {
596596
int topSign = (*it).mLast;
597597
int topCompressed = mCompressed.back().mLast;
598-
int sizeBlock = std::pow(mSpace, mDepth);
599-
int startSign = topSign + 1 - (topSign % sizeBlock);
600-
int startCompressed = topCompressed + 1 - (topCompressed % sizeBlock);
598+
int sizeLevel = std::pow(mSpace, mDepth);
599+
int startSign = topSign + 1 - (topSign % sizeLevel);
600+
int startCompressed = topCompressed + 1 - (topCompressed % sizeLevel);
601601
if (startSign > startCompressed) {
602602
mCompressed.push_back((*it));
603603
} else {

0 commit comments

Comments
 (0)