1 package cz.cuni.amis.utils.heap;
2
3 import java.util.Collection;
4 import java.util.Comparator;
5 import java.util.Iterator;
6 import java.util.Set;
7
8 import cz.cuni.amis.utils.NullCheck;
9
10
11
12
13
14
15
16
17 public class ImmutableHeap<NODE> implements IHeap<NODE> {
18
19 private IHeap<NODE> heap;
20
21 public ImmutableHeap(IHeap<NODE> heap) {
22 this.heap = heap;
23 NullCheck.check(this.heap, "heap");
24 }
25
26 @Override
27 public boolean deleteMin() {
28 throw new UnsupportedOperationException("Immutable heap!");
29 }
30
31 @Override
32 public boolean decreaseKey(NODE arg0) {
33 throw new UnsupportedOperationException("Immutable heap!");
34 }
35
36 @Override
37 public boolean add(NODE arg0) {
38 throw new UnsupportedOperationException("Immutable heap!");
39 }
40
41 @Override
42 public boolean addAll(Collection arg0) {
43 throw new UnsupportedOperationException("Immutable heap!");
44 }
45
46 @Override
47 public boolean addAll(NODE[] arg0) {
48 throw new UnsupportedOperationException("Immutable heap!");
49 }
50
51 @Override
52 public void clear() {
53 throw new UnsupportedOperationException("Immutable heap!");
54 }
55
56 @Override
57 public boolean changedKey(NODE node) {
58 throw new UnsupportedOperationException("Immutable heap!");
59 }
60
61 @Override
62 public boolean containsAll(Object[] items) {
63 return heap.containsAll(items);
64 }
65
66 @Override
67 public boolean empty() {
68 return heap.empty();
69 }
70
71 @Override
72 public Comparator<NODE> getComparator() {
73 return heap.getComparator();
74 }
75
76 @Override
77 public NODE getMin() {
78 return heap.getMin();
79 }
80
81 @Override
82 public boolean increaseKey(NODE node) {
83 throw new UnsupportedOperationException("Immutable heap!");
84 }
85
86 @Override
87 public Set<NODE> toSet() {
88 return heap.toSet();
89 }
90
91 @Override
92 public boolean contains(Object o) {
93 return heap.contains(o);
94 }
95
96 @Override
97 public boolean containsAll(Collection<?> c) {
98 return heap.containsAll(c);
99 }
100
101 @Override
102 public boolean isEmpty() {
103 return heap.isEmpty();
104 }
105
106 @Override
107 public Iterator<NODE> iterator() {
108 return new HeapImmutableIterator<NODE>(heap.iterator());
109 }
110
111 @Override
112 public boolean remove(Object o) {
113 throw new UnsupportedOperationException("Immutable heap!");
114 }
115
116 @Override
117 public boolean removeAll(Collection<?> c) {
118 throw new UnsupportedOperationException("Immutable heap!");
119 }
120
121 @Override
122 public boolean retainAll(Collection<?> c) {
123 throw new UnsupportedOperationException("Immutable heap!");
124 }
125
126 @Override
127 public int size() {
128 return heap.size();
129 }
130
131 @Override
132 public Object[] toArray() {
133 return heap.toArray();
134 }
135
136 @Override
137 public <T> T[] toArray(T[] a) {
138 return heap.toArray(a);
139 }
140
141 }