由于放假回家的原因,已经有10填没有写算法了,今天刚刚回到学校,重新开始我的算法之旅。

  今天主要用java语言描写链表实现的过程。

  LinkedNode

 1 public class LinkedNode {
2 protected Object item;
3 protected LinkedNode nextNode;
4 public LinkedNode(Object x)
5 {
6 item = x;
7 nextNode = null;
8 }
9 public Object item() {
10 return item;
11 }
12 public void setItem(Object x) {
13 item = x ;
14 }
15 public LinkedNode nextNode() {
16 return nextNode;
17 }
18 public void setNextNode(LinkedNode x) {
19 nextNode = x;
20 }
21 public String toString() {
22 String temp = item.toString();
23 if(nextNode !=null)
24 temp += " " +nextNode.toString();
25 return temp;
26 }
27 }

  LinkedSimpleList

 1 public class LinkedSimpleList {
2 protected LinkedNode firstNode;
3 public LinkedSimpleList() {
4 firstNode = null;
5 }
6 public boolean isempty() {
7 return firstNode == null;
8 }
9 public boolean isfull() {
10 return false;
11 }
12 public void insertfirstNode(Object x) {
13 LinkedNode newNode = new LinkedNode(x);
14 newNode.setNextNode(firstNode);
15 firstNode = newNode;
16 }
17 public String toString() {
18 if( ! isempty())
19 return firstNode.toString();
20 else
21 return new String();
22 }
23 public void deleteFrist()throws Exception {
24 if( isempty())
25 ;
26 firstNode = firstNode.nextNode();
27 }
28
29
30
31 }

   只要心中拥有梦想,我们就应为之奋斗。

  

作者: 欧得斯克七 发表于 2011-07-24 23:15 原文链接

推荐.NET配套的通用数据层ORM框架:CYQ.Data 通用数据层框架
新浪微博粉丝精灵,刷粉丝、刷评论、刷转发、企业商家微博营销必备工具"