本文整理汇总了Java中java.util.Collections.indexOfSubList方法的典型用法代码示例。如果您正苦于以下问题:Java Collections.indexOfSubList方法的具体用法?Java Collections.indexOfSubList怎么用?Java Collections.indexOfSubList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Collections
的用法示例。
在下文中一共展示了Collections.indexOfSubList方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: matches
import java.util.Collections; //导入方法依赖的package包/类
@Override
public boolean matches(Issue issue) {
URI actualValue = getActualValue.apply(issue);
if (actualValue == null)
return false;
List<String> actualSegments = actualValue.segmentsList();
List<String> expectedSegments = expectedPattern.segmentsList();
switch (mode) {
case StartsWith:
return Collections.indexOfSubList(actualSegments, expectedSegments) == 0;
case EndsWith:
return Collections.lastIndexOfSubList(actualSegments, expectedSegments) == actualSegments.size()
- expectedSegments.size();
case Equals:
return actualSegments.equals(expectedSegments);
}
throw new IllegalStateException("Unknown URI property matching mode: " + mode);
}
示例2: checkForContainingAndRemoveWrongSets
import java.util.Collections; //导入方法依赖的package包/类
private static List<PeakList> checkForContainingAndRemoveWrongSets(List<PeakList> listOfPeakLists) {
List<PeakList> tempListOfPeakLists = new ArrayList<>(listOfPeakLists);
for (PeakList peakList1 : listOfPeakLists) {
for (PeakList peakList2 : listOfPeakLists) {
if (peakList1.equals(peakList2)) {
continue;
}
if (Collections.indexOfSubList(peakList1.getPeakList(), peakList2.getPeakList()) != -1) {
if (peakList1.size() > peakList2.size()) {
tempListOfPeakLists.remove(peakList2);
} else if (peakList1.size() < peakList2.size()) {
tempListOfPeakLists.remove(peakList1);
}
}
}
}
tempListOfPeakLists = checkIfRemovedCorrectly(tempListOfPeakLists);
return tempListOfPeakLists;
}
示例3: isSubChain
import java.util.Collections; //导入方法依赖的package包/类
private boolean isSubChain ( final List<ViewInstanceDescriptor> descriptors )
{
if ( this.currentChain == null || this.currentChain.isEmpty () )
{
return false;
}
final int idx = Collections.indexOfSubList ( this.currentChain, descriptors );
return idx >= 0;
}
示例4: in
import java.util.Collections; //导入方法依赖的package包/类
private boolean in(List<String> cycle, Set<List<String>> cycles) {
List<String> superCycle = new ArrayList<>(cycle);
superCycle.remove(superCycle.size() - 1);
superCycle.addAll(cycle);
for (List<String> foundCycle: cycles) {
if (foundCycle.size() == cycle.size() && Collections.indexOfSubList(superCycle, foundCycle) != -1)
return true;
}
return false;
}
示例5: main
import java.util.Collections; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
ToolBox tb = new ToolBox();
new JavacTask(tb).sources(TestSrc).run();
List<String> res = new JavapTask(tb)
.options("-v")
.classes("AnnotationDefault.class")
.run()
.getOutputLines(Task.OutputKind.DIRECT);
List<String> goldenList = tb.split(ExpectedSubstring, "\n");
Boolean found = Collections.indexOfSubList(res, goldenList) > -1;
Assert.check(found, "expected output not found: " + ExpectedSubstring);
}
示例6: main
import java.util.Collections; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
ToolBox tb = new ToolBox();
new JavacTask(tb).sources(TestSrc).run();
List<String> res = new JavapTask(tb)
.options("-v")
.classes("Sample.class")
.run()
.getOutputLines(Task.OutputKind.DIRECT);
List<String> expectedList = tb.split(ExpectedSubstring, "\n");
Boolean found = Collections.indexOfSubList(res, expectedList) > -1;
Assert.check(found, "expected output not found: " + ExpectedSubstring);
}
示例7: checkPath
import java.util.Collections; //导入方法依赖的package包/类
void checkPath(StandardLocation l, Mode m, List<File> expect) {
List<File> files = getLocation(l);
if (files == null) {
error("location is unset: " + l);
return;
}
switch (m) {
case EQUALS:
if (!Objects.equals(files, expect)) {
error("location does not match the expected files: " + l);
out.println("found: " + files);
out.println("expect: " + expect);
}
break;
case CONTAINS:
int containsIndex = Collections.indexOfSubList(files, expect);
if (containsIndex == -1) {
error("location does not contain the expected files: " + l);
out.println("found: " + files);
out.println("expect: " + expect);
}
break;
case STARTS_WITH:
int startsIndex = Collections.indexOfSubList(files, expect);
if (startsIndex != 0) {
error("location does not start with the expected files: " + l);
out.println("found: " + files);
out.println("expect: " + expect);
}
break;
case ENDS_WITH:
int endsIndex = Collections.lastIndexOfSubList(files, expect);
if (endsIndex != files.size() - expect.size()) {
error("location does not end with the expected files: " + l);
out.println("found: " + files);
out.println("expect: " + expect);
}
break;
}
}