diff --git a/src/main/java/com/thealgorithms/datastructures/hashset/HashSet.java b/src/main/java/com/thealgorithms/datastructures/hashset/HashSet.java new file mode 100644 index 000000000000..7e97c7e56678 --- /dev/null +++ b/src/main/java/com/thealgorithms/datastructures/hashset/HashSet.java @@ -0,0 +1,65 @@ + +package com.thealgorithms.datastructures.hashset; + +/** + * Example usage: + *
+ * HashSet set = new HashSet(); + * set.add(5); + * set.add(10); + * System.out.println(set.contains(5)); // true + * set.remove(5); + * System.out.println(set.contains(5)); // false + *+ */ + +import java.util.LinkedList; + +/** + * A simple implementation of a HashSet for integers using separate chaining. + * + * See: https://en.wikipedia.org/wiki/Hash_table + */ +public class HashSet { + private static final int INITIAL_CAPACITY = 16; + private LinkedList