English 中文(简体)
a. 硬盘上加固阵列
原标题:Saving arrays to the hard disk
  • 时间:2012-05-01 21:34:41
  •  标签:
  • java
  • arrays

I have written a program that uses 2 million arrays of integer values. However, it only uses 200 arrays at a time. I have 200 intelligent cars that move over a terrain of 10 000 blocks (divided according to GPS values). Each block has an array of 129x28 that has integer values. When any car moves into a new block, it must retrieve the array which is related to this block then it uses a value in that array. Then it makes a decision based on that value, then it moves on and so on. So the entire system of 200 cars and 10 000 blocks, while each car has its own array distinct values, the total number of arrays is 2 millions. I need to simply retrieve 1 array of each car at a time slot = 200 arrays at a time

这些阵列将在申请开始时设立并填满零,然后申请开始填满这些阵列,最后只能使用。 因此,我撰写了一份法典,在该方案中设立这些阵列。

在我想要的时候,我能够把阵列储存在人类发展报告中,并取回?

Update

Since I had 2 million arrays and I can t store & retrieve 200 arrays in 1-1.9 seconds I down-graded the research to use less environment features and ended up with with using 2 million arrays of size 7 x 28. which used 7 * 28 * 10 000 * 4 (integer) * 200 (cars) bytes which consumed only 1.6 GB if RAM. Good luck if you re having similar problem, PM if you are in a similar situation and I hope I will be able to help.

最佳回答

One reasonably easy solution is to use the ObjectOutputStream and ObjectInputStream classes to write and read your arrays.

举例来说,在纸面上写一个阵列:

    int [][] array = new int [129] [28];
    // fill in your array here
    ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(fileName));
    out.writeObject(array);
    out.close();

下面是一些例子,读到先前从磁盘中节省的阵列:

    ObjectInputStream in = new ObjectInputStream(new FileInputStream(fileName));
    int [] [] inArray = (int [] []) in.readObject();
    in.close();
问题回答

暂无回答




相关问题
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 ...

热门标签