We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 538fb49 + 3007f2d commit 235471fCopy full SHA for 235471f
src/main/java/com/thealgorithms/datastructures/caches/ARCCache.java
@@ -27,8 +27,13 @@ public class ARCCache<K, V> {
27
28
/**
29
* This constructor initializes an ARCCache object with the given capacity and initializes other necessary fields
30
+ * @param capacity the initial capacity of the cache
31
+ * @throws IllegalArgumentException if the capacity is negative
32
*/
33
public ARCCache(int capacity) {
34
+ if (capacity < 0) {
35
+ throw new IllegalArgumentException("Capacity cannot be negative");
36
+ }
37
this.cache = new LinkedHashMap<>();
38
this.usageCounts = new LinkedHashMap<>();
39
this.t1Capacity = capacity / 2; // Capacity for the t1 cache
0 commit comments