package com.xdl.data_stru;
public class Day_Three_LinkStackNode<E> {
public E data;
public Day_Three_LinkStackNode<E> next;
}
package com.xdl.data_stru;
/**
* @author xudaolong
* 泛型链式存储结构的栈
* @param <E>
*/
@SuppressWarnings("unused")
public class Day_Three_LinkStack<E> {
private Day_Three_LinkStackNode<E> top;
private void init() {
this.top = null;
}
private boolean push(E e) {
Day_Three_LinkStackNode<E> lsn = new Day_Three_LinkStackNode<E>();
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<E> lsn = new Day_Three_LinkStackNode<E>();
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;
}
}
java 数据结构之 链式存储结构 栈
最新推荐文章于 2022-12-30 19:17:20 发布