English 中文(简体)
商业逻辑等决策树设计建议
原标题:Design suggestion for decision tree like business logic

I am trying to design the data structure to support data that looks like the following for example, according to the first line if X<=15 and Y<=78.00 and X>625500 i need to populate Z as some value.

设计这个方法的最佳方法是什么,以便数据储存和检索既有效率又优雅?树能工作吗?

P.S.我不想在数据库中存储这个数据集,但宁愿在 Java 数据结构中存储

谢谢,多谢

    X             Y                 Z
<= 15    <= 78.00         > 625,500
<= 15   <= 78.00         <= 625,500
<= 15   78.01 - 90.00     > 625,500
<= 15   78.01 - 90.00    <= 625,500
<= 15  > 90.00                > 625,500
<= 15  > 90.00            <= 625,500

问题回答

由于您的数据不是一个自定义结构, 我认为如果您将一行作为一个对象( amp) 来对待, 那么它会更好, 然后创建它的收藏 。

例如:

Class Row{
<variables for X, Y, Z>
<getter setter for X, Y, Z>
}

List<Row> myTable .....

myTable.add(row1);
myTable.add(row2);

现在有了这个, 您可以直接访问您想要的任何一行, 只要做我的表. get(3) 就可以获得第三行。 现在在该对象中, X Y 访问可以计算该对象中的 Z & amp; 设置。 您可以创建 RowUtil. java 来设置 Z 计算方法 。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签