MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   Matlab-堆栈数据结构 (https://www.labfans.com/bbs/showthread.php?t=24113)

poster 2019-12-10 20:48

Matlab-堆栈数据结构
 
我可以在matlab中使用堆栈数据结构吗?

例如,一堆整数,我可以像其中那样将元素压入stack.push(i) ,像i = stack.pop()那样取出元素,然后检查它是否为空stack.isempty() 。



[B]回答:[/B]

我认为MATLAB甚至在较新的版本中都没有。但是您可以使用Java,它是MATLAB中的“一流公民”,可以根据需要与整数完美配合。另请参阅[URL="https://stackoverflow.com/questions/1413860/matlab-linked-list"]与[/URL] [URL="https://stackoverflow.com/questions/4142190/is-there-a-queue-in-matlab"]队列[/URL]和[URL="https://stackoverflow.com/questions/1413860/matlab-linked-list"]链接列表[/URL]有关的问题。

只需在MATLAB stack=java.util.Stack()编写,然后[URL="http://download.oracle.com/javase/1.4.2/docs/api/java/util/Stack.html"]就可以[/URL]像在问题stack.push(i)那样[URL="http://download.oracle.com/javase/1.4.2/docs/api/java/util/Stack.html"]调用方法了[/URL] 。



[url=https://stackoverflow.com/questions/4163920]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 23:19

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.