SBX - Search With Button

SBX - Forum Post Title

Binary Tree Datastructure?

Dynamics 365 for Finance and Operations Forum

Maneesh Kumar asked a question on 15 Sep 2018 12:22 PM

Question Status

Verified

Hello

Is there any binary-tree data structure in X++. I can see a class for map but cannot find any for binary tree.

Reply
Verified Answer

Hi Maneesh Kumar,

What stops you to implement your own binary tree ?

Reply
Danyal Imran responded on 16 Sep 2018 5:43 AM
My Badges
Verified Answer

Hi Maneesh,

There isn't any. The only collection classes available in Dynamics 365 for Operations are Set, Map and Container.

As ievgen suggested, you should implement your own binary tree data structure using BTree and Node class (Typical approach, look It up on google).

Reply
Maneesh Kumar responded on 16 Sep 2018 7:57 AM

yes i am creating my own tree class thanks

Reply
Martin Dráb responded on 16 Sep 2018 3:23 PM
Verified Answer

Also note that you can use classes defined in .NET. For example, you might be interested in SortedDictionary or SortedSet<T> (included in the base class library).

Reply
Maneesh Kumar responded on 17 Sep 2018 11:11 AM

martin,

can we have generics in x++? i have tried to add namespace but angle brackets fail SortedSet<Common> set = new SortedSet<Common>();

Reply
Martin Dráb responded on 17 Sep 2018 11:52 AM
Verified Answer

It's not officially supported, but there are some fragments of such support. Check my blog post Generic types in X++ (AX 7).

Rather than trying to use it directly from X++, which isn't officially supported, you should consider creating a C# library, handling stuff requiring generics there and exposing a non-generic interface. Then you can add a project reference to an X++ project and call your C# classes from X++.

Reply
Maneesh Kumar responded on 17 Sep 2018 2:08 PM

wow. i never think we can use x++ like this. is it a good practice to create library using c# for production environment since we would need to share dll files?

Reply
Martin Dráb responded on 17 Sep 2018 3:11 PM

Oh yes, it's a fully supported feature. But notice that I didn't mention any DLL files; you don't have to deal with them. If you create a project reference inside a solution, it will automatically add an AOT reference (you just have to add it to version control, it doesn't happen automatically) and Visual Studio will build your C# library as well as X++. And the generated assembly (.dll) will be included in deployable packages and deployed to other environments as any other customization.

It's not a completely new approach. In AX 2012, you can add Visual Studio projects to AOT and they're also deployed automatically.

Reply
Verified Answer

Hi Maneesh Kumar,

What stops you to implement your own binary tree ?

Reply
Danyal Imran responded on 16 Sep 2018 5:43 AM
My Badges
Verified Answer

Hi Maneesh,

There isn't any. The only collection classes available in Dynamics 365 for Operations are Set, Map and Container.

As ievgen suggested, you should implement your own binary tree data structure using BTree and Node class (Typical approach, look It up on google).

Reply
Martin Dráb responded on 16 Sep 2018 3:23 PM
Verified Answer

Also note that you can use classes defined in .NET. For example, you might be interested in SortedDictionary or SortedSet<T> (included in the base class library).

Reply
Martin Dráb responded on 17 Sep 2018 11:52 AM
Verified Answer

It's not officially supported, but there are some fragments of such support. Check my blog post Generic types in X++ (AX 7).

Rather than trying to use it directly from X++, which isn't officially supported, you should consider creating a C# library, handling stuff requiring generics there and exposing a non-generic interface. Then you can add a project reference to an X++ project and call your C# classes from X++.

Reply

SBX - Two Col Forum

SBX - Migrated JS