@@ -368,7 +368,7 @@ void CompressedStack<T,D>::pushExplicit(SPData<T,D> elt){
368368 mFirst .mSign .mLast = index;
369369 } else {
370370 if ((mDepth == 1 ) && (!(mSecond .isExplicitEmpty ()))) {
371- int distCompressed = mSpace * mSpace ;
371+ int distCompressed = mSpace ;
372372 int startCompressed = headIndex - (headIndex - 1 ) % distCompressed;
373373 if (index - startCompressed < distCompressed) {
374374 mCompressed .back ().mLast = headIndex;
@@ -414,7 +414,7 @@ void CompressedStack<T,D>::pushCompressed(SPData<T,D> elt, int lvl, int headInde
414414 }
415415 } else {
416416 if (lvl == 0 && (!mSecond .mPartial [0 ].empty ())) {
417- int distCompressed = std::pow (mSpace , mDepth + 1 );
417+ int distCompressed = std::pow (mSpace , mDepth );
418418 int startCompressed = headIndex - (headIndex - 1 ) % distCompressed;
419419 int gamma = index - startCompressed;
420420 if (gamma < distCompressed && !mCompressed .empty ()) {
@@ -458,11 +458,16 @@ void CompressedStack<T,D>::reconstruct(Problem<T,D> &problem){
458458// Reconstruct an auxiliary stack based on the signature found above
459459template <class T , class D >
460460void CompressedStack<T,D>::reconstruct(Problem<T,D> &problem, const Signature<T,D> &sign, int lvl){
461+ Signature<T,D> sign2 = sign;
462+ std::cout << " Reconstruct on " << sign2.toString () << std::endl;
463+
461464 std::streampos posReminder = problem.mInput .tellg ();
462465 int indexReminder = problem.mIndex ;
466+ std::ios_base::iostate eofbitReminder = problem.mInput .rdstate ();
463467
464468 problem.mContext = std::make_shared<T>(*sign.mContext );
465469 problem.mIndex = sign.mFirst - 1 ;
470+ problem.mInput .clear ();
466471 problem.mInput .seekg (sign.mPosition );
467472
468473 int auxSize = std::pow (mSpace , mDepth - lvl + 1 );
@@ -490,13 +495,14 @@ void CompressedStack<T,D>::reconstruct(Problem<T,D> &problem, const Signature<T,
490495 problem.mIndex = indexReminder;
491496 problem.mInput .seekg (posReminder);
492497 problem.mContext = mContext ;
498+ problem.mInput .setstate (eofbitReminder);
493499}
494500
495501template <class T , class D >
496502void CompressedStack<T,D>::copyContent(CompressedStack<T,D> &stack) {
497503 stack.mFirst = mFirst ;
498504 stack.mSecond = mSecond ;
499- stack.mCompressed = mCompressed ;
505+ stack.mCompressed . pop_back () ;
500506 stack.mBuffer = mBuffer ;
501507}
502508
@@ -570,6 +576,10 @@ template <class T, class D>
570576void CompressedStack<T,D>::propagateFirst(int index, int lvl){
571577 for (int i = 0 ; i <= lvl; i++) {
572578 int temp = std::min (mFirst .mPartial [i].back ().mLast , index);
579+ if (temp < mFirst .mPartial [i].back ().mFirst ) {
580+ std::cout << " Debug Prop1" << std::endl << toString () << std::endl;
581+ exit (0 );
582+ }
573583 mFirst .mPartial [i].back ().mLast = temp;
574584 }
575585}
@@ -635,12 +645,15 @@ Data<T,D> CompressedStack<T,D>::pop(Problem<T,D> &problem){
635645 SPData<T,D> elt;
636646 if (mFirst .mExplicit .empty () && mSecond .mExplicit .empty ()) {
637647 // Reconstruct the compressed stack with the first available signature
648+ std::cout << " Begin reconstruct with mDepth = " << mDepth << std::endl;
638649 reconstruct (problem);
650+ std::cout << " End reconstruct with mDepth = " << mDepth << std::endl;
639651 }
640652 if (mFirst .mExplicit .empty ()) {
641653 if (mSecond .mExplicit .empty ()) {
654+ std::cout << " Empty after reconstruct" << std::endl;
642655 problem.println ();
643- // exit(0);
656+ exit (0 );
644657 }
645658 elt = mSecond .mExplicit .back ();
646659 popSecond ((*elt).mIndex );
0 commit comments