Debian Codegraph @

net/sf/saxon/z/IntUniversalSet.java

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2018 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7
8 package net.sf.saxon.z;
9
10 /**
11 * An immutable integer set containing every integer
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 // no action
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(/*@NotNull*/ IntSet other) {
79 return true;
80 }
81 }
82
83