Code Monkey home page Code Monkey logo

ltolist's People

Contributors

maraigue avatar

Watchers

 avatar  avatar

Forkers

ignisan

ltolist's Issues

Bug in deletion of element

#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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.