Matlab-堆栈数据结构 [英] Matlab - Stack Data Structure
问题描述
我可以在matlab中使用堆栈数据结构吗?
Can I have a stack data structure in matlab?
例如,一堆整数,我可以像stack.push(i)
那样将元素压入其中,像i = stack.pop()
那样取出元素,并检查它是否为空stack.isempty()
.
For example a stack of integers where I can push elements in it like stack.push(i)
, get elements out of it like i = stack.pop()
and check out if it is empty stack.isempty()
.
推荐答案
即使在较新的版本中,我也不认为MATLAB有一个.但是您可以使用Java,它是MATLAB中的一流公民",可以根据需要与整数完美配合.另请参见队列和
I do not think MATLAB has one even in the newer versions. But you can use Java, it is a "first class citizen" in MATLAB, it would work perfectly with integers as you need it. See also queue and linked-list related questions.
只需在MATLAB stack=java.util.Stack()
中编写,然后您就可以
Just write in MATLAB stack=java.util.Stack()
and then you can call methods on it as in your question stack.push(i)
, ecc.
这篇关于Matlab-堆栈数据结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!