Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Java by MyList ( 15 years ago )
public class MyList
{
private String []list;
public MyList()
{
String[]name;
name=null;
this.list=name;
}
public MyList(String name)
{
String[]Name;
Name=new String[1];
this.list=Name;
this.list[0]=name;
}
public MyList(String [] x){
Names=new String[x.length];
for(int i=0;i<x.length;i++){
Names[i]=x[i];
}
}
public int getLength()
{
return list.length;
}
public String getFirst()
{
return list[0];
}
public String[] rest()
{
String []rest=new String[list.length];
for(int i=0; i<list.length-1; i++)
{
rest[i]=list[i+1];
}
return rest;
}
public void Insert(String x, int p)
{
String []a= new String[l.length+1];
int i= p-1;
for (int j=0; j<i; j++)
{
a[j]= this.l[j];
}
a[i]= x;
int z=i;
i++;
while (i<a.length)
{
a[i]= l[z];
z++;
i++;
}
list= a;
}
public void Delete(String x)
{
int count=0;
int i=0;
while(i<list.length)
{
if(x.equals(list[i]))
count++;
i++;
}
String[]y=new String[list.length-count];
int j=0;
while(j<y.length)
{
if(!x.equals(list[j]))
{
y[j]=list[j];
j++;
}
else
{
y[j]=list[j+1];
j++;
}
}
list=y;
}
public boolean empty()
{
if(list.length==0)
return true;
else
return false;
}
public boolean subList(String [] x)
{
int j=0;
for(int i=0; i<x.length; i++){
boolean flag=false;
while(j<list.length && flag==false){
if(x[i].equals(list[j])){
flag=true;
}
j++;
}
if (flag==false){
return false;
}
}
return true;
}
}
Revise this Paste
Parent: 36391
Children: 36398