Debian Codegraph @

net/sf/saxon/z/IntEmptySet.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 no integers
12 */
13 public class IntEmptySet implements IntSet {
14
15 private static IntEmptySet THE_INSTANCE = new IntEmptySet();
16
17 public static IntEmptySet getInstance() {
18 return THE_INSTANCE;
19 }
20
21
22 private IntEmptySet() {
23 // no action
24 }
25
26 public IntSet copy() {
27 return this;
28 }
29
30 public IntSet mutableCopy() {
31 return new IntHashSet();
32 }
33
34 public void clear() {
35 throw new UnsupportedOperationException("IntEmptySet is immutable");
36 }
37
38 public int size() {
39 return 0;
40 }
41
42 public boolean isEmpty() {
43 return true;
44 }
45
46 public boolean contains(int value) {
47 return false;
48 }
49
50 public boolean remove(int value) {
51 throw new UnsupportedOperationException("IntEmptySet is immutable");
52 }
53
54 public boolean add(int value) {
55 throw new UnsupportedOperationException("IntEmptySet is immutable");
56 }
57
58 public IntIterator iterator() {
59 return new IntIterator() {
60 public boolean hasNext() {
61 return false;
62 }
63
64 public int next() {
65 return Integer.MIN_VALUE;
66 }
67 };
68 }
69
70 public IntSet union(IntSet other) {
71 return other.copy();
72 }
73
74 public IntSet intersect(IntSet other) {
75 return this;
76 }
77
78 public IntSet except(IntSet other) {
79 return this;
80 }
81
82 public boolean containsAll(/*@NotNull*/ IntSet other) {
83 return other.isEmpty();
84 }
85 }
86
87
88