Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in deletion of element #2

Closed
maraigue opened this issue Jul 16, 2020 · 1 comment
Closed

Bug in deletion of element #2

maraigue opened this issue Jul 16, 2020 · 1 comment

Comments

@maraigue
Copy link
Owner

#include "LTOList.hpp"
#include <iostream>

int main(void){
    size_t n = 9;
    LTOList<double> ot;
    for(size_t i = 0; i < n; ++i) ot.insert(ot.end(), i);

    std::cout << "-----------------------------------------------" << std::endl;
    std::cout << "OrigSize=" << n << " (SizeAfterPop=" << (n-1) << ")" << std::endl;
    std::cout << std::endl;
    ot.base_.display_tree(std::cout); // suppose that `base_` is made `public` (originally `private`)
    std::cout << std::endl;

    ot.pop_front();

    ot.base_.display_tree(std::cout);
    std::cout << std::endl;
}

produced the following:

{LTOList Size=9 Origin=0xd13870 Root=0xd13530 Front=0xd138b0 Back=0xd13830}
    <B>[0 this=0xd138b0 parent=0xd134f0 children=0,0] 0
  <B>[1 this=0xd134f0 parent=0xd13530 children=1,1] 1
    <B>[2 this=0xd13570 parent=0xd134f0 children=0,0] 2
<B>[3 this=0xd13530 parent=0xd13870 children=3,5] 3
    <B>[4 this=0xd136f0 parent=0xd13a70 children=0,0] 4
  <B>[5 this=0xd13a70 parent=0xd13530 children=1,3] 5
      <B>[6 this=0xd13bf0 parent=0xd13af0 children=0,0] 6
    <R>[7 this=0xd13af0 parent=0xd13a70 children=1,1] 7
      <B>[8 this=0xd13830 parent=0xd13af0 children=0,0] 8

{LTOList Size=9 Origin=0xd13870 Root=0xd13a70 Front=0xd134f0 Back=0xd13830}
    <B>[0 this=0xd134f0 parent=0xd13530 children=0,1] 1
      <R>[1 this=0xd13570 parent=0xd134f0 children=0,0] 2
  <B>[3 this=0xd13530 parent=0xd13a70 children=3,1] 3
    <B>[4 this=0xd136f0 parent=0xd13530 children=0,0] 4
<B>[5 this=0xd13a70 parent=0xd13870 children=5,3] 5
    <B>[6 this=0xd13bf0 parent=0xd13af0 children=0,0] 6
  <B>[7 this=0xd13af0 parent=0xd13a70 children=1,1] 7
    <B>[8 this=0xd13830 parent=0xd13af0 children=0,0] 8

The strange point is <B>[5 this=0xd13a70 parent=0xd13870 children=5,3] 5 in the latter tree; although number of left and right child nodes of the node are 4 and 3, respectively, it displays children=5,3.

I examined this situation for n = 4 to 24, and found that such a behavior is produced for n = 9, 10, 19, 20, 21 and 22.

@maraigue
Copy link
Owner Author

I found and fixed the bug. 7417bb1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant