Giter VIP home page Giter VIP logo

Comments (5)

axkr avatar axkr commented on June 3, 2024 1

Seems to be fixed

from paguro.

GlenKPeterson avatar GlenKPeterson commented on June 3, 2024

This unit test passes:

    @Test public void testMutable() {
        List<Integer> control = new ArrayList<>();
        MutList<Integer> test = PersistentVector.emptyMutable();
        final int SEVERAL = 2000; // more than 1024 so 3 levels deep.
        for (int i = 0; i < SEVERAL; i++) {
            control.add(i);
            test.append(i);
            assertEquals(control.size(), test.size());
        }

        for (int i = 0; i < SEVERAL; i++) {
            assertEquals(control.get(i), test.get(i));
        }

        for (int i = 0; i < SEVERAL; i++) {
            control.set(i, i + 10);
            test.replace(i, i + 10);
            assertEquals(control.size(), test.size());
            assertEquals(control, test);
        }

Can you alter it to make it fail? If you can do that, you don't need to answer any of my other questions. Otherwise:

If I understand what I'm looking at in your image, you have a mutable vector with a list as the first element and Doubles or Floats as the other visible elements. You just called replace with object id=314 and idx=1 and it looks like it put object id=314 (-92.4031) at index 1 and is ready to return the correctly mutated-in-place vector.

Questions about your example:

  • What was at index 1 before?
  • What was your expected result, vs. the actual?
  • Why is there a List at index 0 when everything else in the vector looks like double? I don't use a lot of Heterogeneous vectors, so I guess this is more of a chatty question than troubleshooting.

Questions about reproducing this issue:

  • How big a vector do you need to see the problem?
  • Does it happen with homogeneous vectors, or just heterogeneous ones?

from paguro.

axkr avatar axkr commented on June 3, 2024

Seems to be a problem with the MutVector#replace() and call of MutVector#editableArrayFor() method.

Example for 3.6.0 version from Maven Central:

import org.organicdesign.fp.StaticImports;
import org.organicdesign.fp.collections.ImList;
import org.organicdesign.fp.collections.MutList;

public class PersistentVectorTest {
  public static void main(String[] args) {
    ImList<String> v = StaticImports.vec("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
        "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25",
        "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40",
        "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55",
        "56", "57", "58", "59", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70",
        "71", "72", "73", "74", "75", "76", "77", "78", "79", "80", "81", "82", "83", "84", "85",
        "86", "87", "88", "89", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99");
    MutList<String> m = v.mutable();
    m.replace(0, "bug");
    System.out.println(m.get(0).toString());
  }
}

from paguro.

GlenKPeterson avatar GlenKPeterson commented on June 3, 2024

Thanks for finding this bug! I will fix, but maybe not until next weekend.

from paguro.

GlenKPeterson avatar GlenKPeterson commented on June 3, 2024

Thank you so much! This should be fixed in 3.7.0 which I just released. If you get a chance to test it, please leave a comment here and I'll close the issue.

from paguro.

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.