id int32 0 165k | repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 |
|---|---|---|---|---|---|---|---|---|---|---|---|
21,800 | google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/inject/dagger/Util.java | Util.makeConcreteClassAbstract | static SuggestedFix.Builder makeConcreteClassAbstract(ClassTree classTree, VisitorState state) {
Set<Modifier> flags = EnumSet.noneOf(Modifier.class);
flags.addAll(classTree.getModifiers().getFlags());
boolean wasFinal = flags.remove(FINAL);
boolean wasAbstract = !flags.add(ABSTRACT);
if (classTree... | java | static SuggestedFix.Builder makeConcreteClassAbstract(ClassTree classTree, VisitorState state) {
Set<Modifier> flags = EnumSet.noneOf(Modifier.class);
flags.addAll(classTree.getModifiers().getFlags());
boolean wasFinal = flags.remove(FINAL);
boolean wasAbstract = !flags.add(ABSTRACT);
if (classTree... | [
"static",
"SuggestedFix",
".",
"Builder",
"makeConcreteClassAbstract",
"(",
"ClassTree",
"classTree",
",",
"VisitorState",
"state",
")",
"{",
"Set",
"<",
"Modifier",
">",
"flags",
"=",
"EnumSet",
".",
"noneOf",
"(",
"Modifier",
".",
"class",
")",
";",
"flags",... | Returns a fix that changes a concrete class to an abstract class.
<ul>
<li>Removes {@code final} if it was there.
<li>Adds {@code abstract} if it wasn't there.
<li>Adds a private empty constructor if the class was {@code final} and had only a default
constructor.
</ul> | [
"Returns",
"a",
"fix",
"that",
"changes",
"a",
"concrete",
"class",
"to",
"an",
"abstract",
"class",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/inject/dagger/Util.java#L164-L190 |
21,801 | google/error-prone | check_api/src/main/java/com/google/errorprone/fixes/SuggestedFixes.java | SuggestedFixes.addModifiers | public static Optional<SuggestedFix> addModifiers(
Tree tree, VisitorState state, Modifier... modifiers) {
ModifiersTree originalModifiers = getModifiers(tree);
if (originalModifiers == null) {
return Optional.empty();
}
return addModifiers(tree, originalModifiers, state, new TreeSet<>(Array... | java | public static Optional<SuggestedFix> addModifiers(
Tree tree, VisitorState state, Modifier... modifiers) {
ModifiersTree originalModifiers = getModifiers(tree);
if (originalModifiers == null) {
return Optional.empty();
}
return addModifiers(tree, originalModifiers, state, new TreeSet<>(Array... | [
"public",
"static",
"Optional",
"<",
"SuggestedFix",
">",
"addModifiers",
"(",
"Tree",
"tree",
",",
"VisitorState",
"state",
",",
"Modifier",
"...",
"modifiers",
")",
"{",
"ModifiersTree",
"originalModifiers",
"=",
"getModifiers",
"(",
"tree",
")",
";",
"if",
... | Adds modifiers to the given class, method, or field declaration. | [
"Adds",
"modifiers",
"to",
"the",
"given",
"class",
"method",
"or",
"field",
"declaration",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/fixes/SuggestedFixes.java#L157-L164 |
21,802 | google/error-prone | check_api/src/main/java/com/google/errorprone/fixes/SuggestedFixes.java | SuggestedFixes.removeModifiers | public static Optional<SuggestedFix> removeModifiers(
Tree tree, VisitorState state, Modifier... modifiers) {
Set<Modifier> toRemove = ImmutableSet.copyOf(modifiers);
ModifiersTree originalModifiers = getModifiers(tree);
if (originalModifiers == null) {
return Optional.empty();
}
return ... | java | public static Optional<SuggestedFix> removeModifiers(
Tree tree, VisitorState state, Modifier... modifiers) {
Set<Modifier> toRemove = ImmutableSet.copyOf(modifiers);
ModifiersTree originalModifiers = getModifiers(tree);
if (originalModifiers == null) {
return Optional.empty();
}
return ... | [
"public",
"static",
"Optional",
"<",
"SuggestedFix",
">",
"removeModifiers",
"(",
"Tree",
"tree",
",",
"VisitorState",
"state",
",",
"Modifier",
"...",
"modifiers",
")",
"{",
"Set",
"<",
"Modifier",
">",
"toRemove",
"=",
"ImmutableSet",
".",
"copyOf",
"(",
"... | Remove modifiers from the given class, method, or field declaration. | [
"Remove",
"modifiers",
"from",
"the",
"given",
"class",
"method",
"or",
"field",
"declaration",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/fixes/SuggestedFixes.java#L229-L237 |
21,803 | google/error-prone | check_api/src/main/java/com/google/errorprone/fixes/SuggestedFixes.java | SuggestedFixes.qualifyType | public static String qualifyType(VisitorState state, SuggestedFix.Builder fix, TypeMirror type) {
return type.accept(
new SimpleTypeVisitor8<String, SuggestedFix.Builder>() {
@Override
protected String defaultAction(TypeMirror e, Builder builder) {
return e.toString();
... | java | public static String qualifyType(VisitorState state, SuggestedFix.Builder fix, TypeMirror type) {
return type.accept(
new SimpleTypeVisitor8<String, SuggestedFix.Builder>() {
@Override
protected String defaultAction(TypeMirror e, Builder builder) {
return e.toString();
... | [
"public",
"static",
"String",
"qualifyType",
"(",
"VisitorState",
"state",
",",
"SuggestedFix",
".",
"Builder",
"fix",
",",
"TypeMirror",
"type",
")",
"{",
"return",
"type",
".",
"accept",
"(",
"new",
"SimpleTypeVisitor8",
"<",
"String",
",",
"SuggestedFix",
"... | Returns a human-friendly name of the given type for use in fixes. | [
"Returns",
"a",
"human",
"-",
"friendly",
"name",
"of",
"the",
"given",
"type",
"for",
"use",
"in",
"fixes",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/fixes/SuggestedFixes.java#L295-L329 |
21,804 | google/error-prone | check_api/src/main/java/com/google/errorprone/fixes/SuggestedFixes.java | SuggestedFixes.renameMethod | public static SuggestedFix renameMethod(
MethodTree tree, final String replacement, VisitorState state) {
// Search tokens from beginning of method tree to beginning of method body.
int basePos = ((JCTree) tree).getStartPosition();
int endPos =
tree.getBody() != null
? ((JCTree) tr... | java | public static SuggestedFix renameMethod(
MethodTree tree, final String replacement, VisitorState state) {
// Search tokens from beginning of method tree to beginning of method body.
int basePos = ((JCTree) tree).getStartPosition();
int endPos =
tree.getBody() != null
? ((JCTree) tr... | [
"public",
"static",
"SuggestedFix",
"renameMethod",
"(",
"MethodTree",
"tree",
",",
"final",
"String",
"replacement",
",",
"VisitorState",
"state",
")",
"{",
"// Search tokens from beginning of method tree to beginning of method body.",
"int",
"basePos",
"=",
"(",
"(",
"J... | Be warned, only changes method name at the declaration. | [
"Be",
"warned",
"only",
"changes",
"method",
"name",
"at",
"the",
"declaration",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/fixes/SuggestedFixes.java#L466-L488 |
21,805 | google/error-prone | check_api/src/main/java/com/google/errorprone/fixes/SuggestedFixes.java | SuggestedFixes.deleteExceptions | public static Fix deleteExceptions(
MethodTree tree, final VisitorState state, List<ExpressionTree> toDelete) {
List<? extends ExpressionTree> trees = tree.getThrows();
if (toDelete.size() == trees.size()) {
return SuggestedFix.replace(
getThrowsPosition(tree, state) - 1, state.getEndPosit... | java | public static Fix deleteExceptions(
MethodTree tree, final VisitorState state, List<ExpressionTree> toDelete) {
List<? extends ExpressionTree> trees = tree.getThrows();
if (toDelete.size() == trees.size()) {
return SuggestedFix.replace(
getThrowsPosition(tree, state) - 1, state.getEndPosit... | [
"public",
"static",
"Fix",
"deleteExceptions",
"(",
"MethodTree",
"tree",
",",
"final",
"VisitorState",
"state",
",",
"List",
"<",
"ExpressionTree",
">",
"toDelete",
")",
"{",
"List",
"<",
"?",
"extends",
"ExpressionTree",
">",
"trees",
"=",
"tree",
".",
"ge... | Deletes the given exceptions from a method's throws clause. | [
"Deletes",
"the",
"given",
"exceptions",
"from",
"a",
"method",
"s",
"throws",
"clause",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/fixes/SuggestedFixes.java#L509-L532 |
21,806 | google/error-prone | check_api/src/main/java/com/google/errorprone/fixes/SuggestedFixes.java | SuggestedFixes.compilesWithFix | public static boolean compilesWithFix(Fix fix, VisitorState state) {
if (fix.isEmpty()) {
return true;
}
JCCompilationUnit compilationUnit = (JCCompilationUnit) state.getPath().getCompilationUnit();
JavaFileObject modifiedFile = compilationUnit.getSourceFile();
BasicJavacTask javacTask = (Basi... | java | public static boolean compilesWithFix(Fix fix, VisitorState state) {
if (fix.isEmpty()) {
return true;
}
JCCompilationUnit compilationUnit = (JCCompilationUnit) state.getPath().getCompilationUnit();
JavaFileObject modifiedFile = compilationUnit.getSourceFile();
BasicJavacTask javacTask = (Basi... | [
"public",
"static",
"boolean",
"compilesWithFix",
"(",
"Fix",
"fix",
",",
"VisitorState",
"state",
")",
"{",
"if",
"(",
"fix",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"JCCompilationUnit",
"compilationUnit",
"=",
"(",
"JCCompilationUni... | Returns true if the current compilation would succeed with the given fix applied. Note that
calling this method is very expensive as it requires rerunning the entire compile, so it should
be used with restraint. | [
"Returns",
"true",
"if",
"the",
"current",
"compilation",
"would",
"succeed",
"with",
"the",
"given",
"fix",
"applied",
".",
"Note",
"that",
"calling",
"this",
"method",
"is",
"very",
"expensive",
"as",
"it",
"requires",
"rerunning",
"the",
"entire",
"compile"... | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/fixes/SuggestedFixes.java#L773-L841 |
21,807 | google/error-prone | check_api/src/main/java/com/google/errorprone/fixes/SuggestedFixes.java | SuggestedFixes.suggestWhitelistAnnotation | public static Optional<SuggestedFix> suggestWhitelistAnnotation(
String whitelistAnnotation, TreePath where, VisitorState state) {
// TODO(bangert): Support annotations that do not have @Target(CLASS).
if (whitelistAnnotation.equals("com.google.errorprone.annotations.DontSuggestFixes")) {
return Opt... | java | public static Optional<SuggestedFix> suggestWhitelistAnnotation(
String whitelistAnnotation, TreePath where, VisitorState state) {
// TODO(bangert): Support annotations that do not have @Target(CLASS).
if (whitelistAnnotation.equals("com.google.errorprone.annotations.DontSuggestFixes")) {
return Opt... | [
"public",
"static",
"Optional",
"<",
"SuggestedFix",
">",
"suggestWhitelistAnnotation",
"(",
"String",
"whitelistAnnotation",
",",
"TreePath",
"where",
",",
"VisitorState",
"state",
")",
"{",
"// TODO(bangert): Support annotations that do not have @Target(CLASS).",
"if",
"(",... | Create a fix to add a suppression annotation on the surrounding class.
<p>No suggested fix is produced if the suppression annotation cannot be used on classes, i.e.
the annotation has a {@code @Target} but does not include {@code @Target(TYPE)}.
<p>If the suggested annotation is {@code DontSuggestFixes}, return empty... | [
"Create",
"a",
"fix",
"to",
"add",
"a",
"suppression",
"annotation",
"on",
"the",
"surrounding",
"class",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/fixes/SuggestedFixes.java#L926-L956 |
21,808 | google/error-prone | check_api/src/main/java/com/google/errorprone/SuppressionInfo.java | SuppressionInfo.suppressedState | public SuppressedState suppressedState(
Suppressible suppressible, boolean suppressedInGeneratedCode) {
if (inGeneratedCode && suppressedInGeneratedCode) {
return SuppressedState.SUPPRESSED;
}
if (suppressible.supportsSuppressWarnings()
&& !Collections.disjoint(suppressible.allNames(), s... | java | public SuppressedState suppressedState(
Suppressible suppressible, boolean suppressedInGeneratedCode) {
if (inGeneratedCode && suppressedInGeneratedCode) {
return SuppressedState.SUPPRESSED;
}
if (suppressible.supportsSuppressWarnings()
&& !Collections.disjoint(suppressible.allNames(), s... | [
"public",
"SuppressedState",
"suppressedState",
"(",
"Suppressible",
"suppressible",
",",
"boolean",
"suppressedInGeneratedCode",
")",
"{",
"if",
"(",
"inGeneratedCode",
"&&",
"suppressedInGeneratedCode",
")",
"{",
"return",
"SuppressedState",
".",
"SUPPRESSED",
";",
"}... | Returns true if this checker should be considered suppressed given the signals present in this
object.
@param suppressible Holds information about the suppressibilty of a checker
@param suppressedInGeneratedCode true if this checker instance should be considered suppressed
if the signals in this object say we're in ge... | [
"Returns",
"true",
"if",
"this",
"checker",
"should",
"be",
"considered",
"suppressed",
"given",
"the",
"signals",
"present",
"in",
"this",
"object",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/SuppressionInfo.java#L86-L100 |
21,809 | google/error-prone | check_api/src/main/java/com/google/errorprone/predicates/TypePredicates.java | TypePredicates.isExactTypeAny | public static TypePredicate isExactTypeAny(Iterable<String> types) {
return new ExactAny(Iterables.transform(types, GET_TYPE));
} | java | public static TypePredicate isExactTypeAny(Iterable<String> types) {
return new ExactAny(Iterables.transform(types, GET_TYPE));
} | [
"public",
"static",
"TypePredicate",
"isExactTypeAny",
"(",
"Iterable",
"<",
"String",
">",
"types",
")",
"{",
"return",
"new",
"ExactAny",
"(",
"Iterables",
".",
"transform",
"(",
"types",
",",
"GET_TYPE",
")",
")",
";",
"}"
] | Match types that are exactly equal to any of the given types. | [
"Match",
"types",
"that",
"are",
"exactly",
"equal",
"to",
"any",
"of",
"the",
"given",
"types",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/predicates/TypePredicates.java#L63-L65 |
21,810 | google/error-prone | check_api/src/main/java/com/google/errorprone/predicates/TypePredicates.java | TypePredicates.isDescendantOfAny | public static TypePredicate isDescendantOfAny(Iterable<String> types) {
return new DescendantOfAny(Iterables.transform(types, GET_TYPE));
} | java | public static TypePredicate isDescendantOfAny(Iterable<String> types) {
return new DescendantOfAny(Iterables.transform(types, GET_TYPE));
} | [
"public",
"static",
"TypePredicate",
"isDescendantOfAny",
"(",
"Iterable",
"<",
"String",
">",
"types",
")",
"{",
"return",
"new",
"DescendantOfAny",
"(",
"Iterables",
".",
"transform",
"(",
"types",
",",
"GET_TYPE",
")",
")",
";",
"}"
] | Match types that are a sub-type of one of the given types. | [
"Match",
"types",
"that",
"are",
"a",
"sub",
"-",
"type",
"of",
"one",
"of",
"the",
"given",
"types",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/predicates/TypePredicates.java#L73-L75 |
21,811 | google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/SelfAssignment.java | SelfAssignment.stripNullCheck | private static ExpressionTree stripNullCheck(ExpressionTree expression, VisitorState state) {
if (expression != null && expression.getKind() == METHOD_INVOCATION) {
MethodInvocationTree methodInvocation = (MethodInvocationTree) expression;
if (NON_NULL_MATCHER.matches(methodInvocation, state)) {
... | java | private static ExpressionTree stripNullCheck(ExpressionTree expression, VisitorState state) {
if (expression != null && expression.getKind() == METHOD_INVOCATION) {
MethodInvocationTree methodInvocation = (MethodInvocationTree) expression;
if (NON_NULL_MATCHER.matches(methodInvocation, state)) {
... | [
"private",
"static",
"ExpressionTree",
"stripNullCheck",
"(",
"ExpressionTree",
"expression",
",",
"VisitorState",
"state",
")",
"{",
"if",
"(",
"expression",
"!=",
"null",
"&&",
"expression",
".",
"getKind",
"(",
")",
"==",
"METHOD_INVOCATION",
")",
"{",
"Metho... | If the given expression is a call to a method checking the nullity of its first parameter, and
otherwise returns that parameter. | [
"If",
"the",
"given",
"expression",
"is",
"a",
"call",
"to",
"a",
"method",
"checking",
"the",
"nullity",
"of",
"its",
"first",
"parameter",
"and",
"otherwise",
"returns",
"that",
"parameter",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/SelfAssignment.java#L130-L138 |
21,812 | google/error-prone | check_api/src/main/java/com/google/errorprone/apply/SourceFile.java | SourceFile.getLines | public List<String> getLines() {
try {
return CharSource.wrap(sourceBuilder).readLines();
} catch (IOException e) {
throw new AssertionError("IOException not possible, as the string is in-memory");
}
} | java | public List<String> getLines() {
try {
return CharSource.wrap(sourceBuilder).readLines();
} catch (IOException e) {
throw new AssertionError("IOException not possible, as the string is in-memory");
}
} | [
"public",
"List",
"<",
"String",
">",
"getLines",
"(",
")",
"{",
"try",
"{",
"return",
"CharSource",
".",
"wrap",
"(",
"sourceBuilder",
")",
".",
"readLines",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"AssertionErr... | Returns a copy of code as a list of lines. | [
"Returns",
"a",
"copy",
"of",
"code",
"as",
"a",
"list",
"of",
"lines",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/apply/SourceFile.java#L58-L64 |
21,813 | google/error-prone | check_api/src/main/java/com/google/errorprone/apply/SourceFile.java | SourceFile.replaceLines | public void replaceLines(List<String> lines) {
sourceBuilder.replace(0, sourceBuilder.length(), Joiner.on("\n").join(lines) + "\n");
} | java | public void replaceLines(List<String> lines) {
sourceBuilder.replace(0, sourceBuilder.length(), Joiner.on("\n").join(lines) + "\n");
} | [
"public",
"void",
"replaceLines",
"(",
"List",
"<",
"String",
">",
"lines",
")",
"{",
"sourceBuilder",
".",
"replace",
"(",
"0",
",",
"sourceBuilder",
".",
"length",
"(",
")",
",",
"Joiner",
".",
"on",
"(",
"\"\\n\"",
")",
".",
"join",
"(",
"lines",
... | Replace the source code with the new lines of code. | [
"Replace",
"the",
"source",
"code",
"with",
"the",
"new",
"lines",
"of",
"code",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/apply/SourceFile.java#L122-L124 |
21,814 | google/error-prone | check_api/src/main/java/com/google/errorprone/apply/SourceFile.java | SourceFile.replaceLines | public void replaceLines(int startLine, int endLine, List<String> replacementLines) {
Preconditions.checkArgument(startLine <= endLine);
List<String> originalLines = getLines();
List<String> newLines = new ArrayList<>();
for (int i = 0; i < originalLines.size(); i++) {
int lineNum = i + 1;
i... | java | public void replaceLines(int startLine, int endLine, List<String> replacementLines) {
Preconditions.checkArgument(startLine <= endLine);
List<String> originalLines = getLines();
List<String> newLines = new ArrayList<>();
for (int i = 0; i < originalLines.size(); i++) {
int lineNum = i + 1;
i... | [
"public",
"void",
"replaceLines",
"(",
"int",
"startLine",
",",
"int",
"endLine",
",",
"List",
"<",
"String",
">",
"replacementLines",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"startLine",
"<=",
"endLine",
")",
";",
"List",
"<",
"String",
">",
... | Replace the source code between the start and end lines with some new lines of code. | [
"Replace",
"the",
"source",
"code",
"between",
"the",
"start",
"and",
"end",
"lines",
"with",
"some",
"new",
"lines",
"of",
"code",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/apply/SourceFile.java#L127-L142 |
21,815 | google/error-prone | check_api/src/main/java/com/google/errorprone/apply/SourceFile.java | SourceFile.replaceChars | public void replaceChars(int startPosition, int endPosition, String replacement) {
try {
sourceBuilder.replace(startPosition, endPosition, replacement);
} catch (StringIndexOutOfBoundsException e) {
throw new IndexOutOfBoundsException(
String.format(
"Replacement cannot be ma... | java | public void replaceChars(int startPosition, int endPosition, String replacement) {
try {
sourceBuilder.replace(startPosition, endPosition, replacement);
} catch (StringIndexOutOfBoundsException e) {
throw new IndexOutOfBoundsException(
String.format(
"Replacement cannot be ma... | [
"public",
"void",
"replaceChars",
"(",
"int",
"startPosition",
",",
"int",
"endPosition",
",",
"String",
"replacement",
")",
"{",
"try",
"{",
"sourceBuilder",
".",
"replace",
"(",
"startPosition",
",",
"endPosition",
",",
"replacement",
")",
";",
"}",
"catch",... | Replace the source code between the start and end character positions with a new string.
<p>This method uses the same conventions as {@link String#substring(int, int)} for its start
and end parameters. | [
"Replace",
"the",
"source",
"code",
"between",
"the",
"start",
"and",
"end",
"character",
"positions",
"with",
"a",
"new",
"string",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/apply/SourceFile.java#L150-L160 |
21,816 | google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/Parameter.java | Parameter.isAssignableTo | boolean isAssignableTo(Parameter target, VisitorState state) {
if (state.getTypes().isSameType(type(), Type.noType)
|| state.getTypes().isSameType(target.type(), Type.noType)) {
return false;
}
try {
return state.getTypes().isAssignable(type(), target.type());
} catch (CompletionFail... | java | boolean isAssignableTo(Parameter target, VisitorState state) {
if (state.getTypes().isSameType(type(), Type.noType)
|| state.getTypes().isSameType(target.type(), Type.noType)) {
return false;
}
try {
return state.getTypes().isAssignable(type(), target.type());
} catch (CompletionFail... | [
"boolean",
"isAssignableTo",
"(",
"Parameter",
"target",
",",
"VisitorState",
"state",
")",
"{",
"if",
"(",
"state",
".",
"getTypes",
"(",
")",
".",
"isSameType",
"(",
"type",
"(",
")",
",",
"Type",
".",
"noType",
")",
"||",
"state",
".",
"getTypes",
"... | Return true if this parameter is assignable to the target parameter. This will consider
subclassing, autoboxing and null. | [
"Return",
"true",
"if",
"this",
"parameter",
"is",
"assignable",
"to",
"the",
"target",
"parameter",
".",
"This",
"will",
"consider",
"subclassing",
"autoboxing",
"and",
"null",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/Parameter.java#L115-L128 |
21,817 | google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/Parameter.java | Parameter.getArgumentName | @VisibleForTesting
static String getArgumentName(ExpressionTree expressionTree) {
switch (expressionTree.getKind()) {
case MEMBER_SELECT:
return ((MemberSelectTree) expressionTree).getIdentifier().toString();
case NULL_LITERAL:
// null could match anything pretty well
return NA... | java | @VisibleForTesting
static String getArgumentName(ExpressionTree expressionTree) {
switch (expressionTree.getKind()) {
case MEMBER_SELECT:
return ((MemberSelectTree) expressionTree).getIdentifier().toString();
case NULL_LITERAL:
// null could match anything pretty well
return NA... | [
"@",
"VisibleForTesting",
"static",
"String",
"getArgumentName",
"(",
"ExpressionTree",
"expressionTree",
")",
"{",
"switch",
"(",
"expressionTree",
".",
"getKind",
"(",
")",
")",
"{",
"case",
"MEMBER_SELECT",
":",
"return",
"(",
"(",
"MemberSelectTree",
")",
"e... | Extract the name from an argument.
<p>
<ul>
<li>IdentifierTree - if the identifier is 'this' then use the name of the enclosing class,
otherwise use the name of the identifier
<li>MemberSelectTree - the name of its identifier
<li>NewClassTree - the name of the class being constructed
<li>Null literal - a wildcard nam... | [
"Extract",
"the",
"name",
"from",
"an",
"argument",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/Parameter.java#L164-L214 |
21,818 | google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/MockitoUsage.java | MockitoUsage.buildFix | private void buildFix(
Description.Builder builder, MethodInvocationTree tree, VisitorState state) {
MethodInvocationTree mockitoCall = tree;
List<? extends ExpressionTree> args = mockitoCall.getArguments();
Tree mock = mockitoCall.getArguments().get(0);
boolean isVerify = ASTHelpers.getSymbol(tre... | java | private void buildFix(
Description.Builder builder, MethodInvocationTree tree, VisitorState state) {
MethodInvocationTree mockitoCall = tree;
List<? extends ExpressionTree> args = mockitoCall.getArguments();
Tree mock = mockitoCall.getArguments().get(0);
boolean isVerify = ASTHelpers.getSymbol(tre... | [
"private",
"void",
"buildFix",
"(",
"Description",
".",
"Builder",
"builder",
",",
"MethodInvocationTree",
"tree",
",",
"VisitorState",
"state",
")",
"{",
"MethodInvocationTree",
"mockitoCall",
"=",
"tree",
";",
"List",
"<",
"?",
"extends",
"ExpressionTree",
">",
... | Create fixes for invalid assertions.
<ul>
<li>Rewrite `verify(mock.bar())` to `verify(mock).bar()`
<li>Rewrite `verify(mock.bar(), times(N))` to `verify(mock, times(N)).bar()`
<li>Rewrite `verify(mock, never())` to `verifyZeroInteractions(mock)`
<li>Finally, offer to delete the mock statement.
</ul> | [
"Create",
"fixes",
"for",
"invalid",
"assertions",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/MockitoUsage.java#L82-L114 |
21,819 | google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/inject/InjectedConstructorAnnotations.java | InjectedConstructorAnnotations.matchMethod | @Override
public Description matchMethod(MethodTree methodTree, VisitorState state) {
SuggestedFix.Builder fix = null;
if (isInjectedConstructor(methodTree, state)) {
for (AnnotationTree annotationTree : methodTree.getModifiers().getAnnotations()) {
if (OPTIONAL_INJECTION_MATCHER.matches(annotat... | java | @Override
public Description matchMethod(MethodTree methodTree, VisitorState state) {
SuggestedFix.Builder fix = null;
if (isInjectedConstructor(methodTree, state)) {
for (AnnotationTree annotationTree : methodTree.getModifiers().getAnnotations()) {
if (OPTIONAL_INJECTION_MATCHER.matches(annotat... | [
"@",
"Override",
"public",
"Description",
"matchMethod",
"(",
"MethodTree",
"methodTree",
",",
"VisitorState",
"state",
")",
"{",
"SuggestedFix",
".",
"Builder",
"fix",
"=",
"null",
";",
"if",
"(",
"isInjectedConstructor",
"(",
"methodTree",
",",
"state",
")",
... | Matches injected constructors annotated with @Inject(optional=true) or binding annotations.
Suggests fixes to remove the argument {@code optional=true} or binding annotations. | [
"Matches",
"injected",
"constructors",
"annotated",
"with"
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/inject/InjectedConstructorAnnotations.java#L68-L93 |
21,820 | google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/TypeParameterShadowing.java | TypeParameterShadowing.typeVariablesEnclosing | private static List<TypeVariableSymbol> typeVariablesEnclosing(Symbol sym) {
List<TypeVariableSymbol> typeVarScopes = new ArrayList<>();
outer:
while (!sym.isStatic()) {
sym = sym.owner;
switch (sym.getKind()) {
case PACKAGE:
break outer;
case METHOD:
case CLASS... | java | private static List<TypeVariableSymbol> typeVariablesEnclosing(Symbol sym) {
List<TypeVariableSymbol> typeVarScopes = new ArrayList<>();
outer:
while (!sym.isStatic()) {
sym = sym.owner;
switch (sym.getKind()) {
case PACKAGE:
break outer;
case METHOD:
case CLASS... | [
"private",
"static",
"List",
"<",
"TypeVariableSymbol",
">",
"typeVariablesEnclosing",
"(",
"Symbol",
"sym",
")",
"{",
"List",
"<",
"TypeVariableSymbol",
">",
"typeVarScopes",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"outer",
":",
"while",
"(",
"!",
"sy... | Get list of type params of every enclosing class | [
"Get",
"list",
"of",
"type",
"params",
"of",
"every",
"enclosing",
"class"
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/TypeParameterShadowing.java#L237-L253 |
21,821 | google/error-prone | core/src/main/java/com/google/errorprone/refaster/Template.java | Template.actualTypes | protected List<Type> actualTypes(Inliner inliner) {
ArrayList<Type> result = new ArrayList<>();
ImmutableList<String> argNames = expressionArgumentTypes().keySet().asList();
for (int i = 0; i < expressionArgumentTypes().size(); i++) {
String argName = argNames.get(i);
Optional<JCExpression> sing... | java | protected List<Type> actualTypes(Inliner inliner) {
ArrayList<Type> result = new ArrayList<>();
ImmutableList<String> argNames = expressionArgumentTypes().keySet().asList();
for (int i = 0; i < expressionArgumentTypes().size(); i++) {
String argName = argNames.get(i);
Optional<JCExpression> sing... | [
"protected",
"List",
"<",
"Type",
">",
"actualTypes",
"(",
"Inliner",
"inliner",
")",
"{",
"ArrayList",
"<",
"Type",
">",
"result",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"ImmutableList",
"<",
"String",
">",
"argNames",
"=",
"expressionArgumentTypes",... | Returns a list of the actual types to be matched. This consists of the types of the expressions
bound to the @BeforeTemplate method parameters, concatenated with the types of the expressions
bound to expression placeholders, sorted by the name of the placeholder method. | [
"Returns",
"a",
"list",
"of",
"the",
"actual",
"types",
"to",
"be",
"matched",
".",
"This",
"consists",
"of",
"the",
"types",
"of",
"the",
"expressions",
"bound",
"to",
"the"
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/refaster/Template.java#L152-L183 |
21,822 | google/error-prone | core/src/main/java/com/google/errorprone/refaster/Template.java | Template.infer | private Type infer(
Warner warner,
Inliner inliner,
List<Type> freeTypeVariables,
List<Type> expectedArgTypes,
Type returnType,
List<Type> actualArgTypes)
throws InferException {
Symtab symtab = inliner.symtab();
Type methodType =
new MethodType(expectedArgType... | java | private Type infer(
Warner warner,
Inliner inliner,
List<Type> freeTypeVariables,
List<Type> expectedArgTypes,
Type returnType,
List<Type> actualArgTypes)
throws InferException {
Symtab symtab = inliner.symtab();
Type methodType =
new MethodType(expectedArgType... | [
"private",
"Type",
"infer",
"(",
"Warner",
"warner",
",",
"Inliner",
"inliner",
",",
"List",
"<",
"Type",
">",
"freeTypeVariables",
",",
"List",
"<",
"Type",
">",
"expectedArgTypes",
",",
"Type",
"returnType",
",",
"List",
"<",
"Type",
">",
"actualArgTypes",... | Returns the inferred method type of the template based on the given actual argument types.
@throws InferException if no instances of the specified type variables would allow the {@code
actualArgTypes} to match the {@code expectedArgTypes} | [
"Returns",
"the",
"inferred",
"method",
"type",
"of",
"the",
"template",
"based",
"on",
"the",
"given",
"actual",
"argument",
"types",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/refaster/Template.java#L419-L480 |
21,823 | google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/collectionincompatibletype/IncompatibleArgumentType.java | IncompatibleArgumentType.populateTypesToEnforce | @CheckReturnValue
private boolean populateTypesToEnforce(
MethodSymbol declaredMethod,
Type calledMethodType,
Type calledReceiverType,
List<RequiredType> argumentTypeRequirements,
VisitorState state) {
boolean foundAnyTypeToEnforce = false;
List<VarSymbol> params = declaredMethod... | java | @CheckReturnValue
private boolean populateTypesToEnforce(
MethodSymbol declaredMethod,
Type calledMethodType,
Type calledReceiverType,
List<RequiredType> argumentTypeRequirements,
VisitorState state) {
boolean foundAnyTypeToEnforce = false;
List<VarSymbol> params = declaredMethod... | [
"@",
"CheckReturnValue",
"private",
"boolean",
"populateTypesToEnforce",
"(",
"MethodSymbol",
"declaredMethod",
",",
"Type",
"calledMethodType",
",",
"Type",
"calledReceiverType",
",",
"List",
"<",
"RequiredType",
">",
"argumentTypeRequirements",
",",
"VisitorState",
"sta... | caller should explore super-methods. | [
"caller",
"should",
"explore",
"super",
"-",
"methods",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/collectionincompatibletype/IncompatibleArgumentType.java#L153-L193 |
21,824 | google/error-prone | check_api/src/main/java/com/google/errorprone/util/Signatures.java | Signatures.classDescriptor | public static String classDescriptor(Type type, Types types) {
SigGen sig = new SigGen(types);
sig.assembleClassSig(types.erasure(type));
return sig.toString();
} | java | public static String classDescriptor(Type type, Types types) {
SigGen sig = new SigGen(types);
sig.assembleClassSig(types.erasure(type));
return sig.toString();
} | [
"public",
"static",
"String",
"classDescriptor",
"(",
"Type",
"type",
",",
"Types",
"types",
")",
"{",
"SigGen",
"sig",
"=",
"new",
"SigGen",
"(",
"types",
")",
";",
"sig",
".",
"assembleClassSig",
"(",
"types",
".",
"erasure",
"(",
"type",
")",
")",
"... | Returns the binary names of the class. | [
"Returns",
"the",
"binary",
"names",
"of",
"the",
"class",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/Signatures.java#L36-L40 |
21,825 | google/error-prone | check_api/src/main/java/com/google/errorprone/util/Signatures.java | Signatures.descriptor | public static String descriptor(Type type, Types types) {
SigGen sig = new SigGen(types);
sig.assembleSig(types.erasure(type));
return sig.toString();
} | java | public static String descriptor(Type type, Types types) {
SigGen sig = new SigGen(types);
sig.assembleSig(types.erasure(type));
return sig.toString();
} | [
"public",
"static",
"String",
"descriptor",
"(",
"Type",
"type",
",",
"Types",
"types",
")",
"{",
"SigGen",
"sig",
"=",
"new",
"SigGen",
"(",
"types",
")",
";",
"sig",
".",
"assembleSig",
"(",
"types",
".",
"erasure",
"(",
"type",
")",
")",
";",
"ret... | Returns a JVMS 4.3.3 method descriptor. | [
"Returns",
"a",
"JVMS",
"4",
".",
"3",
".",
"3",
"method",
"descriptor",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/Signatures.java#L43-L47 |
21,826 | google/error-prone | check_api/src/main/java/com/google/errorprone/util/Signatures.java | Signatures.prettyMethodSignature | public static String prettyMethodSignature(ClassSymbol origin, MethodSymbol m) {
StringBuilder sb = new StringBuilder();
if (m.isConstructor()) {
Name name = m.owner.enclClass().getSimpleName();
if (name.isEmpty()) {
// use the superclass name of anonymous classes
name = m.owner.encl... | java | public static String prettyMethodSignature(ClassSymbol origin, MethodSymbol m) {
StringBuilder sb = new StringBuilder();
if (m.isConstructor()) {
Name name = m.owner.enclClass().getSimpleName();
if (name.isEmpty()) {
// use the superclass name of anonymous classes
name = m.owner.encl... | [
"public",
"static",
"String",
"prettyMethodSignature",
"(",
"ClassSymbol",
"origin",
",",
"MethodSymbol",
"m",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"m",
".",
"isConstructor",
"(",
")",
")",
"{",
"Name",
"n... | Pretty-prints a method signature for use in diagnostics.
<p>Uses simple names for declared types, and omitting formal type parameters and the return
type since they do not affect overload resolution. | [
"Pretty",
"-",
"prints",
"a",
"method",
"signature",
"for",
"use",
"in",
"diagnostics",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/Signatures.java#L88-L108 |
21,827 | google/error-prone | check_api/src/main/java/com/google/errorprone/util/SourceCodeEscapers.java | SourceCodeEscapers.asUnicodeHexEscape | private static char[] asUnicodeHexEscape(char c) {
// Equivalent to String.format("\\u%04x", (int)c);
char[] r = new char[6];
r[0] = '\\';
r[1] = 'u';
r[5] = HEX_DIGITS[c & 0xF];
c >>>= 4;
r[4] = HEX_DIGITS[c & 0xF];
c >>>= 4;
r[3] = HEX_DIGITS[c & 0xF];
c >>>= 4;
r[2] = HEX_... | java | private static char[] asUnicodeHexEscape(char c) {
// Equivalent to String.format("\\u%04x", (int)c);
char[] r = new char[6];
r[0] = '\\';
r[1] = 'u';
r[5] = HEX_DIGITS[c & 0xF];
c >>>= 4;
r[4] = HEX_DIGITS[c & 0xF];
c >>>= 4;
r[3] = HEX_DIGITS[c & 0xF];
c >>>= 4;
r[2] = HEX_... | [
"private",
"static",
"char",
"[",
"]",
"asUnicodeHexEscape",
"(",
"char",
"c",
")",
"{",
"// Equivalent to String.format(\"\\\\u%04x\", (int)c);",
"char",
"[",
"]",
"r",
"=",
"new",
"char",
"[",
"6",
"]",
";",
"r",
"[",
"0",
"]",
"=",
"'",
"'",
";",
"r",... | Helper for common case of escaping a single char. | [
"Helper",
"for",
"common",
"case",
"of",
"escaping",
"a",
"single",
"char",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/util/SourceCodeEscapers.java#L88-L101 |
21,828 | google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/NarrowingCompoundAssignment.java | NarrowingCompoundAssignment.identifyBadCast | private static String identifyBadCast(Type lhs, Type rhs, Types types) {
if (!lhs.isPrimitive()) {
return null;
}
if (types.isConvertible(rhs, lhs)) {
// Exemption if the rhs is convertible to the lhs.
// This allows, e.g.: <byte> &= <byte> since the narrowing conversion can never be
... | java | private static String identifyBadCast(Type lhs, Type rhs, Types types) {
if (!lhs.isPrimitive()) {
return null;
}
if (types.isConvertible(rhs, lhs)) {
// Exemption if the rhs is convertible to the lhs.
// This allows, e.g.: <byte> &= <byte> since the narrowing conversion can never be
... | [
"private",
"static",
"String",
"identifyBadCast",
"(",
"Type",
"lhs",
",",
"Type",
"rhs",
",",
"Types",
"types",
")",
"{",
"if",
"(",
"!",
"lhs",
".",
"isPrimitive",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"types",
".",
"isConverti... | Classifies bad casts. | [
"Classifies",
"bad",
"casts",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/NarrowingCompoundAssignment.java#L125-L139 |
21,829 | google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/NarrowingCompoundAssignment.java | NarrowingCompoundAssignment.rewriteCompoundAssignment | private static Optional<Fix> rewriteCompoundAssignment(
CompoundAssignmentTree tree, VisitorState state) {
CharSequence var = state.getSourceForNode(tree.getVariable());
CharSequence expr = state.getSourceForNode(tree.getExpression());
if (var == null || expr == null) {
return Optional.absent();... | java | private static Optional<Fix> rewriteCompoundAssignment(
CompoundAssignmentTree tree, VisitorState state) {
CharSequence var = state.getSourceForNode(tree.getVariable());
CharSequence expr = state.getSourceForNode(tree.getExpression());
if (var == null || expr == null) {
return Optional.absent();... | [
"private",
"static",
"Optional",
"<",
"Fix",
">",
"rewriteCompoundAssignment",
"(",
"CompoundAssignmentTree",
"tree",
",",
"VisitorState",
"state",
")",
"{",
"CharSequence",
"var",
"=",
"state",
".",
"getSourceForNode",
"(",
"tree",
".",
"getVariable",
"(",
")",
... | Desugars a compound assignment, making the cast explicit. | [
"Desugars",
"a",
"compound",
"assignment",
"making",
"the",
"cast",
"explicit",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/NarrowingCompoundAssignment.java#L142-L178 |
21,830 | google/error-prone | check_api/src/main/java/com/google/errorprone/suppliers/Suppliers.java | Suppliers.typeFromString | public static Supplier<Type> typeFromString(final String typeString) {
requireNonNull(typeString);
return new Supplier<Type>() {
@Override
public Type get(VisitorState state) {
return state.getTypeFromString(typeString);
}
};
} | java | public static Supplier<Type> typeFromString(final String typeString) {
requireNonNull(typeString);
return new Supplier<Type>() {
@Override
public Type get(VisitorState state) {
return state.getTypeFromString(typeString);
}
};
} | [
"public",
"static",
"Supplier",
"<",
"Type",
">",
"typeFromString",
"(",
"final",
"String",
"typeString",
")",
"{",
"requireNonNull",
"(",
"typeString",
")",
";",
"return",
"new",
"Supplier",
"<",
"Type",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Typ... | Given the string representation of a type, supplies the corresponding type.
@param typeString a string representation of a type, e.g., "java.util.List" | [
"Given",
"the",
"string",
"representation",
"of",
"a",
"type",
"supplies",
"the",
"corresponding",
"type",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/suppliers/Suppliers.java#L116-L124 |
21,831 | google/error-prone | check_api/src/main/java/com/google/errorprone/suppliers/Suppliers.java | Suppliers.identitySupplier | public static <T> Supplier<T> identitySupplier(final T toSupply) {
return new Supplier<T>() {
@Override
public T get(VisitorState state) {
return toSupply;
}
};
} | java | public static <T> Supplier<T> identitySupplier(final T toSupply) {
return new Supplier<T>() {
@Override
public T get(VisitorState state) {
return toSupply;
}
};
} | [
"public",
"static",
"<",
"T",
">",
"Supplier",
"<",
"T",
">",
"identitySupplier",
"(",
"final",
"T",
"toSupply",
")",
"{",
"return",
"new",
"Supplier",
"<",
"T",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"T",
"get",
"(",
"VisitorState",
"state",
... | Supplies what was given. Useful for adapting to methods that require a supplier.
@param toSupply the item to supply | [
"Supplies",
"what",
"was",
"given",
".",
"Useful",
"for",
"adapting",
"to",
"methods",
"that",
"require",
"a",
"supplier",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/suppliers/Suppliers.java#L248-L255 |
21,832 | google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/CreatesDuplicateCallHeuristic.java | CreatesDuplicateCallHeuristic.isAcceptableChange | @Override
public boolean isAcceptableChange(
Changes changes, Tree node, MethodSymbol symbol, VisitorState state) {
return findArgumentsForOtherInstances(symbol, node, state).stream()
.allMatch(arguments -> !anyArgumentsMatch(changes.changedPairs(), arguments));
} | java | @Override
public boolean isAcceptableChange(
Changes changes, Tree node, MethodSymbol symbol, VisitorState state) {
return findArgumentsForOtherInstances(symbol, node, state).stream()
.allMatch(arguments -> !anyArgumentsMatch(changes.changedPairs(), arguments));
} | [
"@",
"Override",
"public",
"boolean",
"isAcceptableChange",
"(",
"Changes",
"changes",
",",
"Tree",
"node",
",",
"MethodSymbol",
"symbol",
",",
"VisitorState",
"state",
")",
"{",
"return",
"findArgumentsForOtherInstances",
"(",
"symbol",
",",
"node",
",",
"state",... | Returns true if there are no other calls to this method which already have an actual parameter
in the position we are moving this one too. | [
"Returns",
"true",
"if",
"there",
"are",
"no",
"other",
"calls",
"to",
"this",
"method",
"which",
"already",
"have",
"an",
"actual",
"parameter",
"in",
"the",
"position",
"we",
"are",
"moving",
"this",
"one",
"too",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/CreatesDuplicateCallHeuristic.java#L44-L49 |
21,833 | google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/CreatesDuplicateCallHeuristic.java | CreatesDuplicateCallHeuristic.anyArgumentsMatch | private static boolean anyArgumentsMatch(
List<ParameterPair> changedPairs, List<Parameter> arguments) {
return changedPairs.stream()
.anyMatch(
change ->
Objects.equals(
change.actual().text(), arguments.get(change.formal().index()).text()));
} | java | private static boolean anyArgumentsMatch(
List<ParameterPair> changedPairs, List<Parameter> arguments) {
return changedPairs.stream()
.anyMatch(
change ->
Objects.equals(
change.actual().text(), arguments.get(change.formal().index()).text()));
} | [
"private",
"static",
"boolean",
"anyArgumentsMatch",
"(",
"List",
"<",
"ParameterPair",
">",
"changedPairs",
",",
"List",
"<",
"Parameter",
">",
"arguments",
")",
"{",
"return",
"changedPairs",
".",
"stream",
"(",
")",
".",
"anyMatch",
"(",
"change",
"->",
"... | Return true if the replacement name is equal to the argument name for any replacement position. | [
"Return",
"true",
"if",
"the",
"replacement",
"name",
"is",
"equal",
"to",
"the",
"argument",
"name",
"for",
"any",
"replacement",
"position",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/CreatesDuplicateCallHeuristic.java#L54-L61 |
21,834 | google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/AmbiguousMethodReference.java | AmbiguousMethodReference.methodReferenceDescriptor | private String methodReferenceDescriptor(Types types, MethodSymbol sym) {
StringBuilder sb = new StringBuilder();
sb.append(sym.getSimpleName()).append('(');
if (!sym.isStatic()) {
sb.append(Signatures.descriptor(sym.owner.type, types));
}
sym.params().stream().map(p -> Signatures.descriptor(p... | java | private String methodReferenceDescriptor(Types types, MethodSymbol sym) {
StringBuilder sb = new StringBuilder();
sb.append(sym.getSimpleName()).append('(');
if (!sym.isStatic()) {
sb.append(Signatures.descriptor(sym.owner.type, types));
}
sym.params().stream().map(p -> Signatures.descriptor(p... | [
"private",
"String",
"methodReferenceDescriptor",
"(",
"Types",
"types",
",",
"MethodSymbol",
"sym",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sb",
".",
"append",
"(",
"sym",
".",
"getSimpleName",
"(",
")",
")",
".",
"ap... | Returns a string descriptor of a method's reference type. | [
"Returns",
"a",
"string",
"descriptor",
"of",
"a",
"method",
"s",
"reference",
"type",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/AmbiguousMethodReference.java#L110-L119 |
21,835 | google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/UnnecessaryBoxedVariable.java | UnnecessaryBoxedVariable.localVariableMatches | private static boolean localVariableMatches(VariableTree tree, VisitorState state) {
ExpressionTree expression = tree.getInitializer();
if (expression == null) {
Tree leaf = state.getPath().getParentPath().getLeaf();
if (!(leaf instanceof EnhancedForLoopTree)) {
return true;
}
En... | java | private static boolean localVariableMatches(VariableTree tree, VisitorState state) {
ExpressionTree expression = tree.getInitializer();
if (expression == null) {
Tree leaf = state.getPath().getParentPath().getLeaf();
if (!(leaf instanceof EnhancedForLoopTree)) {
return true;
}
En... | [
"private",
"static",
"boolean",
"localVariableMatches",
"(",
"VariableTree",
"tree",
",",
"VisitorState",
"state",
")",
"{",
"ExpressionTree",
"expression",
"=",
"tree",
".",
"getInitializer",
"(",
")",
";",
"if",
"(",
"expression",
"==",
"null",
")",
"{",
"Tr... | Check to see if the local variable should be considered for replacement, i.e.
<ul>
<li>A variable without an initializer
<li>Enhanced for loop variables can be replaced if they are loops over primitive arrays
<li>A variable initialized with a primitive value (which is then auto-boxed)
<li>A variable initialized with a... | [
"Check",
"to",
"see",
"if",
"the",
"local",
"variable",
"should",
"be",
"considered",
"for",
"replacement",
"i",
".",
"e",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/UnnecessaryBoxedVariable.java#L177-L202 |
21,836 | google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/AbstractToString.java | AbstractToString.isToString | ToStringKind isToString(Tree parent, ExpressionTree tree, VisitorState state) {
// is the enclosing expression string concat?
if (isStringConcat(parent, state)) {
return ToStringKind.IMPLICIT;
}
if (parent instanceof ExpressionTree) {
ExpressionTree parentExpression = (ExpressionTree) parent... | java | ToStringKind isToString(Tree parent, ExpressionTree tree, VisitorState state) {
// is the enclosing expression string concat?
if (isStringConcat(parent, state)) {
return ToStringKind.IMPLICIT;
}
if (parent instanceof ExpressionTree) {
ExpressionTree parentExpression = (ExpressionTree) parent... | [
"ToStringKind",
"isToString",
"(",
"Tree",
"parent",
",",
"ExpressionTree",
"tree",
",",
"VisitorState",
"state",
")",
"{",
"// is the enclosing expression string concat?",
"if",
"(",
"isStringConcat",
"(",
"parent",
",",
"state",
")",
")",
"{",
"return",
"ToStringK... | Classifies expressions that are converted to strings by their enclosing expression. | [
"Classifies",
"expressions",
"that",
"are",
"converted",
"to",
"strings",
"by",
"their",
"enclosing",
"expression",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/AbstractToString.java#L162-L179 |
21,837 | google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/ModifiedButNotUsed.java | ModifiedButNotUsed.newFluentChain | private static boolean newFluentChain(ExpressionTree tree, VisitorState state) {
while (tree instanceof MethodInvocationTree && FLUENT_CHAIN.matches(tree, state)) {
tree = getReceiver(tree);
}
return tree != null && FLUENT_CONSTRUCTOR.matches(tree, state);
} | java | private static boolean newFluentChain(ExpressionTree tree, VisitorState state) {
while (tree instanceof MethodInvocationTree && FLUENT_CHAIN.matches(tree, state)) {
tree = getReceiver(tree);
}
return tree != null && FLUENT_CONSTRUCTOR.matches(tree, state);
} | [
"private",
"static",
"boolean",
"newFluentChain",
"(",
"ExpressionTree",
"tree",
",",
"VisitorState",
"state",
")",
"{",
"while",
"(",
"tree",
"instanceof",
"MethodInvocationTree",
"&&",
"FLUENT_CHAIN",
".",
"matches",
"(",
"tree",
",",
"state",
")",
")",
"{",
... | Whether this is a chain of method invocations terminating in a new proto or collection builder. | [
"Whether",
"this",
"is",
"a",
"chain",
"of",
"method",
"invocations",
"terminating",
"in",
"a",
"new",
"proto",
"or",
"collection",
"builder",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/ModifiedButNotUsed.java#L299-L304 |
21,838 | google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/WellKnownMutability.java | WellKnownMutability.isAnnotation | public static boolean isAnnotation(VisitorState state, Type type) {
return isAssignableTo(type, Suppliers.ANNOTATION_TYPE, state);
} | java | public static boolean isAnnotation(VisitorState state, Type type) {
return isAssignableTo(type, Suppliers.ANNOTATION_TYPE, state);
} | [
"public",
"static",
"boolean",
"isAnnotation",
"(",
"VisitorState",
"state",
",",
"Type",
"type",
")",
"{",
"return",
"isAssignableTo",
"(",
"type",
",",
"Suppliers",
".",
"ANNOTATION_TYPE",
",",
"state",
")",
";",
"}"
] | Returns true if the type is an annotation. | [
"Returns",
"true",
"if",
"the",
"type",
"is",
"an",
"annotation",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/threadsafety/WellKnownMutability.java#L371-L373 |
21,839 | google/error-prone | check_api/src/main/java/com/google/errorprone/matchers/Description.java | Description.getMessageWithoutCheckName | public String getMessageWithoutCheckName() {
return linkUrl != null
? String.format("%s\n%s", rawMessage, linkTextForDiagnostic(linkUrl))
: String.format("%s", rawMessage);
} | java | public String getMessageWithoutCheckName() {
return linkUrl != null
? String.format("%s\n%s", rawMessage, linkTextForDiagnostic(linkUrl))
: String.format("%s", rawMessage);
} | [
"public",
"String",
"getMessageWithoutCheckName",
"(",
")",
"{",
"return",
"linkUrl",
"!=",
"null",
"?",
"String",
".",
"format",
"(",
"\"%s\\n%s\"",
",",
"rawMessage",
",",
"linkTextForDiagnostic",
"(",
"linkUrl",
")",
")",
":",
"String",
".",
"format",
"(",
... | Returns the message, not including the check name but including the link. | [
"Returns",
"the",
"message",
"not",
"including",
"the",
"check",
"name",
"but",
"including",
"the",
"link",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Description.java#L91-L95 |
21,840 | google/error-prone | check_api/src/main/java/com/google/errorprone/matchers/Description.java | Description.applySeverityOverride | @CheckReturnValue
public Description applySeverityOverride(SeverityLevel severity) {
return new Description(position, checkName, rawMessage, linkUrl, fixes, severity);
} | java | @CheckReturnValue
public Description applySeverityOverride(SeverityLevel severity) {
return new Description(position, checkName, rawMessage, linkUrl, fixes, severity);
} | [
"@",
"CheckReturnValue",
"public",
"Description",
"applySeverityOverride",
"(",
"SeverityLevel",
"severity",
")",
"{",
"return",
"new",
"Description",
"(",
"position",
",",
"checkName",
",",
"rawMessage",
",",
"linkUrl",
",",
"fixes",
",",
"severity",
")",
";",
... | Internal-only. Has no effect if applied to a Description within a BugChecker. | [
"Internal",
"-",
"only",
".",
"Has",
"no",
"effect",
"if",
"applied",
"to",
"a",
"Description",
"within",
"a",
"BugChecker",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Description.java#L126-L129 |
21,841 | google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/PenaltyThresholdHeuristic.java | PenaltyThresholdHeuristic.isAcceptableChange | @Override
public boolean isAcceptableChange(
Changes changes, Tree node, MethodSymbol symbol, VisitorState state) {
int numberOfChanges = changes.changedPairs().size();
return changes.totalOriginalCost() - changes.totalAssignmentCost()
>= threshold * numberOfChanges;
} | java | @Override
public boolean isAcceptableChange(
Changes changes, Tree node, MethodSymbol symbol, VisitorState state) {
int numberOfChanges = changes.changedPairs().size();
return changes.totalOriginalCost() - changes.totalAssignmentCost()
>= threshold * numberOfChanges;
} | [
"@",
"Override",
"public",
"boolean",
"isAcceptableChange",
"(",
"Changes",
"changes",
",",
"Tree",
"node",
",",
"MethodSymbol",
"symbol",
",",
"VisitorState",
"state",
")",
"{",
"int",
"numberOfChanges",
"=",
"changes",
".",
"changedPairs",
"(",
")",
".",
"si... | Return true if the change is sufficiently different. | [
"Return",
"true",
"if",
"the",
"change",
"is",
"sufficiently",
"different",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/PenaltyThresholdHeuristic.java#L47-L55 |
21,842 | google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/WildcardImport.java | WildcardImport.getWildcardImports | private static ImmutableList<ImportTree> getWildcardImports(List<? extends ImportTree> imports) {
ImmutableList.Builder<ImportTree> result = ImmutableList.builder();
for (ImportTree tree : imports) {
// javac represents on-demand imports as a member select where the selected name is '*'.
Tree ident ... | java | private static ImmutableList<ImportTree> getWildcardImports(List<? extends ImportTree> imports) {
ImmutableList.Builder<ImportTree> result = ImmutableList.builder();
for (ImportTree tree : imports) {
// javac represents on-demand imports as a member select where the selected name is '*'.
Tree ident ... | [
"private",
"static",
"ImmutableList",
"<",
"ImportTree",
">",
"getWildcardImports",
"(",
"List",
"<",
"?",
"extends",
"ImportTree",
">",
"imports",
")",
"{",
"ImmutableList",
".",
"Builder",
"<",
"ImportTree",
">",
"result",
"=",
"ImmutableList",
".",
"builder",... | Collect all on demand imports. | [
"Collect",
"all",
"on",
"demand",
"imports",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/WildcardImport.java#L113-L127 |
21,843 | google/error-prone | check_api/src/main/java/com/google/errorprone/dataflow/nullnesspropagation/inference/InferredNullability.java | InferredNullability.getNullnessGenerics | public ImmutableMap<TypeVariableSymbol, Nullness> getNullnessGenerics(
MethodInvocationTree callsite) {
ImmutableMap.Builder<TypeVariableSymbol, Nullness> result = ImmutableMap.builder();
for (TypeVariableSymbol tvs :
TreeInfo.symbol((JCTree) callsite.getMethodSelect()).getTypeParameters()) {
... | java | public ImmutableMap<TypeVariableSymbol, Nullness> getNullnessGenerics(
MethodInvocationTree callsite) {
ImmutableMap.Builder<TypeVariableSymbol, Nullness> result = ImmutableMap.builder();
for (TypeVariableSymbol tvs :
TreeInfo.symbol((JCTree) callsite.getMethodSelect()).getTypeParameters()) {
... | [
"public",
"ImmutableMap",
"<",
"TypeVariableSymbol",
",",
"Nullness",
">",
"getNullnessGenerics",
"(",
"MethodInvocationTree",
"callsite",
")",
"{",
"ImmutableMap",
".",
"Builder",
"<",
"TypeVariableSymbol",
",",
"Nullness",
">",
"result",
"=",
"ImmutableMap",
".",
... | Get inferred nullness qualifiers for method-generic type variables at a callsite. When
inference is not possible for a given type variable, that type variable is not included in the
resulting map. | [
"Get",
"inferred",
"nullness",
"qualifiers",
"for",
"method",
"-",
"generic",
"type",
"variables",
"at",
"a",
"callsite",
".",
"When",
"inference",
"is",
"not",
"possible",
"for",
"a",
"given",
"type",
"variable",
"that",
"type",
"variable",
"is",
"not",
"in... | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/dataflow/nullnesspropagation/inference/InferredNullability.java#L53-L64 |
21,844 | google/error-prone | check_api/src/main/java/com/google/errorprone/dataflow/nullnesspropagation/inference/InferredNullability.java | InferredNullability.getExprNullness | public Optional<Nullness> getExprNullness(ExpressionTree exprTree) {
InferenceVariable iv = TypeArgInferenceVar.create(ImmutableList.of(), exprTree);
return constraintGraph.nodes().contains(iv) ? getNullness(iv) : Optional.empty();
} | java | public Optional<Nullness> getExprNullness(ExpressionTree exprTree) {
InferenceVariable iv = TypeArgInferenceVar.create(ImmutableList.of(), exprTree);
return constraintGraph.nodes().contains(iv) ? getNullness(iv) : Optional.empty();
} | [
"public",
"Optional",
"<",
"Nullness",
">",
"getExprNullness",
"(",
"ExpressionTree",
"exprTree",
")",
"{",
"InferenceVariable",
"iv",
"=",
"TypeArgInferenceVar",
".",
"create",
"(",
"ImmutableList",
".",
"of",
"(",
")",
",",
"exprTree",
")",
";",
"return",
"c... | Get inferred nullness qualifier for an expression, if possible. | [
"Get",
"inferred",
"nullness",
"qualifier",
"for",
"an",
"expression",
"if",
"possible",
"."
] | fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/dataflow/nullnesspropagation/inference/InferredNullability.java#L67-L70 |
21,845 | chanjarster/weixin-java-tools | weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/xml/XStreamTransformer.java | XStreamTransformer.fromXml | @SuppressWarnings("unchecked")
public static <T> T fromXml(Class<T> clazz, String xml) {
T object = (T) CLASS_2_XSTREAM_INSTANCE.get(clazz).fromXML(xml);
return object;
} | java | @SuppressWarnings("unchecked")
public static <T> T fromXml(Class<T> clazz, String xml) {
T object = (T) CLASS_2_XSTREAM_INSTANCE.get(clazz).fromXML(xml);
return object;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
">",
"T",
"fromXml",
"(",
"Class",
"<",
"T",
">",
"clazz",
",",
"String",
"xml",
")",
"{",
"T",
"object",
"=",
"(",
"T",
")",
"CLASS_2_XSTREAM_INSTANCE",
".",
"get",
"(",... | xml -> pojo
@param clazz
@param xml
@return | [
"xml",
"-",
">",
"pojo"
] | 2a0b1c30c0f60c2de466cb8933c945bc0d391edf | https://github.com/chanjarster/weixin-java-tools/blob/2a0b1c30c0f60c2de466cb8933c945bc0d391edf/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/xml/XStreamTransformer.java#L22-L26 |
21,846 | chanjarster/weixin-java-tools | weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/xml/XStreamTransformer.java | XStreamTransformer.toXml | public static <T> String toXml(Class<T> clazz, T object) {
return CLASS_2_XSTREAM_INSTANCE.get(clazz).toXML(object);
} | java | public static <T> String toXml(Class<T> clazz, T object) {
return CLASS_2_XSTREAM_INSTANCE.get(clazz).toXML(object);
} | [
"public",
"static",
"<",
"T",
">",
"String",
"toXml",
"(",
"Class",
"<",
"T",
">",
"clazz",
",",
"T",
"object",
")",
"{",
"return",
"CLASS_2_XSTREAM_INSTANCE",
".",
"get",
"(",
"clazz",
")",
".",
"toXML",
"(",
"object",
")",
";",
"}"
] | pojo -> xml
@param clazz
@param object
@return | [
"pojo",
"-",
">",
"xml"
] | 2a0b1c30c0f60c2de466cb8933c945bc0d391edf | https://github.com/chanjarster/weixin-java-tools/blob/2a0b1c30c0f60c2de466cb8933c945bc0d391edf/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/xml/XStreamTransformer.java#L41-L43 |
21,847 | chanjarster/weixin-java-tools | weixin-java-common/src/main/java/me/chanjar/weixin/common/session/StandardSessionManager.java | StandardSessionManager.processExpires | public void processExpires() {
long timeNow = System.currentTimeMillis();
InternalSession sessions[] = findSessions();
int expireHere = 0 ;
if(log.isDebugEnabled())
log.debug("Start expire sessions {} at {} sessioncount {}", getName(), timeNow, sessions.length);
for (int i = 0; i < sessions.... | java | public void processExpires() {
long timeNow = System.currentTimeMillis();
InternalSession sessions[] = findSessions();
int expireHere = 0 ;
if(log.isDebugEnabled())
log.debug("Start expire sessions {} at {} sessioncount {}", getName(), timeNow, sessions.length);
for (int i = 0; i < sessions.... | [
"public",
"void",
"processExpires",
"(",
")",
"{",
"long",
"timeNow",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"InternalSession",
"sessions",
"[",
"]",
"=",
"findSessions",
"(",
")",
";",
"int",
"expireHere",
"=",
"0",
";",
"if",
"(",
"log... | Invalidate all sessions that have expired. | [
"Invalidate",
"all",
"sessions",
"that",
"have",
"expired",
"."
] | 2a0b1c30c0f60c2de466cb8933c945bc0d391edf | https://github.com/chanjarster/weixin-java-tools/blob/2a0b1c30c0f60c2de466cb8933c945bc0d391edf/weixin-java-common/src/main/java/me/chanjar/weixin/common/session/StandardSessionManager.java#L250-L268 |
21,848 | chanjarster/weixin-java-tools | weixin-java-common/src/main/java/me/chanjar/weixin/common/util/res/StringManager.java | StringManager.getString | public String getString(final String key, final Object... args) {
String value = getString(key);
if (value == null) {
value = key;
}
MessageFormat mf = new MessageFormat(value);
mf.setLocale(locale);
return mf.format(args, new StringBuffer(), null).toString()... | java | public String getString(final String key, final Object... args) {
String value = getString(key);
if (value == null) {
value = key;
}
MessageFormat mf = new MessageFormat(value);
mf.setLocale(locale);
return mf.format(args, new StringBuffer(), null).toString()... | [
"public",
"String",
"getString",
"(",
"final",
"String",
"key",
",",
"final",
"Object",
"...",
"args",
")",
"{",
"String",
"value",
"=",
"getString",
"(",
"key",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"value",
"=",
"key",
";",
"}",
"... | Get a string from the underlying resource bundle and format
it with the given set of arguments.
@param key
@param args | [
"Get",
"a",
"string",
"from",
"the",
"underlying",
"resource",
"bundle",
"and",
"format",
"it",
"with",
"the",
"given",
"set",
"of",
"arguments",
"."
] | 2a0b1c30c0f60c2de466cb8933c945bc0d391edf | https://github.com/chanjarster/weixin-java-tools/blob/2a0b1c30c0f60c2de466cb8933c945bc0d391edf/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/res/StringManager.java#L151-L160 |
21,849 | JohnSnowLabs/spark-nlp | src/main/scala/com/johnsnowlabs/nlp/annotators/parser/typdep/util/Alphabet.java | Alphabet.lookupIndex | public int lookupIndex (long entry)
{
int ret = map.get(entry);
if (ret <= 0 && !growthStopped) {
numEntries++;
ret = numEntries;
map.put (entry, ret);
}
return ret - 1; // feature id should be 0-based
} | java | public int lookupIndex (long entry)
{
int ret = map.get(entry);
if (ret <= 0 && !growthStopped) {
numEntries++;
ret = numEntries;
map.put (entry, ret);
}
return ret - 1; // feature id should be 0-based
} | [
"public",
"int",
"lookupIndex",
"(",
"long",
"entry",
")",
"{",
"int",
"ret",
"=",
"map",
".",
"get",
"(",
"entry",
")",
";",
"if",
"(",
"ret",
"<=",
"0",
"&&",
"!",
"growthStopped",
")",
"{",
"numEntries",
"++",
";",
"ret",
"=",
"numEntries",
";",... | Return -1 if entry isn't present. | [
"Return",
"-",
"1",
"if",
"entry",
"isn",
"t",
"present",
"."
] | cf6c7a86e044b82f7690157c195f77874858bb00 | https://github.com/JohnSnowLabs/spark-nlp/blob/cf6c7a86e044b82f7690157c195f77874858bb00/src/main/scala/com/johnsnowlabs/nlp/annotators/parser/typdep/util/Alphabet.java#L39-L48 |
21,850 | huaban/jieba-analysis | src/main/java/com/huaban/analysis/jieba/WordDictionary.java | WordDictionary.init | public void init(Path configFile) {
String abspath = configFile.toAbsolutePath().toString();
System.out.println("initialize user dictionary:" + abspath);
synchronized (WordDictionary.class) {
if (loadedPath.contains(abspath))
return;
Directory... | java | public void init(Path configFile) {
String abspath = configFile.toAbsolutePath().toString();
System.out.println("initialize user dictionary:" + abspath);
synchronized (WordDictionary.class) {
if (loadedPath.contains(abspath))
return;
Directory... | [
"public",
"void",
"init",
"(",
"Path",
"configFile",
")",
"{",
"String",
"abspath",
"=",
"configFile",
".",
"toAbsolutePath",
"(",
")",
".",
"toString",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"initialize user dictionary:\"",
"+",
"abspat... | for ES to initialize the user dictionary.
@param configFile | [
"for",
"ES",
"to",
"initialize",
"the",
"user",
"dictionary",
"."
] | 57d2733a9a3b0adc1eda2fbf827fd270153110f4 | https://github.com/huaban/jieba-analysis/blob/57d2733a9a3b0adc1eda2fbf827fd270153110f4/src/main/java/com/huaban/analysis/jieba/WordDictionary.java#L55-L76 |
21,851 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/buffer/BufferReverseIntIteratorFlyweight.java | BufferReverseIntIteratorFlyweight.wrap | public void wrap(ImmutableRoaringBitmap r) {
this.roaringBitmap = r;
this.hs = 0;
this.pos = (short) (this.roaringBitmap.highLowContainer.size() - 1);
this.nextContainer();
} | java | public void wrap(ImmutableRoaringBitmap r) {
this.roaringBitmap = r;
this.hs = 0;
this.pos = (short) (this.roaringBitmap.highLowContainer.size() - 1);
this.nextContainer();
} | [
"public",
"void",
"wrap",
"(",
"ImmutableRoaringBitmap",
"r",
")",
"{",
"this",
".",
"roaringBitmap",
"=",
"r",
";",
"this",
".",
"hs",
"=",
"0",
";",
"this",
".",
"pos",
"=",
"(",
"short",
")",
"(",
"this",
".",
"roaringBitmap",
".",
"highLowContainer... | Prepares a bitmap for iteration
@param r bitmap to be iterated over | [
"Prepares",
"a",
"bitmap",
"for",
"iteration"
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/buffer/BufferReverseIntIteratorFlyweight.java#L111-L116 |
21,852 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/RoaringArray.java | RoaringArray.appendCopy | protected void appendCopy(RoaringArray sa, int index) {
extendArray(1);
this.keys[this.size] = sa.keys[index];
this.values[this.size] = sa.values[index].clone();
this.size++;
} | java | protected void appendCopy(RoaringArray sa, int index) {
extendArray(1);
this.keys[this.size] = sa.keys[index];
this.values[this.size] = sa.values[index].clone();
this.size++;
} | [
"protected",
"void",
"appendCopy",
"(",
"RoaringArray",
"sa",
",",
"int",
"index",
")",
"{",
"extendArray",
"(",
"1",
")",
";",
"this",
".",
"keys",
"[",
"this",
".",
"size",
"]",
"=",
"sa",
".",
"keys",
"[",
"index",
"]",
";",
"this",
".",
"values... | Append copy of the one value from another array
@param sa other array
@param index index in the other array | [
"Append",
"copy",
"of",
"the",
"one",
"value",
"from",
"another",
"array"
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/RoaringArray.java#L194-L199 |
21,853 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/RoaringArray.java | RoaringArray.extendArray | protected void extendArray(int k) {
// size + 1 could overflow
if (this.size + k > this.keys.length) {
int newCapacity;
if (this.keys.length < 1024) {
newCapacity = 2 * (this.size + k);
} else {
newCapacity = 5 * (this.size + k) / 4;
}
this.keys = Arrays.copyOf(this... | java | protected void extendArray(int k) {
// size + 1 could overflow
if (this.size + k > this.keys.length) {
int newCapacity;
if (this.keys.length < 1024) {
newCapacity = 2 * (this.size + k);
} else {
newCapacity = 5 * (this.size + k) / 4;
}
this.keys = Arrays.copyOf(this... | [
"protected",
"void",
"extendArray",
"(",
"int",
"k",
")",
"{",
"// size + 1 could overflow",
"if",
"(",
"this",
".",
"size",
"+",
"k",
">",
"this",
".",
"keys",
".",
"length",
")",
"{",
"int",
"newCapacity",
";",
"if",
"(",
"this",
".",
"keys",
".",
... | make sure there is capacity for at least k more elements | [
"make",
"sure",
"there",
"is",
"capacity",
"for",
"at",
"least",
"k",
"more",
"elements"
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/RoaringArray.java#L662-L674 |
21,854 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/RoaringArray.java | RoaringArray.getContainerPointer | public ContainerPointer getContainerPointer(final int startIndex) {
return new ContainerPointer() {
int k = startIndex;
@Override
public void advance() {
++k;
}
@Override
public ContainerPointer clone() {
try {
return (ContainerPointer) super.clone();... | java | public ContainerPointer getContainerPointer(final int startIndex) {
return new ContainerPointer() {
int k = startIndex;
@Override
public void advance() {
++k;
}
@Override
public ContainerPointer clone() {
try {
return (ContainerPointer) super.clone();... | [
"public",
"ContainerPointer",
"getContainerPointer",
"(",
"final",
"int",
"startIndex",
")",
"{",
"return",
"new",
"ContainerPointer",
"(",
")",
"{",
"int",
"k",
"=",
"startIndex",
";",
"@",
"Override",
"public",
"void",
"advance",
"(",
")",
"{",
"++",
"k",
... | Create a ContainerPointer for this RoaringArray
@param startIndex starting index in the container list
@return a ContainerPointer | [
"Create",
"a",
"ContainerPointer",
"for",
"this",
"RoaringArray"
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/RoaringArray.java#L702-L760 |
21,855 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/RoaringArray.java | RoaringArray.insertNewKeyValueAt | protected void insertNewKeyValueAt(int i, short key, Container value) {
extendArray(1);
System.arraycopy(keys, i, keys, i + 1, size - i);
keys[i] = key;
System.arraycopy(values, i, values, i + 1, size - i);
values[i] = value;
size++;
} | java | protected void insertNewKeyValueAt(int i, short key, Container value) {
extendArray(1);
System.arraycopy(keys, i, keys, i + 1, size - i);
keys[i] = key;
System.arraycopy(values, i, values, i + 1, size - i);
values[i] = value;
size++;
} | [
"protected",
"void",
"insertNewKeyValueAt",
"(",
"int",
"i",
",",
"short",
"key",
",",
"Container",
"value",
")",
"{",
"extendArray",
"(",
"1",
")",
";",
"System",
".",
"arraycopy",
"(",
"keys",
",",
"i",
",",
"keys",
",",
"i",
"+",
"1",
",",
"size",... | insert a new key, it is assumed that it does not exist | [
"insert",
"a",
"new",
"key",
"it",
"is",
"assumed",
"that",
"it",
"does",
"not",
"exist"
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/RoaringArray.java#L808-L815 |
21,856 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/RoaringArray.java | RoaringArray.first | public int first() {
assertNonEmpty();
short firstKey = keys[0];
Container container = values[0];
return firstKey << 16 | container.first();
} | java | public int first() {
assertNonEmpty();
short firstKey = keys[0];
Container container = values[0];
return firstKey << 16 | container.first();
} | [
"public",
"int",
"first",
"(",
")",
"{",
"assertNonEmpty",
"(",
")",
";",
"short",
"firstKey",
"=",
"keys",
"[",
"0",
"]",
";",
"Container",
"container",
"=",
"values",
"[",
"0",
"]",
";",
"return",
"firstKey",
"<<",
"16",
"|",
"container",
".",
"fir... | Gets the first value in the array
@return the first value in the array
@throws NoSuchElementException if empty | [
"Gets",
"the",
"first",
"value",
"in",
"the",
"array"
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/RoaringArray.java#L987-L992 |
21,857 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/RoaringArray.java | RoaringArray.last | public int last() {
assertNonEmpty();
short lastKey = keys[size - 1];
Container container = values[size - 1];
return lastKey << 16 | container.last();
} | java | public int last() {
assertNonEmpty();
short lastKey = keys[size - 1];
Container container = values[size - 1];
return lastKey << 16 | container.last();
} | [
"public",
"int",
"last",
"(",
")",
"{",
"assertNonEmpty",
"(",
")",
";",
"short",
"lastKey",
"=",
"keys",
"[",
"size",
"-",
"1",
"]",
";",
"Container",
"container",
"=",
"values",
"[",
"size",
"-",
"1",
"]",
";",
"return",
"lastKey",
"<<",
"16",
"|... | Gets the last value in the array
@return the last value in the array
@throws NoSuchElementException if empty | [
"Gets",
"the",
"last",
"value",
"in",
"the",
"array"
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/RoaringArray.java#L999-L1004 |
21,858 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/longlong/Roaring64NavigableMap.java | Roaring64NavigableMap.select | @Override
public long select(final long j) throws IllegalArgumentException {
if (!doCacheCardinalities) {
return selectNoCache(j);
}
// Ensure all cumulatives as we we have straightforward way to know in advance the high of the
// j-th value
int indexOk = ensureCumulatives(highestHigh());
... | java | @Override
public long select(final long j) throws IllegalArgumentException {
if (!doCacheCardinalities) {
return selectNoCache(j);
}
// Ensure all cumulatives as we we have straightforward way to know in advance the high of the
// j-th value
int indexOk = ensureCumulatives(highestHigh());
... | [
"@",
"Override",
"public",
"long",
"select",
"(",
"final",
"long",
"j",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"!",
"doCacheCardinalities",
")",
"{",
"return",
"selectNoCache",
"(",
"j",
")",
";",
"}",
"// Ensure all cumulatives as we we have s... | Return the jth value stored in this bitmap.
@param j index of the value
@return the value
@throws IllegalArgumentException if j is out of the bounds of the bitmap cardinality | [
"Return",
"the",
"jth",
"value",
"stored",
"in",
"this",
"bitmap",
"."
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/longlong/Roaring64NavigableMap.java#L340-L393 |
21,859 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/longlong/Roaring64NavigableMap.java | Roaring64NavigableMap.serialize | @Override
public void serialize(DataOutput out) throws IOException {
// TODO: Should we transport the performance tweak 'doCacheCardinalities'?
out.writeBoolean(signedLongs);
out.writeInt(highToBitmap.size());
for (Entry<Integer, BitmapDataProvider> entry : highToBitmap.entrySet()) {
out.write... | java | @Override
public void serialize(DataOutput out) throws IOException {
// TODO: Should we transport the performance tweak 'doCacheCardinalities'?
out.writeBoolean(signedLongs);
out.writeInt(highToBitmap.size());
for (Entry<Integer, BitmapDataProvider> entry : highToBitmap.entrySet()) {
out.write... | [
"@",
"Override",
"public",
"void",
"serialize",
"(",
"DataOutput",
"out",
")",
"throws",
"IOException",
"{",
"// TODO: Should we transport the performance tweak 'doCacheCardinalities'?",
"out",
".",
"writeBoolean",
"(",
"signedLongs",
")",
";",
"out",
".",
"writeInt",
"... | Serialize this bitmap.
Unlike RoaringBitmap, there is no specification for now: it may change from onve java version
to another, and from one RoaringBitmap version to another.
Consider calling {@link #runOptimize} before serialization to improve compression.
The current bitmap is not modified.
@param out the DataOu... | [
"Serialize",
"this",
"bitmap",
"."
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/longlong/Roaring64NavigableMap.java#L1123-L1134 |
21,860 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/longlong/Roaring64NavigableMap.java | Roaring64NavigableMap.toArray | @Override
public long[] toArray() {
long cardinality = this.getLongCardinality();
if (cardinality > Integer.MAX_VALUE) {
throw new IllegalStateException("The cardinality does not fit in an array");
}
final long[] array = new long[(int) cardinality];
int pos = 0;
LongIterator it = getLo... | java | @Override
public long[] toArray() {
long cardinality = this.getLongCardinality();
if (cardinality > Integer.MAX_VALUE) {
throw new IllegalStateException("The cardinality does not fit in an array");
}
final long[] array = new long[(int) cardinality];
int pos = 0;
LongIterator it = getLo... | [
"@",
"Override",
"public",
"long",
"[",
"]",
"toArray",
"(",
")",
"{",
"long",
"cardinality",
"=",
"this",
".",
"getLongCardinality",
"(",
")",
";",
"if",
"(",
"cardinality",
">",
"Integer",
".",
"MAX_VALUE",
")",
"{",
"throw",
"new",
"IllegalStateExceptio... | Return the set values as an array, if the cardinality is smaller than 2147483648. The long
values are in sorted order.
@return array representing the set values. | [
"Return",
"the",
"set",
"values",
"as",
"an",
"array",
"if",
"the",
"cardinality",
"is",
"smaller",
"than",
"2147483648",
".",
"The",
"long",
"values",
"are",
"in",
"sorted",
"order",
"."
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/longlong/Roaring64NavigableMap.java#L1209-L1225 |
21,861 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/longlong/Roaring64NavigableMap.java | Roaring64NavigableMap.bitmapOf | public static Roaring64NavigableMap bitmapOf(final long... dat) {
final Roaring64NavigableMap ans = new Roaring64NavigableMap();
ans.add(dat);
return ans;
} | java | public static Roaring64NavigableMap bitmapOf(final long... dat) {
final Roaring64NavigableMap ans = new Roaring64NavigableMap();
ans.add(dat);
return ans;
} | [
"public",
"static",
"Roaring64NavigableMap",
"bitmapOf",
"(",
"final",
"long",
"...",
"dat",
")",
"{",
"final",
"Roaring64NavigableMap",
"ans",
"=",
"new",
"Roaring64NavigableMap",
"(",
")",
";",
"ans",
".",
"add",
"(",
"dat",
")",
";",
"return",
"ans",
";",... | Generate a bitmap with the specified values set to true. The provided longs values don't have
to be in sorted order, but it may be preferable to sort them from a performance point of view.
@param dat set values
@return a new bitmap | [
"Generate",
"a",
"bitmap",
"with",
"the",
"specified",
"values",
"set",
"to",
"true",
".",
"The",
"provided",
"longs",
"values",
"don",
"t",
"have",
"to",
"be",
"in",
"sorted",
"order",
"but",
"it",
"may",
"be",
"preferable",
"to",
"sort",
"them",
"from"... | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/longlong/Roaring64NavigableMap.java#L1234-L1238 |
21,862 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/longlong/Roaring64NavigableMap.java | Roaring64NavigableMap.add | public void add(final long rangeStart, final long rangeEnd) {
int startHigh = high(rangeStart);
int startLow = low(rangeStart);
int endHigh = high(rangeEnd);
int endLow = low(rangeEnd);
for (int high = startHigh; high <= endHigh; high++) {
final int currentStartLow;
if (startHigh == hi... | java | public void add(final long rangeStart, final long rangeEnd) {
int startHigh = high(rangeStart);
int startLow = low(rangeStart);
int endHigh = high(rangeEnd);
int endLow = low(rangeEnd);
for (int high = startHigh; high <= endHigh; high++) {
final int currentStartLow;
if (startHigh == hi... | [
"public",
"void",
"add",
"(",
"final",
"long",
"rangeStart",
",",
"final",
"long",
"rangeEnd",
")",
"{",
"int",
"startHigh",
"=",
"high",
"(",
"rangeStart",
")",
";",
"int",
"startLow",
"=",
"low",
"(",
"rangeStart",
")",
";",
"int",
"endHigh",
"=",
"h... | Add to the current bitmap all longs in [rangeStart,rangeEnd).
@param rangeStart inclusive beginning of range
@param rangeEnd exclusive ending of range | [
"Add",
"to",
"the",
"current",
"bitmap",
"all",
"longs",
"in",
"[",
"rangeStart",
"rangeEnd",
")",
"."
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/longlong/Roaring64NavigableMap.java#L1259-L1307 |
21,863 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/buffer/MutableRoaringArray.java | MutableRoaringArray.serializedSizeInBytes | @Override
public int serializedSizeInBytes() {
int count = headerSize();
// for each container, we store cardinality (16 bits), key (16 bits) and location offset (32
// bits).
for (int k = 0; k < this.size; ++k) {
count += values[k].getArraySizeInBytes();
}
return count;
} | java | @Override
public int serializedSizeInBytes() {
int count = headerSize();
// for each container, we store cardinality (16 bits), key (16 bits) and location offset (32
// bits).
for (int k = 0; k < this.size; ++k) {
count += values[k].getArraySizeInBytes();
}
return count;
} | [
"@",
"Override",
"public",
"int",
"serializedSizeInBytes",
"(",
")",
"{",
"int",
"count",
"=",
"headerSize",
"(",
")",
";",
"// for each container, we store cardinality (16 bits), key (16 bits) and location offset (32",
"// bits).",
"for",
"(",
"int",
"k",
"=",
"0",
";"... | Report the number of bytes required for serialization.
@return the size in bytes | [
"Report",
"the",
"number",
"of",
"bytes",
"required",
"for",
"serialization",
"."
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/buffer/MutableRoaringArray.java#L745-L754 |
21,864 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/buffer/MappeableRunContainer.java | MappeableRunContainer.appendValueLength | private void appendValueLength(int value, int index) {
int previousValue = toIntUnsigned(getValue(index));
int length = toIntUnsigned(getLength(index));
int offset = value - previousValue;
if (offset > length) {
setLength(index, (short) offset);
}
} | java | private void appendValueLength(int value, int index) {
int previousValue = toIntUnsigned(getValue(index));
int length = toIntUnsigned(getLength(index));
int offset = value - previousValue;
if (offset > length) {
setLength(index, (short) offset);
}
} | [
"private",
"void",
"appendValueLength",
"(",
"int",
"value",
",",
"int",
"index",
")",
"{",
"int",
"previousValue",
"=",
"toIntUnsigned",
"(",
"getValue",
"(",
"index",
")",
")",
";",
"int",
"length",
"=",
"toIntUnsigned",
"(",
"getLength",
"(",
"index",
"... | Append a value length with all values until a given value | [
"Append",
"a",
"value",
"length",
"with",
"all",
"values",
"until",
"a",
"given",
"value"
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/buffer/MappeableRunContainer.java#L665-L672 |
21,865 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/buffer/MappeableRunContainer.java | MappeableRunContainer.canPrependValueLength | private boolean canPrependValueLength(int value, int index) {
if (index < this.nbrruns) {
int nextValue = toIntUnsigned(getValue(index));
if (nextValue == value + 1) {
return true;
}
}
return false;
} | java | private boolean canPrependValueLength(int value, int index) {
if (index < this.nbrruns) {
int nextValue = toIntUnsigned(getValue(index));
if (nextValue == value + 1) {
return true;
}
}
return false;
} | [
"private",
"boolean",
"canPrependValueLength",
"(",
"int",
"value",
",",
"int",
"index",
")",
"{",
"if",
"(",
"index",
"<",
"this",
".",
"nbrruns",
")",
"{",
"int",
"nextValue",
"=",
"toIntUnsigned",
"(",
"getValue",
"(",
"index",
")",
")",
";",
"if",
... | To check if a value length can be prepended with a given value | [
"To",
"check",
"if",
"a",
"value",
"length",
"can",
"be",
"prepended",
"with",
"a",
"given",
"value"
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/buffer/MappeableRunContainer.java#L676-L684 |
21,866 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/buffer/MappeableRunContainer.java | MappeableRunContainer.closeValueLength | private void closeValueLength(int value, int index) {
int initialValue = toIntUnsigned(getValue(index));
setLength(index, (short) (value - initialValue));
} | java | private void closeValueLength(int value, int index) {
int initialValue = toIntUnsigned(getValue(index));
setLength(index, (short) (value - initialValue));
} | [
"private",
"void",
"closeValueLength",
"(",
"int",
"value",
",",
"int",
"index",
")",
"{",
"int",
"initialValue",
"=",
"toIntUnsigned",
"(",
"getValue",
"(",
"index",
")",
")",
";",
"setLength",
"(",
"index",
",",
"(",
"short",
")",
"(",
"value",
"-",
... | To set the last value of a value length | [
"To",
"set",
"the",
"last",
"value",
"of",
"a",
"value",
"length"
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/buffer/MappeableRunContainer.java#L702-L705 |
21,867 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/buffer/MappeableRunContainer.java | MappeableRunContainer.contains | public static boolean contains(ByteBuffer buf, int position, short x, final int numRuns) {
int index = bufferedUnsignedInterleavedBinarySearch(buf, position, 0, numRuns, x);
if (index >= 0) {
return true;
}
index = -index - 2; // points to preceding value, possibly -1
if (index != -1) {// poss... | java | public static boolean contains(ByteBuffer buf, int position, short x, final int numRuns) {
int index = bufferedUnsignedInterleavedBinarySearch(buf, position, 0, numRuns, x);
if (index >= 0) {
return true;
}
index = -index - 2; // points to preceding value, possibly -1
if (index != -1) {// poss... | [
"public",
"static",
"boolean",
"contains",
"(",
"ByteBuffer",
"buf",
",",
"int",
"position",
",",
"short",
"x",
",",
"final",
"int",
"numRuns",
")",
"{",
"int",
"index",
"=",
"bufferedUnsignedInterleavedBinarySearch",
"(",
"buf",
",",
"position",
",",
"0",
"... | Checks whether the run container contains x.
@param buf underlying ByteBuffer
@param position starting position of the container in the ByteBuffer
@param x target 16-bit value
@param numRuns number of runs
@return whether the run container contains x | [
"Checks",
"whether",
"the",
"run",
"container",
"contains",
"x",
"."
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/buffer/MappeableRunContainer.java#L733-L749 |
21,868 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/buffer/MappeableRunContainer.java | MappeableRunContainer.prependValueLength | private void prependValueLength(int value, int index) {
int initialValue = toIntUnsigned(getValue(index));
int length = toIntUnsigned(getLength(index));
setValue(index, (short) value);
setLength(index, (short) (initialValue - value + length));
} | java | private void prependValueLength(int value, int index) {
int initialValue = toIntUnsigned(getValue(index));
int length = toIntUnsigned(getLength(index));
setValue(index, (short) value);
setLength(index, (short) (initialValue - value + length));
} | [
"private",
"void",
"prependValueLength",
"(",
"int",
"value",
",",
"int",
"index",
")",
"{",
"int",
"initialValue",
"=",
"toIntUnsigned",
"(",
"getValue",
"(",
"index",
")",
")",
";",
"int",
"length",
"=",
"toIntUnsigned",
"(",
"getLength",
"(",
"index",
"... | Prepend a value length with all values starting from a given value | [
"Prepend",
"a",
"value",
"length",
"with",
"all",
"values",
"starting",
"from",
"a",
"given",
"value"
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/buffer/MappeableRunContainer.java#L1920-L1925 |
21,869 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/buffer/MappeableRunContainer.java | MappeableRunContainer.smartAppend | private void smartAppend(short[] vl, short val) {
int oldend;
if ((nbrruns == 0) || (
toIntUnsigned(val) > (oldend = toIntUnsigned(vl[2 * (nbrruns - 1)])
+ toIntUnsigned(vl[2 * (nbrruns - 1) + 1])) + 1)) { // we add a new one
vl[2 * nbrruns] = val;
vl[2 * nbrruns + 1] = 0;
... | java | private void smartAppend(short[] vl, short val) {
int oldend;
if ((nbrruns == 0) || (
toIntUnsigned(val) > (oldend = toIntUnsigned(vl[2 * (nbrruns - 1)])
+ toIntUnsigned(vl[2 * (nbrruns - 1) + 1])) + 1)) { // we add a new one
vl[2 * nbrruns] = val;
vl[2 * nbrruns + 1] = 0;
... | [
"private",
"void",
"smartAppend",
"(",
"short",
"[",
"]",
"vl",
",",
"short",
"val",
")",
"{",
"int",
"oldend",
";",
"if",
"(",
"(",
"nbrruns",
"==",
"0",
")",
"||",
"(",
"toIntUnsigned",
"(",
"val",
")",
">",
"(",
"oldend",
"=",
"toIntUnsigned",
"... | to return ArrayContainer or BitmapContainer | [
"to",
"return",
"ArrayContainer",
"or",
"BitmapContainer"
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/buffer/MappeableRunContainer.java#L2070-L2083 |
21,870 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/buffer/MappeableRunContainer.java | MappeableRunContainer.valueLengthContains | private boolean valueLengthContains(int value, int index) {
int initialValue = toIntUnsigned(getValue(index));
int length = toIntUnsigned(getLength(index));
return value <= initialValue + length;
} | java | private boolean valueLengthContains(int value, int index) {
int initialValue = toIntUnsigned(getValue(index));
int length = toIntUnsigned(getLength(index));
return value <= initialValue + length;
} | [
"private",
"boolean",
"valueLengthContains",
"(",
"int",
"value",
",",
"int",
"index",
")",
"{",
"int",
"initialValue",
"=",
"toIntUnsigned",
"(",
"getValue",
"(",
"index",
")",
")",
";",
"int",
"length",
"=",
"toIntUnsigned",
"(",
"getLength",
"(",
"index",... | To check if a value length contains a given value | [
"To",
"check",
"if",
"a",
"value",
"length",
"contains",
"a",
"given",
"value"
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/buffer/MappeableRunContainer.java#L2341-L2346 |
21,871 | RoaringBitmap/RoaringBitmap | jmh/src/main/java/org/roaringbitmap/runcontainer/RandomUtil.java | RandomUtil.negate | static int[] negate(int[] x, int Max) {
int[] ans = new int[Max - x.length];
int i = 0;
int c = 0;
for (int j = 0; j < x.length; ++j) {
int v = x[j];
for (; i < v; ++i)
ans[c++] = i;
++i;
}
while (c < ans.length)
ans[c++] = i++;
return ans;
} | java | static int[] negate(int[] x, int Max) {
int[] ans = new int[Max - x.length];
int i = 0;
int c = 0;
for (int j = 0; j < x.length; ++j) {
int v = x[j];
for (; i < v; ++i)
ans[c++] = i;
++i;
}
while (c < ans.length)
ans[c++] = i++;
return ans;
} | [
"static",
"int",
"[",
"]",
"negate",
"(",
"int",
"[",
"]",
"x",
",",
"int",
"Max",
")",
"{",
"int",
"[",
"]",
"ans",
"=",
"new",
"int",
"[",
"Max",
"-",
"x",
".",
"length",
"]",
";",
"int",
"i",
"=",
"0",
";",
"int",
"c",
"=",
"0",
";",
... | output all integers from the range [0,Max) that are not in the array | [
"output",
"all",
"integers",
"from",
"the",
"range",
"[",
"0",
"Max",
")",
"that",
"are",
"not",
"in",
"the",
"array"
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/jmh/src/main/java/org/roaringbitmap/runcontainer/RandomUtil.java#L42-L55 |
21,872 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/buffer/MappeableBitmapContainer.java | MappeableBitmapContainer.contains | public static boolean contains(ByteBuffer buf, int position, final short i) {
final int x = toIntUnsigned(i);
return (buf.getLong(x / 64 * 8 + position) & (1L << x)) != 0;
} | java | public static boolean contains(ByteBuffer buf, int position, final short i) {
final int x = toIntUnsigned(i);
return (buf.getLong(x / 64 * 8 + position) & (1L << x)) != 0;
} | [
"public",
"static",
"boolean",
"contains",
"(",
"ByteBuffer",
"buf",
",",
"int",
"position",
",",
"final",
"short",
"i",
")",
"{",
"final",
"int",
"x",
"=",
"toIntUnsigned",
"(",
"i",
")",
";",
"return",
"(",
"buf",
".",
"getLong",
"(",
"x",
"/",
"64... | Checks whether the container contains the value i.
@param buf underlying buffer
@param position position of the container in the buffer
@param i index
@return whether the container contains the value i | [
"Checks",
"whether",
"the",
"container",
"contains",
"the",
"value",
"i",
"."
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/buffer/MappeableBitmapContainer.java#L418-L421 |
21,873 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/buffer/MappeableBitmapContainer.java | MappeableBitmapContainer.nextClearBit | public int nextClearBit(final int i) {
int x = i >> 6; // i / 64 with sign extension
long w = ~bitmap.get(x);
w >>>= i;
if (w != 0) {
return i + numberOfTrailingZeros(w);
}
int length = bitmap.limit();
for (++x; x < length; ++x) {
long map = ~bitmap.get(x);
if (map != 0L) {... | java | public int nextClearBit(final int i) {
int x = i >> 6; // i / 64 with sign extension
long w = ~bitmap.get(x);
w >>>= i;
if (w != 0) {
return i + numberOfTrailingZeros(w);
}
int length = bitmap.limit();
for (++x; x < length; ++x) {
long map = ~bitmap.get(x);
if (map != 0L) {... | [
"public",
"int",
"nextClearBit",
"(",
"final",
"int",
"i",
")",
"{",
"int",
"x",
"=",
"i",
">>",
"6",
";",
"// i / 64 with sign extension",
"long",
"w",
"=",
"~",
"bitmap",
".",
"get",
"(",
"x",
")",
";",
"w",
">>>=",
"i",
";",
"if",
"(",
"w",
"!... | Find the index of the next clear bit greater or equal to i.
@param i starting index
@return index of the next clear bit | [
"Find",
"the",
"index",
"of",
"the",
"next",
"clear",
"bit",
"greater",
"or",
"equal",
"to",
"i",
"."
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/buffer/MappeableBitmapContainer.java#L1279-L1294 |
21,874 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/buffer/MappeableBitmapContainer.java | MappeableBitmapContainer.prevClearBit | public int prevClearBit(final int i) {
int x = i >> 6; // i / 64 with sign extension
long w = ~bitmap.get(x);
w <<= 64 - i - 1;
if (w != 0L) {
return i - Long.numberOfLeadingZeros(w);
}
for (--x; x >= 0; --x) {
long map = ~bitmap.get(x);
if (map != 0L) {
return x * 64 +... | java | public int prevClearBit(final int i) {
int x = i >> 6; // i / 64 with sign extension
long w = ~bitmap.get(x);
w <<= 64 - i - 1;
if (w != 0L) {
return i - Long.numberOfLeadingZeros(w);
}
for (--x; x >= 0; --x) {
long map = ~bitmap.get(x);
if (map != 0L) {
return x * 64 +... | [
"public",
"int",
"prevClearBit",
"(",
"final",
"int",
"i",
")",
"{",
"int",
"x",
"=",
"i",
">>",
"6",
";",
"// i / 64 with sign extension",
"long",
"w",
"=",
"~",
"bitmap",
".",
"get",
"(",
"x",
")",
";",
"w",
"<<=",
"64",
"-",
"i",
"-",
"1",
";"... | Find the index of the previous clear bit less than or equal to i.
@param i starting index
@return index of the previous clear bit | [
"Find",
"the",
"index",
"of",
"the",
"previous",
"clear",
"bit",
"less",
"than",
"or",
"equal",
"to",
"i",
"."
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/buffer/MappeableBitmapContainer.java#L1518-L1532 |
21,875 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/buffer/MappeableBitmapContainer.java | MappeableBitmapContainer.toLongArray | public long[] toLongArray() {
long[] answer = new long[bitmap.limit()];
bitmap.rewind();
bitmap.get(answer);
return answer;
} | java | public long[] toLongArray() {
long[] answer = new long[bitmap.limit()];
bitmap.rewind();
bitmap.get(answer);
return answer;
} | [
"public",
"long",
"[",
"]",
"toLongArray",
"(",
")",
"{",
"long",
"[",
"]",
"answer",
"=",
"new",
"long",
"[",
"bitmap",
".",
"limit",
"(",
")",
"]",
";",
"bitmap",
".",
"rewind",
"(",
")",
";",
"bitmap",
".",
"get",
"(",
"answer",
")",
";",
"r... | Create a copy of the content of this container as a long array. This creates a copy.
@return copy of the content as a long array | [
"Create",
"a",
"copy",
"of",
"the",
"content",
"of",
"this",
"container",
"as",
"a",
"long",
"array",
".",
"This",
"creates",
"a",
"copy",
"."
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/buffer/MappeableBitmapContainer.java#L1714-L1719 |
21,876 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/BitmapContainer.java | BitmapContainer.toLongBuffer | public LongBuffer toLongBuffer() {
LongBuffer lb = LongBuffer.allocate(bitmap.length);
lb.put(bitmap);
return lb;
} | java | public LongBuffer toLongBuffer() {
LongBuffer lb = LongBuffer.allocate(bitmap.length);
lb.put(bitmap);
return lb;
} | [
"public",
"LongBuffer",
"toLongBuffer",
"(",
")",
"{",
"LongBuffer",
"lb",
"=",
"LongBuffer",
".",
"allocate",
"(",
"bitmap",
".",
"length",
")",
";",
"lb",
".",
"put",
"(",
"bitmap",
")",
";",
"return",
"lb",
";",
"}"
] | Return the content of this container as a LongBuffer. This creates a copy and might be
relatively slow.
@return the LongBuffer | [
"Return",
"the",
"content",
"of",
"this",
"container",
"as",
"a",
"LongBuffer",
".",
"This",
"creates",
"a",
"copy",
"and",
"might",
"be",
"relatively",
"slow",
"."
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/BitmapContainer.java#L1295-L1299 |
21,877 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/buffer/MappeableArrayContainer.java | MappeableArrayContainer.contains | public static boolean contains(ByteBuffer buf, int position, final short x, int cardinality) {
return BufferUtil.unsignedBinarySearch(buf, position, 0, cardinality, x) >= 0;
} | java | public static boolean contains(ByteBuffer buf, int position, final short x, int cardinality) {
return BufferUtil.unsignedBinarySearch(buf, position, 0, cardinality, x) >= 0;
} | [
"public",
"static",
"boolean",
"contains",
"(",
"ByteBuffer",
"buf",
",",
"int",
"position",
",",
"final",
"short",
"x",
",",
"int",
"cardinality",
")",
"{",
"return",
"BufferUtil",
".",
"unsignedBinarySearch",
"(",
"buf",
",",
"position",
",",
"0",
",",
"... | Checks whether the container contains the value x.
@param buf underlying buffer
@param position starting position of the container in the ByteBuffer
@param x target value x
@param cardinality container cardinality
@return whether the container contains the value x | [
"Checks",
"whether",
"the",
"container",
"contains",
"the",
"value",
"x",
"."
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/buffer/MappeableArrayContainer.java#L374-L376 |
21,878 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/ArrayContainer.java | ArrayContainer.increaseCapacity | private void increaseCapacity(boolean allowIllegalSize) {
int newCapacity = (this.content.length == 0) ? DEFAULT_INIT_SIZE
: this.content.length < 64 ? this.content.length * 2
: this.content.length < 1067 ? this.content.length * 3 / 2
: this.content.length * 5 / 4;
// never a... | java | private void increaseCapacity(boolean allowIllegalSize) {
int newCapacity = (this.content.length == 0) ? DEFAULT_INIT_SIZE
: this.content.length < 64 ? this.content.length * 2
: this.content.length < 1067 ? this.content.length * 3 / 2
: this.content.length * 5 / 4;
// never a... | [
"private",
"void",
"increaseCapacity",
"(",
"boolean",
"allowIllegalSize",
")",
"{",
"int",
"newCapacity",
"=",
"(",
"this",
".",
"content",
".",
"length",
"==",
"0",
")",
"?",
"DEFAULT_INIT_SIZE",
":",
"this",
".",
"content",
".",
"length",
"<",
"64",
"?"... | the illegal container does not return it. | [
"the",
"illegal",
"container",
"does",
"not",
"return",
"it",
"."
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/ArrayContainer.java#L592-L607 |
21,879 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/FastRankRoaringBitmap.java | FastRankRoaringBitmap.preComputeCardinalities | private void preComputeCardinalities() {
if (!cumulatedCardinalitiesCacheIsValid) {
int nbBuckets = highLowContainer.size();
// Ensure the cache size is the right one
if (highToCumulatedCardinality == null || highToCumulatedCardinality.length != nbBuckets) {
highToCumulatedCardinality = n... | java | private void preComputeCardinalities() {
if (!cumulatedCardinalitiesCacheIsValid) {
int nbBuckets = highLowContainer.size();
// Ensure the cache size is the right one
if (highToCumulatedCardinality == null || highToCumulatedCardinality.length != nbBuckets) {
highToCumulatedCardinality = n... | [
"private",
"void",
"preComputeCardinalities",
"(",
")",
"{",
"if",
"(",
"!",
"cumulatedCardinalitiesCacheIsValid",
")",
"{",
"int",
"nbBuckets",
"=",
"highLowContainer",
".",
"size",
"(",
")",
";",
"// Ensure the cache size is the right one",
"if",
"(",
"highToCumulat... | On any .rank or .select operation, we pre-compute all cumulated cardinalities. It will enable
using a binary-search to spot the relevant underlying bucket. We may prefer to cache
cardinality only up-to the selected rank, but it would lead to a more complex implementation | [
"On",
"any",
".",
"rank",
"or",
".",
"select",
"operation",
"we",
"pre",
"-",
"compute",
"all",
"cumulated",
"cardinalities",
".",
"It",
"will",
"enable",
"using",
"a",
"binary",
"-",
"search",
"to",
"spot",
"the",
"relevant",
"underlying",
"bucket",
".",
... | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/FastRankRoaringBitmap.java#L159-L181 |
21,880 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/buffer/ImmutableRoaringBitmap.java | ImmutableRoaringBitmap.contains | public boolean contains(long minimum, long supremum) {
MutableRoaringBitmap.rangeSanityCheck(minimum, supremum);
short firstKey = highbits(minimum);
short lastKey = highbits(supremum);
int span = BufferUtil.toIntUnsigned(lastKey) - BufferUtil.toIntUnsigned(firstKey);
int len = highLowContainer.size(... | java | public boolean contains(long minimum, long supremum) {
MutableRoaringBitmap.rangeSanityCheck(minimum, supremum);
short firstKey = highbits(minimum);
short lastKey = highbits(supremum);
int span = BufferUtil.toIntUnsigned(lastKey) - BufferUtil.toIntUnsigned(firstKey);
int len = highLowContainer.size(... | [
"public",
"boolean",
"contains",
"(",
"long",
"minimum",
",",
"long",
"supremum",
")",
"{",
"MutableRoaringBitmap",
".",
"rangeSanityCheck",
"(",
"minimum",
",",
"supremum",
")",
";",
"short",
"firstKey",
"=",
"highbits",
"(",
"minimum",
")",
";",
"short",
"... | Checks if the bitmap contains the range.
@param minimum the inclusive lower bound of the range
@param supremum the exclusive upper bound of the range
@return whether the bitmap intersects with the range | [
"Checks",
"if",
"the",
"bitmap",
"contains",
"the",
"range",
"."
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/buffer/ImmutableRoaringBitmap.java#L1003-L1036 |
21,881 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/buffer/ImmutableRoaringBitmap.java | ImmutableRoaringBitmap.toArray | @Override
public int[] toArray() {
final int[] array = new int[this.getCardinality()];
int pos = 0, pos2 = 0;
while (pos < this.highLowContainer.size()) {
final int hs = BufferUtil.toIntUnsigned(this.highLowContainer.getKeyAtIndex(pos)) << 16;
final MappeableContainer c = this.highLowContainer... | java | @Override
public int[] toArray() {
final int[] array = new int[this.getCardinality()];
int pos = 0, pos2 = 0;
while (pos < this.highLowContainer.size()) {
final int hs = BufferUtil.toIntUnsigned(this.highLowContainer.getKeyAtIndex(pos)) << 16;
final MappeableContainer c = this.highLowContainer... | [
"@",
"Override",
"public",
"int",
"[",
"]",
"toArray",
"(",
")",
"{",
"final",
"int",
"[",
"]",
"array",
"=",
"new",
"int",
"[",
"this",
".",
"getCardinality",
"(",
")",
"]",
";",
"int",
"pos",
"=",
"0",
",",
"pos2",
"=",
"0",
";",
"while",
"("... | Return the set values as an array if the cardinality is less
than 2147483648. The integer values are in sorted order.
@return array representing the set values. | [
"Return",
"the",
"set",
"values",
"as",
"an",
"array",
"if",
"the",
"cardinality",
"is",
"less",
"than",
"2147483648",
".",
"The",
"integer",
"values",
"are",
"in",
"sorted",
"order",
"."
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/buffer/ImmutableRoaringBitmap.java#L1725-L1736 |
21,882 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/buffer/ImmutableRoaringBitmap.java | ImmutableRoaringBitmap.toMutableRoaringBitmap | public MutableRoaringBitmap toMutableRoaringBitmap() {
MutableRoaringBitmap c = new MutableRoaringBitmap();
MappeableContainerPointer mcp = highLowContainer.getContainerPointer();
while (mcp.hasContainer()) {
c.getMappeableRoaringArray().appendCopy(mcp.key(), mcp.getContainer());
mcp.advance();
... | java | public MutableRoaringBitmap toMutableRoaringBitmap() {
MutableRoaringBitmap c = new MutableRoaringBitmap();
MappeableContainerPointer mcp = highLowContainer.getContainerPointer();
while (mcp.hasContainer()) {
c.getMappeableRoaringArray().appendCopy(mcp.key(), mcp.getContainer());
mcp.advance();
... | [
"public",
"MutableRoaringBitmap",
"toMutableRoaringBitmap",
"(",
")",
"{",
"MutableRoaringBitmap",
"c",
"=",
"new",
"MutableRoaringBitmap",
"(",
")",
";",
"MappeableContainerPointer",
"mcp",
"=",
"highLowContainer",
".",
"getContainerPointer",
"(",
")",
";",
"while",
... | Copies the content of this bitmap to a bitmap that can be modified.
@return a mutable bitmap. | [
"Copies",
"the",
"content",
"of",
"this",
"bitmap",
"to",
"a",
"bitmap",
"that",
"can",
"be",
"modified",
"."
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/buffer/ImmutableRoaringBitmap.java#L1743-L1751 |
21,883 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/insights/BitmapAnalyser.java | BitmapAnalyser.analyse | public static BitmapStatistics analyse(RoaringBitmap r) {
int acCount = 0;
int acCardinalitySum = 0;
int bcCount = 0;
int rcCount = 0;
ContainerPointer cp = r.getContainerPointer();
while (cp.getContainer() != null) {
if (cp.isBitmapContainer()) {
bcCount += 1;
} else if (cp.... | java | public static BitmapStatistics analyse(RoaringBitmap r) {
int acCount = 0;
int acCardinalitySum = 0;
int bcCount = 0;
int rcCount = 0;
ContainerPointer cp = r.getContainerPointer();
while (cp.getContainer() != null) {
if (cp.isBitmapContainer()) {
bcCount += 1;
} else if (cp.... | [
"public",
"static",
"BitmapStatistics",
"analyse",
"(",
"RoaringBitmap",
"r",
")",
"{",
"int",
"acCount",
"=",
"0",
";",
"int",
"acCardinalitySum",
"=",
"0",
";",
"int",
"bcCount",
"=",
"0",
";",
"int",
"rcCount",
"=",
"0",
";",
"ContainerPointer",
"cp",
... | Analyze the internal representation of bitmap
@param r the bitmap
@return the statistics | [
"Analyze",
"the",
"internal",
"representation",
"of",
"bitmap"
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/insights/BitmapAnalyser.java#L15-L35 |
21,884 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/insights/BitmapAnalyser.java | BitmapAnalyser.analyse | public static BitmapStatistics analyse(Collection<? extends RoaringBitmap> bitmaps) {
return bitmaps
.stream()
.reduce(
BitmapStatistics.empty,
(acc, r) -> acc.merge(BitmapAnalyser.analyse(r)),
BitmapStatistics::merge);
} | java | public static BitmapStatistics analyse(Collection<? extends RoaringBitmap> bitmaps) {
return bitmaps
.stream()
.reduce(
BitmapStatistics.empty,
(acc, r) -> acc.merge(BitmapAnalyser.analyse(r)),
BitmapStatistics::merge);
} | [
"public",
"static",
"BitmapStatistics",
"analyse",
"(",
"Collection",
"<",
"?",
"extends",
"RoaringBitmap",
">",
"bitmaps",
")",
"{",
"return",
"bitmaps",
".",
"stream",
"(",
")",
".",
"reduce",
"(",
"BitmapStatistics",
".",
"empty",
",",
"(",
"acc",
",",
... | Analyze the internal representation of bitmaps
@param bitmaps the bitmaps
@return the statistics | [
"Analyze",
"the",
"internal",
"representation",
"of",
"bitmaps"
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/insights/BitmapAnalyser.java#L42-L49 |
21,885 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/buffer/BufferUtil.java | BufferUtil.getSizeInBytesFromCardinalityEtc | protected static int getSizeInBytesFromCardinalityEtc(int card, int numRuns,
boolean isRunEncoded) {
if (isRunEncoded) {
return 2 + numRuns * 2 * 2; // each run uses 2 shorts, plus the initial short giving num runs
}
boolean isBitmap = card > MappeableArrayContainer.DEFAULT_MAX_SIZE;
if (isB... | java | protected static int getSizeInBytesFromCardinalityEtc(int card, int numRuns,
boolean isRunEncoded) {
if (isRunEncoded) {
return 2 + numRuns * 2 * 2; // each run uses 2 shorts, plus the initial short giving num runs
}
boolean isBitmap = card > MappeableArrayContainer.DEFAULT_MAX_SIZE;
if (isB... | [
"protected",
"static",
"int",
"getSizeInBytesFromCardinalityEtc",
"(",
"int",
"card",
",",
"int",
"numRuns",
",",
"boolean",
"isRunEncoded",
")",
"{",
"if",
"(",
"isRunEncoded",
")",
"{",
"return",
"2",
"+",
"numRuns",
"*",
"2",
"*",
"2",
";",
"// each run u... | From the cardinality of a container, compute the corresponding size in bytes of the container.
Additional information is required if the container is run encoded.
@param card the cardinality if this is not run encoded, otherwise ignored
@param numRuns number of runs if run encoded, othewise ignored
@param isRunEncoded... | [
"From",
"the",
"cardinality",
"of",
"a",
"container",
"compute",
"the",
"corresponding",
"size",
"in",
"bytes",
"of",
"the",
"container",
".",
"Additional",
"information",
"is",
"required",
"if",
"the",
"container",
"is",
"run",
"encoded",
"."
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/buffer/BufferUtil.java#L492-L504 |
21,886 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/buffer/BufferUtil.java | BufferUtil.unsignedIntersects | public static boolean unsignedIntersects(ShortBuffer set1, int length1, ShortBuffer set2,
int length2) {
if ((0 == length1) || (0 == length2)) {
return false;
}
int k1 = 0;
int k2 = 0;
// could be more efficient with galloping
short s1 = set1.get(k1);
short s2 = set2.get(k2);
... | java | public static boolean unsignedIntersects(ShortBuffer set1, int length1, ShortBuffer set2,
int length2) {
if ((0 == length1) || (0 == length2)) {
return false;
}
int k1 = 0;
int k2 = 0;
// could be more efficient with galloping
short s1 = set1.get(k1);
short s2 = set2.get(k2);
... | [
"public",
"static",
"boolean",
"unsignedIntersects",
"(",
"ShortBuffer",
"set1",
",",
"int",
"length1",
",",
"ShortBuffer",
"set2",
",",
"int",
"length2",
")",
"{",
"if",
"(",
"(",
"0",
"==",
"length1",
")",
"||",
"(",
"0",
"==",
"length2",
")",
")",
"... | Checks if two arrays intersect
@param set1 first array
@param length1 length of first array
@param set2 second array
@param length2 length of second array
@return true if they intersect | [
"Checks",
"if",
"two",
"arrays",
"intersect"
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/buffer/BufferUtil.java#L762-L797 |
21,887 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/Util.java | Util.fillArrayANDNOT | public static void fillArrayANDNOT(final short[] container, final long[] bitmap1,
final long[] bitmap2) {
int pos = 0;
if (bitmap1.length != bitmap2.length) {
throw new IllegalArgumentException("not supported");
}
for (int k = 0; k < bitmap1.length; ++k) {
long bitset = bitmap1[k] & (~... | java | public static void fillArrayANDNOT(final short[] container, final long[] bitmap1,
final long[] bitmap2) {
int pos = 0;
if (bitmap1.length != bitmap2.length) {
throw new IllegalArgumentException("not supported");
}
for (int k = 0; k < bitmap1.length; ++k) {
long bitset = bitmap1[k] & (~... | [
"public",
"static",
"void",
"fillArrayANDNOT",
"(",
"final",
"short",
"[",
"]",
"container",
",",
"final",
"long",
"[",
"]",
"bitmap1",
",",
"final",
"long",
"[",
"]",
"bitmap2",
")",
"{",
"int",
"pos",
"=",
"0",
";",
"if",
"(",
"bitmap1",
".",
"leng... | Compute the bitwise ANDNOT between two long arrays and write the set bits in the container.
@param container where we write
@param bitmap1 first bitmap
@param bitmap2 second bitmap | [
"Compute",
"the",
"bitwise",
"ANDNOT",
"between",
"two",
"long",
"arrays",
"and",
"write",
"the",
"set",
"bits",
"in",
"the",
"container",
"."
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/Util.java#L244-L257 |
21,888 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/Util.java | Util.flipBitmapRange | public static void flipBitmapRange(long[] bitmap, int start, int end) {
if (start == end) {
return;
}
int firstword = start / 64;
int endword = (end - 1) / 64;
bitmap[firstword] ^= ~(~0L << start);
for (int i = firstword; i < endword; i++) {
bitmap[i] = ~bitmap[i];
}
bitmap[e... | java | public static void flipBitmapRange(long[] bitmap, int start, int end) {
if (start == end) {
return;
}
int firstword = start / 64;
int endword = (end - 1) / 64;
bitmap[firstword] ^= ~(~0L << start);
for (int i = firstword; i < endword; i++) {
bitmap[i] = ~bitmap[i];
}
bitmap[e... | [
"public",
"static",
"void",
"flipBitmapRange",
"(",
"long",
"[",
"]",
"bitmap",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"if",
"(",
"start",
"==",
"end",
")",
"{",
"return",
";",
"}",
"int",
"firstword",
"=",
"start",
"/",
"64",
";",
"int"... | flip bits at start, start+1,..., end-1
@param bitmap array of words to be modified
@param start first index to be modified (inclusive)
@param end last index to be modified (exclusive) | [
"flip",
"bits",
"at",
"start",
"start",
"+",
"1",
"...",
"end",
"-",
"1"
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/Util.java#L288-L299 |
21,889 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/Util.java | Util.hybridUnsignedBinarySearch | protected static int hybridUnsignedBinarySearch(final short[] array, final int begin,
final int end, final short k) {
int ikey = toIntUnsigned(k);
// next line accelerates the possibly common case where the value would
// be inserted at the end
if ((end > 0) && (toIntUnsigned(array[end - 1]) < ike... | java | protected static int hybridUnsignedBinarySearch(final short[] array, final int begin,
final int end, final short k) {
int ikey = toIntUnsigned(k);
// next line accelerates the possibly common case where the value would
// be inserted at the end
if ((end > 0) && (toIntUnsigned(array[end - 1]) < ike... | [
"protected",
"static",
"int",
"hybridUnsignedBinarySearch",
"(",
"final",
"short",
"[",
"]",
"array",
",",
"final",
"int",
"begin",
",",
"final",
"int",
"end",
",",
"final",
"short",
"k",
")",
"{",
"int",
"ikey",
"=",
"toIntUnsigned",
"(",
"k",
")",
";",... | starts with binary search and finishes with a sequential search | [
"starts",
"with",
"binary",
"search",
"and",
"finishes",
"with",
"a",
"sequential",
"search"
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/Util.java#L363-L398 |
21,890 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/Util.java | Util.setBitmapRange | public static void setBitmapRange(long[] bitmap, int start, int end) {
if (start == end) {
return;
}
int firstword = start / 64;
int endword = (end - 1) / 64;
if (firstword == endword) {
bitmap[firstword] |= (~0L << start) & (~0L >>> -end);
return;
}
bitmap[firstword] |= ~0... | java | public static void setBitmapRange(long[] bitmap, int start, int end) {
if (start == end) {
return;
}
int firstword = start / 64;
int endword = (end - 1) / 64;
if (firstword == endword) {
bitmap[firstword] |= (~0L << start) & (~0L >>> -end);
return;
}
bitmap[firstword] |= ~0... | [
"public",
"static",
"void",
"setBitmapRange",
"(",
"long",
"[",
"]",
"bitmap",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"if",
"(",
"start",
"==",
"end",
")",
"{",
"return",
";",
"}",
"int",
"firstword",
"=",
"start",
"/",
"64",
";",
"int",... | set bits at start, start+1,..., end-1
@param bitmap array of words to be modified
@param start first index to be modified (inclusive)
@param end last index to be modified (exclusive) | [
"set",
"bits",
"at",
"start",
"start",
"+",
"1",
"...",
"end",
"-",
"1"
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/Util.java#L501-L516 |
21,891 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/Util.java | Util.unsignedIntersect2by2 | public static int unsignedIntersect2by2(final short[] set1, final int length1, final short[] set2,
final int length2, final short[] buffer) {
final int THRESHOLD = 25;
if (set1.length * THRESHOLD < set2.length) {
return unsignedOneSidedGallopingIntersect2by2(set1, length1, set2, length2, buffer);
... | java | public static int unsignedIntersect2by2(final short[] set1, final int length1, final short[] set2,
final int length2, final short[] buffer) {
final int THRESHOLD = 25;
if (set1.length * THRESHOLD < set2.length) {
return unsignedOneSidedGallopingIntersect2by2(set1, length1, set2, length2, buffer);
... | [
"public",
"static",
"int",
"unsignedIntersect2by2",
"(",
"final",
"short",
"[",
"]",
"set1",
",",
"final",
"int",
"length1",
",",
"final",
"short",
"[",
"]",
"set2",
",",
"final",
"int",
"length2",
",",
"final",
"short",
"[",
"]",
"buffer",
")",
"{",
"... | Intersect two sorted lists and write the result to the provided output array
@param set1 first array
@param length1 length of first array
@param set2 second array
@param length2 length of second array
@param buffer output array
@return cardinality of the intersection | [
"Intersect",
"two",
"sorted",
"lists",
"and",
"write",
"the",
"result",
"to",
"the",
"provided",
"output",
"array"
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/Util.java#L779-L789 |
21,892 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/Util.java | Util.unsignedUnion2by2 | public static int unsignedUnion2by2(
final short[] set1, final int offset1, final int length1,
final short[] set2, final int offset2, final int length2,
final short[] buffer) {
if (0 == length2) {
System.arraycopy(set1, offset1, buffer, 0, length1);
return length1;
}
... | java | public static int unsignedUnion2by2(
final short[] set1, final int offset1, final int length1,
final short[] set2, final int offset2, final int length2,
final short[] buffer) {
if (0 == length2) {
System.arraycopy(set1, offset1, buffer, 0, length1);
return length1;
}
... | [
"public",
"static",
"int",
"unsignedUnion2by2",
"(",
"final",
"short",
"[",
"]",
"set1",
",",
"final",
"int",
"offset1",
",",
"final",
"int",
"length1",
",",
"final",
"short",
"[",
"]",
"set2",
",",
"final",
"int",
"offset2",
",",
"final",
"int",
"length... | Unite two sorted lists and write the result to the provided output array
@param set1 first array
@param offset1 offset of first array
@param length1 length of first array
@param set2 second array
@param offset2 offset of second array
@param length2 length of second array
@param buffer output array
@return cardinality ... | [
"Unite",
"two",
"sorted",
"lists",
"and",
"write",
"the",
"result",
"to",
"the",
"provided",
"output",
"array"
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/Util.java#L1005-L1057 |
21,893 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/Util.java | Util.partialRadixSort | public static void partialRadixSort(int[] data) {
final int radix = 8;
int shift = 16;
int mask = 0xFF0000;
int[] copy = new int[data.length];
int[] histogram = new int[(1 << radix) + 1];
while (shift < 32) {
for (int i = 0; i < data.length; ++i) {
++histogram[((data[i] & mask) >>>... | java | public static void partialRadixSort(int[] data) {
final int radix = 8;
int shift = 16;
int mask = 0xFF0000;
int[] copy = new int[data.length];
int[] histogram = new int[(1 << radix) + 1];
while (shift < 32) {
for (int i = 0; i < data.length; ++i) {
++histogram[((data[i] & mask) >>>... | [
"public",
"static",
"void",
"partialRadixSort",
"(",
"int",
"[",
"]",
"data",
")",
"{",
"final",
"int",
"radix",
"=",
"8",
";",
"int",
"shift",
"=",
"16",
";",
"int",
"mask",
"=",
"0xFF0000",
";",
"int",
"[",
"]",
"copy",
"=",
"new",
"int",
"[",
... | Sorts the data by the 16 bit prefix.
@param data - the data | [
"Sorts",
"the",
"data",
"by",
"the",
"16",
"bit",
"prefix",
"."
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/Util.java#L1082-L1103 |
21,894 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/RoaringBitmap.java | RoaringBitmap.bitmapOfUnordered | public static RoaringBitmap bitmapOfUnordered(final int... data) {
RoaringBitmapWriter<RoaringBitmap> writer = writer().constantMemory()
.doPartialRadixSort().get();
writer.addMany(data);
writer.flush();
return writer.getUnderlying();
} | java | public static RoaringBitmap bitmapOfUnordered(final int... data) {
RoaringBitmapWriter<RoaringBitmap> writer = writer().constantMemory()
.doPartialRadixSort().get();
writer.addMany(data);
writer.flush();
return writer.getUnderlying();
} | [
"public",
"static",
"RoaringBitmap",
"bitmapOfUnordered",
"(",
"final",
"int",
"...",
"data",
")",
"{",
"RoaringBitmapWriter",
"<",
"RoaringBitmap",
">",
"writer",
"=",
"writer",
"(",
")",
".",
"constantMemory",
"(",
")",
".",
"doPartialRadixSort",
"(",
")",
"... | Efficiently builds a RoaringBitmap from unordered data
@param data unsorted data
@return a new bitmap | [
"Efficiently",
"builds",
"a",
"RoaringBitmap",
"from",
"unordered",
"data"
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/RoaringBitmap.java#L536-L542 |
21,895 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/RoaringBitmap.java | RoaringBitmap.intersects | public static boolean intersects(final RoaringBitmap x1, final RoaringBitmap x2) {
final int length1 = x1.highLowContainer.size(), length2 = x2.highLowContainer.size();
int pos1 = 0, pos2 = 0;
while (pos1 < length1 && pos2 < length2) {
final short s1 = x1.highLowContainer.getKeyAtIndex(pos1);
f... | java | public static boolean intersects(final RoaringBitmap x1, final RoaringBitmap x2) {
final int length1 = x1.highLowContainer.size(), length2 = x2.highLowContainer.size();
int pos1 = 0, pos2 = 0;
while (pos1 < length1 && pos2 < length2) {
final short s1 = x1.highLowContainer.getKeyAtIndex(pos1);
f... | [
"public",
"static",
"boolean",
"intersects",
"(",
"final",
"RoaringBitmap",
"x1",
",",
"final",
"RoaringBitmap",
"x2",
")",
"{",
"final",
"int",
"length1",
"=",
"x1",
".",
"highLowContainer",
".",
"size",
"(",
")",
",",
"length2",
"=",
"x2",
".",
"highLowC... | Checks whether the two bitmaps intersect. This can be much faster than calling "and" and
checking the cardinality of the result.
@param x1 first bitmap
@param x2 other bitmap
@return true if they intersect | [
"Checks",
"whether",
"the",
"two",
"bitmaps",
"intersect",
".",
"This",
"can",
"be",
"much",
"faster",
"than",
"calling",
"and",
"and",
"checking",
"the",
"cardinality",
"of",
"the",
"result",
"."
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/RoaringBitmap.java#L625-L647 |
21,896 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/RoaringBitmap.java | RoaringBitmap.add | public void add(final long rangeStart, final long rangeEnd) {
rangeSanityCheck(rangeStart, rangeEnd);
if (rangeStart >= rangeEnd) {
return; // empty range
}
final int hbStart = Util.toIntUnsigned(Util.highbits(rangeStart));
final int lbStart = Util.toIntUnsigned(Util.lowbits(rangeStart));
... | java | public void add(final long rangeStart, final long rangeEnd) {
rangeSanityCheck(rangeStart, rangeEnd);
if (rangeStart >= rangeEnd) {
return; // empty range
}
final int hbStart = Util.toIntUnsigned(Util.highbits(rangeStart));
final int lbStart = Util.toIntUnsigned(Util.lowbits(rangeStart));
... | [
"public",
"void",
"add",
"(",
"final",
"long",
"rangeStart",
",",
"final",
"long",
"rangeEnd",
")",
"{",
"rangeSanityCheck",
"(",
"rangeStart",
",",
"rangeEnd",
")",
";",
"if",
"(",
"rangeStart",
">=",
"rangeEnd",
")",
"{",
"return",
";",
"// empty range",
... | Add to the current bitmap all integers in [rangeStart,rangeEnd).
@param rangeStart inclusive beginning of range
@param rangeEnd exclusive ending of range | [
"Add",
"to",
"the",
"current",
"bitmap",
"all",
"integers",
"in",
"[",
"rangeStart",
"rangeEnd",
")",
"."
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/RoaringBitmap.java#L1069-L1096 |
21,897 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/RoaringBitmap.java | RoaringBitmap.isHammingSimilar | public boolean isHammingSimilar(RoaringBitmap other, int tolerance) {
final int size1 = highLowContainer.size();
final int size2 = other.highLowContainer.size();
int pos1 = 0;
int pos2 = 0;
int budget = tolerance;
while(budget >= 0 && pos1 < size1 && pos2 < size2) {
final short key1 = this... | java | public boolean isHammingSimilar(RoaringBitmap other, int tolerance) {
final int size1 = highLowContainer.size();
final int size2 = other.highLowContainer.size();
int pos1 = 0;
int pos2 = 0;
int budget = tolerance;
while(budget >= 0 && pos1 < size1 && pos2 < size2) {
final short key1 = this... | [
"public",
"boolean",
"isHammingSimilar",
"(",
"RoaringBitmap",
"other",
",",
"int",
"tolerance",
")",
"{",
"final",
"int",
"size1",
"=",
"highLowContainer",
".",
"size",
"(",
")",
";",
"final",
"int",
"size2",
"=",
"other",
".",
"highLowContainer",
".",
"siz... | Returns true if the other bitmap has no more than tolerance bits
differing from this bitmap. The other may be transformed into a bitmap equal
to this bitmap in no more than tolerance bit flips if this method returns true.
@param other the bitmap to compare to
@param tolerance the maximum number of bits that may differ... | [
"Returns",
"true",
"if",
"the",
"other",
"bitmap",
"has",
"no",
"more",
"than",
"tolerance",
"bits",
"differing",
"from",
"this",
"bitmap",
".",
"The",
"other",
"may",
"be",
"transformed",
"into",
"a",
"bitmap",
"equal",
"to",
"this",
"bitmap",
"in",
"no",... | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/RoaringBitmap.java#L1515-L1547 |
21,898 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/RoaringBitmap.java | RoaringBitmap.hasRunCompression | public boolean hasRunCompression() {
for (int i = 0; i < this.highLowContainer.size(); i++) {
Container c = this.highLowContainer.getContainerAtIndex(i);
if (c instanceof RunContainer) {
return true;
}
}
return false;
} | java | public boolean hasRunCompression() {
for (int i = 0; i < this.highLowContainer.size(); i++) {
Container c = this.highLowContainer.getContainerAtIndex(i);
if (c instanceof RunContainer) {
return true;
}
}
return false;
} | [
"public",
"boolean",
"hasRunCompression",
"(",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"highLowContainer",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"Container",
"c",
"=",
"this",
".",
"highLowContainer",
".",
... | Check whether this bitmap has had its runs compressed.
@return whether this bitmap has run compression | [
"Check",
"whether",
"this",
"bitmap",
"has",
"had",
"its",
"runs",
"compressed",
"."
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/RoaringBitmap.java#L1793-L1801 |
21,899 | RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/RoaringBitmap.java | RoaringBitmap.runOptimize | public boolean runOptimize() {
boolean answer = false;
for (int i = 0; i < this.highLowContainer.size(); i++) {
Container c = this.highLowContainer.getContainerAtIndex(i).runOptimize();
if (c instanceof RunContainer) {
answer = true;
}
this.highLowContainer.setContainerAtIndex(i,... | java | public boolean runOptimize() {
boolean answer = false;
for (int i = 0; i < this.highLowContainer.size(); i++) {
Container c = this.highLowContainer.getContainerAtIndex(i).runOptimize();
if (c instanceof RunContainer) {
answer = true;
}
this.highLowContainer.setContainerAtIndex(i,... | [
"public",
"boolean",
"runOptimize",
"(",
")",
"{",
"boolean",
"answer",
"=",
"false",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"highLowContainer",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"Container",
"c",
"=",
"... | Use a run-length encoding where it is more space efficient
@return whether a change was applied | [
"Use",
"a",
"run",
"-",
"length",
"encoding",
"where",
"it",
"is",
"more",
"space",
"efficient"
] | b26fd0a1330fd4d2877f4d74feb69ceb812e9efa | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/RoaringBitmap.java#L2270-L2280 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.