# Flyingis

Talking and thinking freely !
Flying in the world of GIS !

## 基本数据结构的Java实现

class Node {

Object item; Node next;

Node (Object v) {

item = v; next = null;

}

}

x后插入t

if ( x == null)

else { t.next = x.next; x.next = t; }

x后插入tt.next = x.next; x.next = t;

x后插入tt.next = x.next; x.next = t;

x后插入tt.next = x.next; x.next = t;

class Stack {

private Object[] s;

private int n;

Stack ( int maxN ) {

s = new Object[maxN]; n = 0;

}

boolean isEmpty() { return ( n == 0 ); }

void push ( Object item ) { s[n++] = item; }

Object pop() {

Object t = s[--n]; s[n] = null; return t;

}

}

class Stack {

private class Node {

Object item; Node next;

Node ( Object item, Node next ) {

this.item = item; this.next = next;

}

}

Stack ( Object maxN ) { head = null; }

boolean isEmpty() { return ( head ==null ); }

void push ( Object item ) { head = new Node(item, head); }

Object pop() {

return v;

}

}

FIFO队列的链表实现

class Queue {

private class Node {

Object item; Node next;

Node ( Object item ) {

this.item = item; this.next = null;

}

}

Queue ( Object max ) { head = null; tail = null; }

boolean isEmpty() { return ( head ==null ); }

void put ( Object item ) {

Node t = tail;

tail = new Node(item);

if ( empty() )

else t.next = tail

}

Object get() {

return v;

}

}

posted on 2006-02-05 23:08 Flyingis 阅读(1121) 评论(1)  编辑  收藏 所属分类: Algorithm

## #re: 基本数据结构的Java实现回复更多评论

2006-02-06 11:54 | 爱拼才会赢

 只有注册用户登录后才能发表评论。 网站导航: 相关文章: