📄 objectlist.java
字号:
package SOMA.security.utility;
public class ObjectList
{
java.lang.Object Obj;
ObjectList next;
static public java.lang.Object[] toObjectArray(ObjectList ol){
java.lang.Object ret[] = new java.lang.Object[ol.length()];
for (int i=0; i<ol.length(); i++)
ret[i]=ol.element(i);
return ret;
}
ObjectList(){
this.Obj=null;
this.next=null;
}
ObjectList(java.lang.Object Obj){
this.Obj=Obj;
this.next=null;
}
ObjectList(java.lang.Object Obj, ObjectList ObjLst){
this.Obj = Obj;
this.next = ObjLst;
}
public int length () {
if (this.Obj==null) return 0;
if (this.next==null) return 1;
else return (this.next.length() + 1);
}
public java.lang.Object element(long i){
if (i <= 0) return this.Obj;
if (this.next == null) return null;
return this.next.element(i-1);
}
public java.lang.Object head(){
return this.Obj;
}
public ObjectList tail(){
return this.next;
}
public ObjectList cons(java.lang.Object Obj){
if (this.Obj!=null) return new ObjectList(Obj,this.next);
this.Obj = Obj;
return this;
}
public boolean empty(){
return (this.Obj==null);
}
public ObjectList emptyList(){
return new ObjectList();
}
public void add(java.lang.Object newObj){
if (this.Obj==null) this.Obj = newObj;
else
if (this.next==null) this.next=new ObjectList(newObj);
else this.next.add(newObj);
}
public void addOrd(java.lang.Object newObj){
if (this.Obj==null) this.Obj = newObj;
else
if ((this.Obj.toString()).compareTo(newObj.toString()) <= 0){
ObjectList stemp = new ObjectList(this.Obj);
stemp.next = this.next;
this.next = stemp;
this.Obj = newObj;
}
else this.next.addOrd(newObj);
}
public boolean inList(java.lang.Object obj) {
if (this.Obj == null) return false;
if (this.Obj.equals(obj)) return true;
if (this.next == null) return false;
return this.next.inList(obj);
}
public void println(){
if (this.Obj != null){
System.out.println("<#class name: ObjectList;" + this + ";String: " + this.Obj.toString());
if (this.next != null) this.next.println();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -