m back again, m working on the array list implementation
and so far i have gotten this far, I want to know if i am going in the right direction, because i feel that something is wrong, the add method that i created for my array implementation was less complicated then the one i made for linked list, so can someone please confirm my methods.
My add method adds an element to the end of the list
Note = my project is to create a list of an integer set(unordered nonrepitative collection of integers)
public class MyArraySet<Value> implements MySet<Value> {
private int[] Array;
private int capacity = 65535; /* i am guessing this is the array capacity
because the teacher told us that the range of each number in the set is
from 0 to 65535, and since the set is non repitative 65535 would be the
max range of the size of the set correct?*/
public boolean isIn(Integer v){ //checks if the value is in the array
int count=0;
boolean flag=false;
for(count=0; count<size(); count++)
{
if(Array[count]==v){
flag=true;
break;
}
}
return flag;
}
public void add(Integer v){ // adds the element to the end of the list
int[] temp= new int[size()+1];
int count=0;
temp[size-1]=v;
}
public int size(){ //gets the size of the list
return Array.length;
}
this is my interface
public interface MySet<Value> {
boolean isIn(Integer v);
void add(Integer v);
void remove(Integer v);
MySet union(MySet s);
MySet intersect(MySet s);
MySet difference(MySet s);
int size();
void printSet();
}
thanks, would appreciate any comments and m new to programming so I know there are a lot of mistakes lol :)
Edited by: haraminoI on Mar 24, 2009 11:08 AM
Edited by: haraminoI on Mar 24, 2009 11:09 AM
Edited by: haraminoI on Mar 24, 2009 11:11 AM
Edited by: haraminoI on Mar 24, 2009 11:12 AM
Edited by: haraminoI on Mar 24, 2009 11:14 AM