riordinato alcuni package e creato una prima implementazione di set e mergetemplate

This commit is contained in:
2014-05-17 21:19:18 +02:00
parent 867a7c1a53
commit 4dab60c3fa
10 changed files with 254 additions and 9 deletions

140
set/OrderedListSet.java Normal file
View File

@@ -0,0 +1,140 @@
package set;
import position.NodePositionList;
import position.PositionList;
import utility.DefaultComparator;
import utility.merge.MergeTemplate;
import java.util.Comparator;
/**
* Created with xgiovio.macbookair.
* User: xgiovio
* Date: 14/05/14
* Time: 14:23
*/
public class OrderedListSet <E> implements Set<E> {
private Comparator<E> c;
private PositionList<E> L;
OrderedListSet() {
L = new NodePositionList<E>();
c = new DefaultComparator();
}
OrderedListSet(Comparator<E> in_c) {
L = new NodePositionList<E>();
c = in_c;
}
@Override
public int size() {
return L.size();
}
@Override
public boolean isEmpty() {
return L.isEmpty();
}
@Override
public Set<E> union(Set<E> B) {
new MergeUnion<E>(this.L, ,c);
}
@Override
public Set<E> intersect(Set<E> B) {
return null;
}
@Override
public Set<E> subtract(Set<E> B) {
return null;
}
//////////////////////// inner class override methods from merge template /////
protected class MergeUnion<E> extends MergeTemplate<E>{
public MergeUnion (PositionList<E> A , PositionList<E> B, DefaultComparator<E> c){
super(A,B,c);
}
@Override
protected void aIsLess(E a) {
}
@Override
protected void bIsLess(E b) {
}
@Override
protected void bothAreEqual(E a, E b) {
}
}
protected class MergeIntersect<E> extends MergeTemplate<E>{
public MergeIntersect (PositionList<E> A , PositionList<E> B, DefaultComparator<E> c){
super(A,B,c);
}
@Override
protected void aIsLess(E a) {
}
@Override
protected void bIsLess(E b) {
}
@Override
protected void bothAreEqual(E a, E b) {
}
}
protected class MergeSubtract<E> extends MergeTemplate<E>{
public MergeSubtract (PositionList<E> A , PositionList<E> B, DefaultComparator<E> c){
super(A,B,c);
}
@Override
protected void aIsLess(E a) {
}
@Override
protected void bIsLess(E b) {
}
@Override
protected void bothAreEqual(E a, E b) {
}
}
}

25
set/Set.java Normal file
View File

@@ -0,0 +1,25 @@
package set;
/**
* Created with xgiovio.macbookair.
* User: xgiovio
* Date: 14/05/14
* Time: 14:18
*/
public interface Set<E> {
// Restituisce il numero degli elementi nellinsieme
public int size();
// Restituisce true se linsieme è vuoto
public boolean isEmpty();
// Rimpiazza this con lunione di this e B
public Set<E> union(Set<E> B) ;
// Rimpiazza this con lintersezione di this e B
public Set<E> intersect(Set<E> B) ;
// Rimpiazza this con la differenza di this e B
public Set <E>subtract(Set <E> B) ;
}