数据结构(LinkedList的java实现)
package day10;
import java.util.*;
public class MyLinkedList implements List
{
static class Node
{
public Object data;
public Node next;
public Node(Object data)
{
this.data=data;
}
}
private Node head;
public MyLinkedList()
{
head=new Node(0);
}
public void add(int index, Object element)
{
if(index<(Integer)head.data)
{
Node current;
current=head;
for(int i=0;i<index;i++)
{
current=current.next;
}
Node p=new Node(element);
p.next=current.next;
current.next=p;
head.data=(Integer)head.data+1;
}
else
{
System.out.println("ERROR!");
}
}
@Override
public boolean add(Object e)
{
Node current=head;
while(current.next!=null)
{
current=current.next;
}
Node p=new Node(e);
current.next=p;
head.data=(Integer)head.data+1;
return true;
}
@Override
public boolean addAll(Collection c) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean addAll(int index, Collection c) {
// TODO Auto-generated method stub
return false;
}
@Override
public void clear()
{
head.next=null;
}
@Override
public boolean contains(Object o)
{
Node current=head;
while(current.next!=null)
{
current=current.next;
if(current.data.equals(o))
{
return true;
}
}
return false;
}
@Override
public boolean containsAll(Collection c)
{
// TODO Auto-generated method stub
return false;
}
@Override
public Object get(int index)
{
Node current;
current=head.next;
for(int i=0;i<index;i++)
{
current=current.next;
}
return current.data;
}
@Override
public int indexOf(Object o)
{
int i;
Node current=head;
for(i=0;i<(Integer)head.data;i++)
{
current=current.next;
if(current.data.equals(o))
{
break;
}
}
if(i<(Integer)head.data)
{
return i;
}
return -1;
}
@Override
public boolean isEmpty()
{
if(head.next!=null)
{
return true;
}
return false;
}
@Override
public Iterator iterator()
{
return new Iterator()
{
Nod
相关文档:
Java学习从入门到精通
一、 JDK (Java Development Kit)
JDK是整个Java的核心,包括了Java运行环境(Java Runtime Envirnment),一堆Java工具和Java基础的类库(rt.jar)。不论什么Java应用服务器实质都是内置了某个版本的JDK。因此掌握JDK是学好Java的第一步。最主流的J ......
FLEX:
[Bindable] public var ary1:Array=[];
private function init():void{
ary1.push('黄晓华');
......
JAVA annotation入门
最近对spring源码感兴趣,今天看到annotation部分,略记之。
一. 最常见的annotation
@Override:用在方法之上,用来告诉别人这一个方法是改写父类的
@Deprecated:建议别人不要使用旧的API的时候用的,编译的时候会用产生警告信息,可以设定在 ......
题计:这里给出java解析xml,以帮助人们理解许多容器是怎么做的。。像spring,struts等.
1.mysql.xml代码:
<?xml version="1.0" encoding="UTF-8"?>
<data>
<datasource>
<servername>localhost</servername>
<serverport>3306</serverport>
<databasen ......
首先,做一点说明。Flex是不能直接连接数据库的,这一点大家需要知道,它只能间接地连接数据库。Flex中提供了三种方式:HttpService,WebService 和RemoteObject。其中HttpService可以直接获取XML中的数据,还可以通过JSP,ASP以及PHP读取数据库中的数据,这个比较简单,而且网上也有很多例子,我就不多说了。WebServi ......