File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
main/java/dataStructures/hashSet/openAddressing
test/java/dataStructures/hashSet/openAddressing Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -318,7 +318,7 @@ private boolean isLoadFactorExceeded() {
318
318
return this .size () >= this .capacity () * LOAD_FACTOR ;
319
319
}
320
320
321
- private static < T > T tombstone () {
321
+ public T tombstone () {
322
322
// It is safe to cast Tombstone to T, because methods retrieving elements (HashSet::get) from the HashSet
323
323
// should, and will check whether the item is a Tombstone object, returning null in-place of the Tombstone.
324
324
@ SuppressWarnings ("unchecked" )
Original file line number Diff line number Diff line change 2
2
3
3
import static org .junit .Assert .assertEquals ;
4
4
import static org .junit .Assert .assertFalse ;
5
+ import static org .junit .Assert .assertNotEquals ;
5
6
import static org .junit .Assert .assertTrue ;
6
7
7
8
import java .util .List ;
@@ -137,4 +138,20 @@ public void testAdd_afterRemove() {
137
138
138
139
assertEquals (expectedList , actualList );
139
140
}
141
+
142
+ @ Test
143
+ public void testTombstoneEquals () {
144
+ HashSet <Integer > integerHashSet = new HashSet <>();
145
+ assertNotEquals (Integer .valueOf (5 ), integerHashSet .tombstone ());
146
+ assertNotEquals (null , integerHashSet .tombstone ());
147
+
148
+ HashSet <Boolean > booleanHashSet = new HashSet <>();
149
+ assertNotEquals (Boolean .TRUE , booleanHashSet .tombstone ());
150
+ assertNotEquals (Boolean .FALSE , booleanHashSet .tombstone ());
151
+ assertNotEquals (null , booleanHashSet .tombstone ());
152
+
153
+ HashSet <Object > objectHashSet = new HashSet <>();
154
+ assertNotEquals (new Object (), objectHashSet .tombstone ());
155
+ assertNotEquals (null , objectHashSet .tombstone ());
156
+ }
140
157
}
You can’t perform that action at this time.
0 commit comments