TheAlgorithms/Java
All Algorithms implemented in Java
Java★ 67,107+51 that day#8 on trending
B70.2/100
Duplication54
7.7% in java, docker, pythonDead coden/a
the languages dead code reads are under 5% of the codeComplexity92
6.1% The score is jscpd's own --health model: markup, data and text left out, tests kept. The numbers below are the trending scan's.
5.48%duplicated code · 4,854 of 88,511 lines
457clones in code
841code files of 1,652 scanned
7.49%duplicated over all files · 1,191 clones
Most complex files
- src/main/java/com/thealgorithms/maths/MathBuilder.java106 cx
- src/main/java/com/thealgorithms/geometry/BentleyOttmann.java98 cx
- src/main/java/com/thealgorithms/streaming/UnscentedKalmanFilter.java85 cx
- src/main/java/com/thealgorithms/datastructures/lists/SinglyLinkedList.java80 cx
- src/main/java/com/thealgorithms/datastructures/trees/BTree.java79 cx
- src/main/java/com/thealgorithms/streaming/TDigest.java75 cx
- src/main/java/com/thealgorithms/datastructures/trees/KDTree.java68 cx
- src/main/java/com/thealgorithms/datastructures/trees/RedBlackBST.java67 cx
- src/main/java/com/thealgorithms/conversions/WordsToNumber.java66 cx
- src/main/java/com/thealgorithms/graph/HierholzerEulerianPath.java60 cx
Dead code 0% unused · 0 findings
No dead code found — everything here is reachable.
The code number leaves out tests, fixtures, docs, examples, data files, styles, translations and vendored code.
Largest clones in the code
- 87 lines in 2 placesjava1,552 tokenssrc/main/java/com/thealgorithms/datastructures/caches/FIFOCache.java:242–328src/main/java/com/thealgorithms/datastructures/caches/LIFOCache.java:255–341
242} 243 244/** 245 * Notifies the eviction listener, if one is registered, that a key-value pair has been evicted. 246 * 247 * <p>If the {@code evictionListener} is not {@code null}, it is invoked with the provided key 248 * and value. Any exceptions thrown by the listener are caught and logged to standard error, 249 * preventing them from disrupting cache operations. 250 * 251 * @param key the key that was evictedFirst 10 of 87 lines.
- 19 lines in 3 placesjava615 tokenssrc/main/java/com/thealgorithms/datastructures/caches/FIFOCache.java:155–173src/main/java/com/thealgorithms/datastructures/caches/LIFOCache.java:161–179src/main/java/com/thealgorithms/datastructures/caches/RRCache.java:154–172
155 * If the key does not exist and the cache is full, the oldest entry is evicted to make space. 156 * Expired entries are also cleaned up prior to any eviction. The eviction listener 157 * is notified when an entry gets evicted. 158 * 159 * @param key the key to associate with the cached value; must not be {@code null} 160 * @param value the value to be cached; must not be {@code null} 161 * @param ttlMillis the time-to-live for this entry in milliseconds; must be >= 0 162 * @throws IllegalArgumentException if {@code key} or {@code value} is {@code null}, or if {@code ttlMillis} is negative 163 */ 164public void put(K key, V value, long ttlMillis) {First 10 of 19 lines.
- 46 lines in 2 placesjava1,101 tokenssrc/main/java/com/thealgorithms/datastructures/caches/FIFOCache.java:481–526src/main/java/com/thealgorithms/datastructures/caches/LIFOCache.java:495–540
481private EvictionStrategy<K, V> evictionStrategy = new FIFOCache.ImmediateEvictionStrategy<>(); 482/** 483 * Creates a new {@code Builder} with the specified cache capacity. 484 * 485 * @param capacity the maximum number of entries the cache can hold; must be > 0 486 * @throws IllegalArgumentException if {@code capacity} is less than or equal to 0 487 */ 488public Builder(int capacity) { 489 if (capacity <= 0) { 490 throw new IllegalArgumentException("Capacity must be > 0");First 10 of 46 lines.
7 more
- 59 lines in 2 placesjava999 tokens
- 7 lines in 3 placesjava474 tokens
- 10 lines in 3 placesjava473 tokens
- 19 lines in 3 placesjava378 tokens
- 30 lines in 2 placesjava749 tokens
- 26 lines in 2 placesjava712 tokens
- 50 lines in 2 placesjava682 tokens
Largest clones over all files, tests and data included
- 87 lines in 2 placesjava1,552 tokenssrc/main/java/com/thealgorithms/datastructures/caches/FIFOCache.java:242–328src/main/java/com/thealgorithms/datastructures/caches/LIFOCache.java:255–341
242} 243 244/** 245 * Notifies the eviction listener, if one is registered, that a key-value pair has been evicted. 246 * 247 * <p>If the {@code evictionListener} is not {@code null}, it is invoked with the provided key 248 * and value. Any exceptions thrown by the listener are caught and logged to standard error, 249 * preventing them from disrupting cache operations. 250 * 251 * @param key the key that was evictedFirst 10 of 87 lines.
- 19 lines in 3 placesjava615 tokenssrc/main/java/com/thealgorithms/datastructures/caches/FIFOCache.java:155–173src/main/java/com/thealgorithms/datastructures/caches/LIFOCache.java:161–179src/main/java/com/thealgorithms/datastructures/caches/RRCache.java:154–172
155 * If the key does not exist and the cache is full, the oldest entry is evicted to make space. 156 * Expired entries are also cleaned up prior to any eviction. The eviction listener 157 * is notified when an entry gets evicted. 158 * 159 * @param key the key to associate with the cached value; must not be {@code null} 160 * @param value the value to be cached; must not be {@code null} 161 * @param ttlMillis the time-to-live for this entry in milliseconds; must be >= 0 162 * @throws IllegalArgumentException if {@code key} or {@code value} is {@code null}, or if {@code ttlMillis} is negative 163 */ 164public void put(K key, V value, long ttlMillis) {First 10 of 19 lines.
- 46 lines in 2 placesjava1,101 tokenssrc/main/java/com/thealgorithms/datastructures/caches/FIFOCache.java:481–526src/main/java/com/thealgorithms/datastructures/caches/LIFOCache.java:495–540
481private EvictionStrategy<K, V> evictionStrategy = new FIFOCache.ImmediateEvictionStrategy<>(); 482/** 483 * Creates a new {@code Builder} with the specified cache capacity. 484 * 485 * @param capacity the maximum number of entries the cache can hold; must be > 0 486 * @throws IllegalArgumentException if {@code capacity} is less than or equal to 0 487 */ 488public Builder(int capacity) { 489 if (capacity <= 0) { 490 throw new IllegalArgumentException("Capacity must be > 0");First 10 of 46 lines.
- 59 lines in 2 placesjava999 tokens
- 7 lines in 3 placesjava474 tokens
By format, code only
| Format | Files | Lines | Clones | Duplicated lines | Duplication |
|---|---|---|---|---|---|
| java | 840 | 88,484 | 457 | 4,854 | 5.49% |
| python | 1 | 27 | 0 | 0 | 0% |
By format, all files
| Format | Files | Lines | Clones | Duplicated lines | Duplication |
|---|---|---|---|---|---|
| java | 1,617 | 151,197 | 1,191 | 11,595 | 7.67% |
| markdown | 12 | 2,222 | 0 | 0 | 0% |
| markup | 4 | 565 | 0 | 0 | 0% |
| yaml | 12 | 533 | 0 | 0 | 0% |
| properties | 1 | 111 | 0 | 0 | 0% |
| docker | 2 | 47 | 0 | 0 | 0% |
| json | 1 | 47 | 0 | 0 | 0% |
| text | 2 | 42 | 0 | 0 | 0% |
| python | 1 | 27 | 0 | 0 | 0% |
Trending appearances
| Day | Rank | Stars | Files | Lines | Clones | All files | Code | Health | Commit |
|---|---|---|---|---|---|---|---|---|---|
| Nov 12, 2026 | #8 | 67,107 (+51) | 1,652 | 154,791 | 1,191 | 7.49% | 5.48% | B 70.2 | c468089 |
Want this for your own project? Install jscpd and run jscpd ., or measure it the way the baselines were measured.