mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-10-05 21:22:39 +02:00
It's long surpassed the single-responsibility library it once was, and is as such out of place in its original location, and fits better among the function-type modules.
41 lines
864 B
Java
41 lines
864 B
Java
package nu.marginalia.keyword;
|
|
|
|
import gnu.trove.list.TIntList;
|
|
import gnu.trove.list.array.TIntArrayList;
|
|
import nu.marginalia.language.model.DocumentSentence;
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
import java.util.List;
|
|
|
|
public record LinkTexts(
|
|
List<DocumentSentence> linkTexts,
|
|
TIntList counts
|
|
) {
|
|
public LinkTexts() {
|
|
this(List.of(), new TIntArrayList());
|
|
}
|
|
|
|
public int length() {
|
|
return linkTexts.size();
|
|
}
|
|
|
|
@NotNull
|
|
public LinkTexts.Iter iterator() {
|
|
return new Iter();
|
|
}
|
|
|
|
public class Iter {
|
|
private int pos = -1;
|
|
|
|
public boolean next() {
|
|
return ++pos < length();
|
|
}
|
|
public int count() {
|
|
return counts.get(pos);
|
|
}
|
|
public DocumentSentence sentence() {
|
|
return linkTexts.get(pos);
|
|
}
|
|
}
|
|
}
|