1 Star 0 Fork 86

alpha-99/pythonvm

forked from hinus/pythonvm 
Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
stack.hpp 798 Bytes
Copy Edit Raw Blame History
hinus authored 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/alpha-99/pythonvm.git
git@gitee.com:alpha-99/pythonvm.git
alpha-99
pythonvm
pythonvm
master

Search