Coder Social home page Coder Social logo

Comments (2)

spond avatar spond commented on June 5, 2024

Two issues in _AssociativeList::Merge

  1. delete p_keys would actually delete all the keys in "b" in the above example (bad idea)
  2. I rewrote the function to use AVL traversal, because otherwise we may run into issues where some of the elements in the dataList are empty (results of deletion operations on the list, for example), which would cause a different segfault.

Please use the following code patch for ::Merge

//_____________________________________________________________________________________________
void        _AssociativeList::Merge (_PMathObj p)
{
    //SW20111207: I don't think we should ever have to worry about avl traversing 
    //here as long as the other methods are implemented properly


    if(p==this){
        return;
    }

    if (p && p->ObjectClass() == ASSOCIATIVE_LIST) {

       _AssociativeList *rhs = (_AssociativeList*) p;

        _SimpleList  hist;
        long         ls,
                     cn = rhs->avl.Traverser (hist,ls,rhs->avl.GetRoot());



       /*   SLKP20120111: we need to skip over "blanks" (e.g. resulting from previous delete operations)
            here; using the traversal of the second list is the easiest way to go. */

        while (cn >= 0) {
            MStore(*(_String*)(*(_List*)rhs->avl.dataList)(cn),(_PMathObj)rhs->avl.GetXtra (cn),true);
            cn = avl.Traverser (hist,ls);
        }
    }
    else {
        WarnError ("Associative list merge operation requires an associative list argument.");
    }
}

from hyphy.

stevenweaver avatar stevenweaver commented on June 5, 2024

Ah I introduced the bug. I should have taken a look at the code before assigning it to you.

My apologies.

I'll go ahead and apply the patch.

The idea behind my change was to start reusing methods that explicitly take care of storage in an effort to reduce the lines and complexity in some parts of the code. I notice a few problems where I was a bit short-sighted though. I understand what you're doing now.

from hyphy.

Related Issues (20)

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.