package com.xdl.data_stru;
public class Day_Three_LinkStackNode {
public E data;
public Day_Three_LinkStackNode next;
}
package com.xdl.data_stru;
/**
* @author xudaolong
* 泛型链式存储结构的栈
* @param
*/
@SuppressWarnings("unused")
public class Day_Three_LinkStack {
private Day_Three_LinkStackNode top;
private void init() {
this.top = null;
}
private boolean push(E e) {
Day_Three_LinkStackNode lsn = new Day_Three_LinkStackNode();
if (lsn == null) {
return false;
} else {
lsn.data = e;
lsn.next = this.top;
this.top = lsn;
return true;
}
}
private boolean is_empty() {
if (this.top == null) {
return true;
}
return false;
}
private E pop() {
Day_Three_LinkStackNode lsn = new Day_Three_LinkStackNode();
E e;
if (!is_empty()) {
e = this.top.data;
lsn = this.top;
this.top = this.top.next;
lsn = null;
return e;
}
return null;
}
private E get_top() {
if (!is_empty()) {
return this.top.data;
}
return null;
}
}