| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package net.sf.saxon.z; |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
public class IntUniversalSet implements IntSet { |
| 14 |
|
| 15 |
private static IntUniversalSet THE_INSTANCE = new IntUniversalSet(); |
| 16 |
|
| 17 |
public static IntUniversalSet getInstance() { |
| 18 |
return THE_INSTANCE; |
| 19 |
} |
| 20 |
|
| 21 |
|
| 22 |
private IntUniversalSet() { |
| 23 |
|
| 24 |
} |
| 25 |
|
| 26 |
public IntSet copy() { |
| 27 |
return this; |
| 28 |
} |
| 29 |
|
| 30 |
public IntSet mutableCopy() { |
| 31 |
return new IntComplementSet(new IntHashSet()); |
| 32 |
} |
| 33 |
|
| 34 |
public void clear() { |
| 35 |
throw new UnsupportedOperationException("IntUniversalSet is immutable"); |
| 36 |
} |
| 37 |
|
| 38 |
public int size() { |
| 39 |
return Integer.MAX_VALUE; |
| 40 |
} |
| 41 |
|
| 42 |
public boolean isEmpty() { |
| 43 |
return false; |
| 44 |
} |
| 45 |
|
| 46 |
public boolean contains(int value) { |
| 47 |
return true; |
| 48 |
} |
| 49 |
|
| 50 |
public boolean remove(int value) { |
| 51 |
throw new UnsupportedOperationException("IntUniversalSet is immutable"); |
| 52 |
} |
| 53 |
|
| 54 |
public boolean add(int value) { |
| 55 |
throw new UnsupportedOperationException("IntUniversalSet is immutable"); |
| 56 |
} |
| 57 |
|
| 58 |
public IntIterator iterator() { |
| 59 |
throw new UnsupportedOperationException("Cannot enumerate an infinite set"); |
| 60 |
} |
| 61 |
|
| 62 |
public IntSet union(IntSet other) { |
| 63 |
return this; |
| 64 |
} |
| 65 |
|
| 66 |
public IntSet intersect(IntSet other) { |
| 67 |
return other.copy(); |
| 68 |
} |
| 69 |
|
| 70 |
public IntSet except(IntSet other) { |
| 71 |
if (other instanceof IntUniversalSet) { |
| 72 |
return IntEmptySet.getInstance(); |
| 73 |
} else { |
| 74 |
return new IntComplementSet(other.copy()); |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
public boolean containsAll( IntSet other) { |
| 79 |
return true; |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
|