转换Objective-C的结构数组到Java数组、结构、Objective、Java

2023-09-06 15:56:38 作者:彼年豆蔻,谁许地老天荒

我移植一些Objective-C到Android。源应用程序商店有很多结构数组中的数据,并有一些高性能的方法来做查找到的结果阵列和计算设置提供附近的图形作为用户点的实时分析拖累图表周围指针他们的手指。计算结果被用于更新在围绕图形各种视图值

I'm porting some Objective-C to Android. The source app stores a lot of data in structure arrays and has some high performing methods to do lookups into the arrays and calculations on the result sets to provide near real time analysis of points on a graph as the user drags a pointer around the graph with their finger. The calculation results are used to update values in various views surrounding the graph.

下面是包含大约7.5K结构的一个例子。

Here's an example which contain approx 7.5k structures.

structDataFeedReduced gFeedData[7662] = {
1233,@"",12.466667,26.166667,@"AARS",0,0,0,1.000000,-1,1,1,
6760,@"",15.816667,41.033333,@"DCTT",1,1,1,12.000000,-1,1,2,
8117,@"",44.016667,144.283333,@"SKDD",2,1,2,9.000000,-1,1,1,
8666283,@"WS",42.676666,40.006668,@"DLCC",3,2,3,-5.000000,-1,1,6,
...
...
...
};

我的问题是什么是在Java静态存储这些数据的最佳方式?

My question is what is the best way to store this data statically in Java?

我试过这是不够的高性能以下,无论是在加载时或在运行时提供的数据计算。

I've tried the following which are not high enough performance, either at load time or to provide data to the calculations at run time.

SQL精简版。从存储资产文件中读取。 静态存储为字符串数组,然后处理它们初始化成对象,使用它反映了Objective-C的结构类(如转换为int,布尔变量,从字符串数据加倍等)在arrays.xml存储然后处理它们初始化成对象

是否有任何其他的模式,我可以试试吗?如果没有问题的话,我会赞成上述,我会牺牲良好的运行响应一些加载和初始化性能3或4。

Are there any other patterns I could try? If there are none, then I'll favour 3 or 4 above as I'll sacrifice some loading and initialisation performance for good runtime response.

我的逆止器将使用JNI推下来为本地code。也许这是唯一有意义的选项?

My backstop would be to push this down into native code using JNI. Perhaps this is the only option that makes sense?

谢谢...

推荐答案

您可以只保留这些数据作为code。你可以定义一个 StructDataFeedReduced 类,然后更改您的初始code为:

You can just keep that data as code. You could define a StructDataFeedReduced class, then change your initialization code to:

static StructDataFeedReduced[] gFeedData = new StructDataFeedReduced[] {
    new StructDataFeedReduced(1233,"",12.466667,26.166667,"AARS",0,0,0,1.000000,-1,1,1),
    new StructDataFeedReduced(6760,"",15.816667,41.033333,"DCTT",1,1,1,12.000000,-1,1,2),
    ...
}

StructDataFeedReduced 的构造函数可以在内部字段中的数据存储为合适。

The constructor of StructDataFeedReduced can store the data in internal fields as appropriate.