iniziato la prima struttura arraylist
This commit is contained in:
64
arraylist/ArrayIndexList.java
Normal file
64
arraylist/ArrayIndexList.java
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
package arraylist;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created with xgiovio.macbookair.
|
||||||
|
* User: xgiovio
|
||||||
|
* Date: 24/03/14
|
||||||
|
* Time: 14:31
|
||||||
|
*/
|
||||||
|
public class ArrayIndexList<E> implements IndexList<E> {
|
||||||
|
|
||||||
|
|
||||||
|
public ArrayIndexList(){
|
||||||
|
indexlist = (E[])new Object [def_capacity];
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayIndexList( int in_n){
|
||||||
|
indexlist = (E[])new Object [in_n];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public E remove(int i) throws IndexOutOfBoundsException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void add(int i, E e) throws IndexOutOfBoundsException {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public E set(int i, E e) throws IndexOutOfBoundsException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public E get(int i) throws IndexOutOfBoundsException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty() {
|
||||||
|
if (size() == 0){
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int size() {
|
||||||
|
return nelements;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return super.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private E[] indexlist;
|
||||||
|
private int def_capacity = 100;
|
||||||
|
private int nelements = 0;
|
||||||
|
|
||||||
|
}
|
||||||
20
arraylist/IndexList.java
Normal file
20
arraylist/IndexList.java
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package arraylist;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created with xgiovio.macbookair.
|
||||||
|
* User: xgiovio
|
||||||
|
* Date: 24/03/14
|
||||||
|
* Time: 14:29
|
||||||
|
*/
|
||||||
|
public interface IndexList<E> {
|
||||||
|
|
||||||
|
|
||||||
|
public E remove(int i) throws IndexOutOfBoundsException;
|
||||||
|
public void add(int i, E e) throws IndexOutOfBoundsException;
|
||||||
|
public E set(int i, E e) throws IndexOutOfBoundsException;
|
||||||
|
public E get(int i) throws IndexOutOfBoundsException;
|
||||||
|
public boolean isEmpty();
|
||||||
|
public int size();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user