riordinato alcuni package e creato una prima implementazione di set e mergetemplate
This commit is contained in:
140
set/OrderedListSet.java
Normal file
140
set/OrderedListSet.java
Normal 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
25
set/Set.java
Normal 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 nell’insieme
|
||||
public int size();
|
||||
|
||||
// Restituisce true se l’insieme è vuoto
|
||||
public boolean isEmpty();
|
||||
|
||||
// Rimpiazza this con l’unione di this e B
|
||||
public Set<E> union(Set<E> B) ;
|
||||
|
||||
// Rimpiazza this con l’intersezione 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) ;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user