28 Star 110 Fork 86

hinus/pythonvm

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
stack.hpp 798 Bytes
一键复制 编辑 原始数据 按行查看 历史
hinus 提交于 2018-10-03 00:06 +08:00 . add gc
#ifndef _STACK_HPP
#define _STACK_HPP
class OopClosure;
template<typename V>
class Stack {
private:
V* vector;
int _len;
int _size;
public:
Stack(int n = 16) {
_len = n;
vector = new V[n];
_size = 0;
}
~Stack() {
delete[] vector;
_len = 0;
_size = 0;
}
void push(V v) {
vector[_size++] = v;
}
V pop() {
return vector[--_size];
}
V top() {
return vector[_size - 1];
}
V peek(int index) {
return vector[_size - index - 1];
}
int len() {
return _len;
}
int size() {
return _size;
}
bool empty() {
return _size == 0;
}
void copy(const Stack<V>* stack);
void oops_do(OopClosure* f);
};
#endif
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/hinus/pythonvm.git
git@gitee.com:hinus/pythonvm.git
hinus
pythonvm
pythonvm
master

搜索帮助