Updating code that used to work in older versions of ddogleg

12 views
Skip to first unread message

Nico Stuurman

unread,
Apr 14, 2021, 5:25:44 PM4/14/21
to DDogleg

After upgrading ddogleg to 0.18, the following part of my code no longer compiles:

NearestNeighbor<Point2D_F32> nn = FactoryNearestNeighbor.kdtree(new KdTreePoint2D_F32());
List<Point2D_F32> centersList = new ArrayList<>(centers.size());
for (Map.Entry<Integer, Point2D_F32> entry : centers.entrySet()) {
centersList.add(entry.getValue());
}
nn.setPoints(centersList, true);
NearestNeighbor.Search<Point2D_F32> search = nn.createSearch();
NnData<Point2D_F32> result = new NnData<>();
// 4 should be enough...
FastQueue<NnData<Point2D_F32>> fResults = new FastQueue(4, result.getClass(), true);

The particulra FastQueue constructor that I used here is no longer present.  The constructors I can find all use a Factory<T> object, but it is unclear to me how to construct one.  Also, I can no longer find FastQueue in the Javadoc to ddogleg 0.19, so maybe I should replace this with something very different altogether?  All advice appreciated!

Best,

Nico

Peter A

unread,
Apr 14, 2021, 5:51:04 PM4/14/21
to Nico Stuurman, DDogleg
In 0.19 you want to use DogArray not sure if that had made its way in yet or not by 0.18. What was FastQueue got converted into FastArray and DogArray. FastQueue was not a queue and due to feature creep was hiding a lot of bugs, since it could either be used in situations where it "owned" the elements inside of it and in situations where it did not. FastArray is similar to ArrayList but lets you mess with the internal. DogArray will automatically add new elements via grow().

You probably want to do something like this:

DogArray<NnData<Point2D_F32>> results = new DogArray<>(NnData::new);

I've not checked that code but you might need to typecast NnData due to Java being obnoxious. Part of the design change was to get away from using reflection since that was causing problems in weird edge cases, like people converting the code to Javascript. It's also more flexible now as you can use a lambda to create new objects instead of hacking it by extending the class. You can also pass in a second lambda that will reset the data when it grows the array. useful when you're recycling data and want to ensure the state is known.


--
You received this message because you are subscribed to the Google Groups "DDogleg" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ddogleg+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ddogleg/1cf13285-637f-4770-800f-6f146ef92f1dn%40googlegroups.com.


--
"Now, now my good man, this is no time for making enemies."    — Voltaire (1694-1778), on his deathbed in response to a priest asking that he renounce Satan.

Nico Stuurman

unread,
Apr 14, 2021, 6:02:02 PM4/14/21
to DDogleg
0.18 does not have DogArray.  I do not want to upgrade at this point in time because there are many dependencies all over the place that I can not check into right now.  How should this be done in 0.18?

Thanks!

Peter A

unread,
Apr 14, 2021, 6:33:28 PM4/14/21
to Nico Stuurman, DDogleg
Treat it like a DogArray but call it FastQueue instead.

Nico Stuurman

unread,
Apr 14, 2021, 8:54:35 PM4/14/21
to DDogleg
That compiles.  Thanks!

Peter A

unread,
Apr 19, 2021, 2:28:07 PM4/19/21
to Nico Stuurman, DDogleg
Reply all
Reply to author
Forward
0 new messages