Skip to content

Commit f385cb7

Browse files
committed
Add Javadocs, reduce visibility of a few annotations, rename OptimizationObjectives, rename SmoothieMapBuilder.minExpectedSize to minPeakSize, add signing plugin to gradle build
1 parent 77917d8 commit f385cb7

File tree

15 files changed

+495
-121
lines changed

15 files changed

+495
-121
lines changed

build.gradle

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ buildscript {
1313
plugins {
1414
id 'java-library'
1515
id 'maven-publish'
16+
id 'signing'
1617

1718
id 'checkstyle'
1819
id 'de.thetaphi.forbiddenapis' version '2.6'
@@ -200,6 +201,24 @@ task sourcesJar(type: Jar, dependsOn: classes) {
200201
from sourceSets.main.allSource
201202
}
202203

204+
javadoc {
205+
options {
206+
links 'http://docs.oracle.com/javase/8/docs/api/'
207+
tags = [
208+
'apiNote:a:API Note:',
209+
'implSpec:a:Implementation Requirements:',
210+
'implNote:a:Implementation Note:',
211+
'param',
212+
'return',
213+
'throws',
214+
'since',
215+
'version',
216+
'serialData',
217+
'see'
218+
]
219+
}
220+
}
221+
203222
task javadocJar(type: Jar) {
204223
classifier 'javadoc'
205224
from javadoc

src/main/java/io/timeandspace/collect/Equivalence.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* A strategy for determining whether two instances are considered equivalent.
2727
*
2828
* <p>This class is inspired and very similar to
29-
* <a href="http://docs.guava-libraries.googlecode.com/git-history/release/javadoc/com/google/common/base/Equivalence.html">
29+
* <a href="https://guava.dev/releases/27.1-jre/api/docs/com/google/common/base/Equivalence.html">
3030
* Guava's {@code Equivalence}</a>, with one notable difference: this {@code Equivalence} forces
3131
* the actual implementation to override {@link #equals(Object)} and {@link #hashCode()}. Notice
3232
* these are {@code Equivalence}'s own equals and hashCode, not the strategy

src/main/java/io/timeandspace/collect/map/KeyValue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
/**
2020
* Defines a simple key-value pair. The difference between this interface and {@link
21-
* java.util.Map.Entry} is that this interface doesn't specify {@link #equals} and {@link #hashCode}
21+
* java.util.Map.Entry} is that this interface doesn't specify {@link Object#equals} and {@link Object#hashCode}
2222
* and whether they should depend on key's and value's equivalence and hash codes at all.
2323
* KeyValue also doesn't have an equivalent of {@link java.util.Map.Entry}'s {@code setValue()}
2424
* method.

src/main/java/io/timeandspace/collect/map/ObjObjMap.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,25 @@
3131
import java.util.function.BiPredicate;
3232
import java.util.function.Function;
3333

34+
/**
35+
* An extension of the {@link Map} interface. Notable additions and differences:
36+
* <ul>
37+
* <li>{@code null} keys and values are explicitly prohibited. Attempt to query nulls via
38+
* methods like {@link #get(Object)} or {@link #containsValue(Object)} are specified to throw
39+
* a {@link NullPointerException} as well. In the {@link Map} interface, both aspects (rejecting
40+
* nulls for storage and rejecting null queries) are optional.</li>
41+
* <li>The notion of non-standard key and value equivalences is formalized in {@link
42+
* #keyEquivalence()} and {@link #valueEquivalence()} methods.</li>
43+
* <li>{@link #sizeAsLong()} returns the exact size of the map if it exceeds {@link
44+
* Integer#MAX_VALUE}.</li>
45+
* <li>{@link #containsEntry(Object, Object)}</li>
46+
* <li>{@link #getInternalKey} allows to use the map as the vehicle for key interning.</li>
47+
* <li>{@link #forEachWhile(BiPredicate)}</li>
48+
* <li>{@link #removeIf(BiPredicate)}</li>
49+
* </ul>
50+
* @param <K> the type of keys maintained by this map
51+
* @param <V> the type of mapped values
52+
*/
3453
public interface ObjObjMap<K, V> extends Map<K, V> {
3554

3655
/**
@@ -117,8 +136,10 @@ default long mappingCount() {
117136
* <p>This method could be used to deduplicate objects in the application, to reduce the memory
118137
* footprint and make the application to conform to the "most objects die young" hypothesis that
119138
* most GC algorithms are optimized for. This method is functionally similar to {@link
120-
* String#intern()} and Guava's Interner, but allows to piggy-back a map data structure which
121-
* may already exist in an application.
139+
* String#intern()} and Guava's <a
140+
* href="https://guava.dev/releases/28.0-jre/api/docs/com/google/common/collect/Interner.html">
141+
* Interner</a>, but allows to piggy-back a map data structure which may already exist in an
142+
* application.
122143
*
123144
* <p>{@link #keySet()}.{@link ObjSet#getInternal(Object) getInternal(key)} delegates to this
124145
* method.

src/main/java/io/timeandspace/collect/map/package-info.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515
*/
1616

1717

18-
/**
19-
*
20-
*/
2118
@CheckReturnValue
22-
@DefaultQualifier(NonNull.class)
19+
@DefaultQualifier(value = NonNull.class, locations = TypeUseLocation.ALL)
2320
package io.timeandspace.collect.map;
2421

2522
import com.google.errorprone.annotations.CheckReturnValue;
2623
import org.checkerframework.checker.nullness.qual.NonNull;
27-
import org.checkerframework.framework.qual.DefaultQualifier;
24+
import org.checkerframework.framework.qual.DefaultQualifier;
25+
import org.checkerframework.framework.qual.TypeUseLocation;

src/main/java/io/timeandspace/smoothie/BarelyCalled.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@
2929
*/
3030
@Target(ElementType.METHOD)
3131
@Retention(RetentionPolicy.SOURCE)
32-
public @interface BarelyCalled {
32+
@interface BarelyCalled {
3333
}

src/main/java/io/timeandspace/smoothie/CompileTimeConstant.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
*/
3333
@Retention(RetentionPolicy.SOURCE)
3434
@Target(ElementType.FIELD)
35-
public @interface CompileTimeConstant {
35+
@interface CompileTimeConstant {
3636
}

src/main/java/io/timeandspace/smoothie/OptimizationObjective.java

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,37 @@
1616

1717
package io.timeandspace.smoothie;
1818

19+
/**
20+
* OptimizationObjectives correspond to {@link SmoothieMap}'s <i>modes of operation</i> which could
21+
* be configured via {@link SmoothieMapBuilder#optimizeFor} method.
22+
*/
1923
public enum OptimizationObjective {
20-
ALLOCATION_RATE,
21-
MEMORY_FOOTPRINT
24+
/**
25+
* In the "low-garbage" mode, {@link SmoothieMap} generates very little garbage (that is, heap
26+
* objects that later become unreachable and need to be swept by the GC), either during the
27+
* growth phase or the shrinkage phase (when a map reduces in size after the peak growth).
28+
*
29+
* @implSpec Configuring {@link SmoothieMapBuilder#optimizeFor
30+
* smoothieMapBuilder.optimizeFor(LOW_GARBAGE)} includes <i>not</i> {@linkplain
31+
* SmoothieMapBuilder#allocateIntermediateCapacitySegments(boolean) allocating
32+
* intermediate-capacity segments} (nor, consequently, {@linkplain
33+
* SmoothieMapBuilder#splitBetweenTwoNewSegments(boolean) splitting between two new segments})
34+
* and <i>not</i> {@linkplain SmoothieMapBuilder#doShrink(boolean) shrinking SmoothieMap
35+
* automatically} when it reduces in size.
36+
*/
37+
LOW_GARBAGE,
38+
39+
/**
40+
* In the "footprint" mode, {@link SmoothieMap} has the lowest possible footprint per entry and
41+
* the lowest variability of the footprint at different SmoothieMap's sizes.
42+
*
43+
* @implSpec Configuring {@link SmoothieMapBuilder#optimizeFor
44+
* smoothieMapBuilder.optimizeFor(FOOTPRINT)} includes {@linkplain
45+
* SmoothieMapBuilder#allocateIntermediateCapacitySegments(boolean) allocating
46+
* intermediate-capacity segments}, {@linkplain
47+
* SmoothieMapBuilder#splitBetweenTwoNewSegments(boolean) splitting between two new segments},
48+
* and {@linkplain SmoothieMapBuilder#doShrink(boolean) automatic shrinking} when a SmoothieMap
49+
* reduces in size.
50+
*/
51+
FOOTPRINT
2252
}

src/main/java/io/timeandspace/smoothie/RarelyCalledAmortizedPerSegment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@
2828
*
2929
* @see AmortizedPerSegment
3030
*/
31-
public @interface RarelyCalledAmortizedPerSegment {
31+
@interface RarelyCalledAmortizedPerSegment {
3232
}

src/main/java/io/timeandspace/smoothie/SegmentClasses.java

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)