gpt4 book ai didi

java - Java 中的矩阵指针

转载 作者:行者123 更新时间:2023-12-01 11:58:49 26 4
gpt4 key购买 nike

在 Java 中使用矩阵指针的最佳方法操作系统标准机制是什么?

基本上我有一个矩阵并且喜欢使用像 cellPointers 这样的东西我可以在其中检索 getXaxisIndex()、getYaxisIndex() 和 getCellValue()。

如果只有标准数组存储像这样的引用......:

myMatrix[1][3]=235 //Auto or myMatrix[1][3].setValue(235)
myPointer=myMatrix[1][3]
myPointer.getX()=1
myPointer.getY()=3
myPointer.getValue()=235

最佳答案

您可能实现的是

class Cell {
Cell( int x, int y ){...}
Cell( int x, int y, int value ){...}
int getX(){...}
int getY(){...}
int getValue(){...}
}

class Table {
Table( int rows, int cols ){...}
void put( Cell c ){...}
Cell get( int x, int y ){...}
}

Table 是否应该包含 Cell[][] 取决于您没有提到的一些细节。对于大且稀疏的数组,可以考虑 HashMap 。

关于java - Java 中的矩阵指针,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28135904/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com