本文整理了Java中java.util.LinkedList.subList()
方法的一些代码示例,展示了LinkedList.subList()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LinkedList.subList()
方法的具体详情如下:
包路径:java.util.LinkedList
类名称:LinkedList
方法名:subList
暂无
代码示例来源:origin: hankcs/HanLP
@Override
public List<Pipe<M, M>> subList(int fromIndex, int toIndex)
{
return pipeList.subList(fromIndex, toIndex);
}
}
代码示例来源:origin: ronmamo/reflections
public static Class<?> resolveClassOf(final Class element) throws ClassNotFoundException {
Class<?> cursor = element;
LinkedList<String> ognl = Lists.newLinkedList();
while (cursor != null) {
ognl.addFirst(cursor.getSimpleName());
cursor = cursor.getDeclaringClass();
}
String classOgnl = Joiner.on(".").join(ognl.subList(1, ognl.size())).replace(".$", "$");
return Class.forName(classOgnl);
}
代码示例来源:origin: org.reflections/reflections
public static Class<?> resolveClassOf(final Class element) throws ClassNotFoundException {
Class<?> cursor = element;
LinkedList<String> ognl = Lists.newLinkedList();
while (cursor != null) {
ognl.addFirst(cursor.getSimpleName());
cursor = cursor.getDeclaringClass();
}
String classOgnl = Joiner.on(".").join(ognl.subList(1, ognl.size())).replace(".$", "$");
return Class.forName(classOgnl);
}
代码示例来源:origin: apache/incubator-gobblin
private String computePath(T node) {
StringBuilder sb = new StringBuilder();
for (T t : this.nodesList.subList(this.nodesList.indexOf(node), this.nodesList.size())) {
sb.append(t).append(" -> ");
}
sb.append(node);
return sb.toString();
}
}
代码示例来源:origin: shekhargulati/99-problems
public static <T> T kthRecursive(final LinkedList<T> list, final int k) {
if (k == 0) {
return list.getFirst();
}
return kthRecursive(new LinkedList<>(list.subList(1, list.size())), k - 1);
}
代码示例来源:origin: shekhargulati/99-problems
public static <T> T secondLastRecursion(LinkedList<T> list) {
if (list.size() < 2) {
throw new NoSuchElementException("Can't find secondLast element from a list with less than 2 elements");
}
if (list.size() == 2) {
return list.getFirst();
}
return secondLastRecursion(new LinkedList<>(list.subList(1, list.size())));
}
}
代码示例来源:origin: org.codehaus.plexus/plexus-utils
/**
* This method will be called when an edge leading to given vertex was added and we want to check if introduction of
* this edge has not resulted in apparition of cycle in the graph
*
* @param vertex
* @param vertexStateMap
* @return
*/
public static List<String> introducesCycle( final Vertex vertex, final Map<Vertex, Integer> vertexStateMap )
{
final LinkedList<String> cycleStack = new LinkedList<String>();
final boolean hasCycle = dfsVisit( vertex, cycleStack, vertexStateMap );
if ( hasCycle )
{
// we have a situation like: [b, a, c, d, b, f, g, h].
// Label of Vertex which introduced the cycle is at the first position in the list
// We have to find second occurrence of this label and use its position in the list
// for getting the sublist of vertex labels of cycle participants
//
// So in our case we are searching for [b, a, c, d, b]
final String label = cycleStack.getFirst();
final int pos = cycleStack.lastIndexOf( label );
final List<String> cycle = cycleStack.subList( 0, pos + 1 );
Collections.reverse( cycle );
return cycle;
}
return null;
}
代码示例来源:origin: FudanNLP/fnlp
public static void main(String[] args) throws Exception {
String datapath = "../data";
FNLPCorpus corpus = new FNLPCorpus();
corpus.read(datapath + "/FNLPDATA/WeiboFTB(v1.0).dat", null);
System.out.println(corpus.getDocumenNum());
System.out.println(corpus.getSentenceNum());
System.out.println(corpus.getAllPOS());
FNLPDoc doc = corpus.docs.get(0);
List<FNLPSent> train = doc.sentences.subList(0, 3000);
List<FNLPSent> test = doc.sentences.subList(3000,doc.sentences.size());
doc.sentences = new LinkedList<FNLPSent>();
doc.sentences.addAll(train);
corpus.writeOne(datapath + "/FNLPDATA/WeiboFTB(v1.0)-train.dat");
System.out.println(corpus.getSentenceNum());
System.out.println(corpus.getAllPOS().size());
doc.sentences = new LinkedList<FNLPSent>();
doc.sentences.addAll(test);
corpus.writeOne(datapath + "/FNLPDATA/WeiboFTB(v1.0)-test.dat");
System.out.println(corpus.getSentenceNum());
System.out.println(corpus.getAllPOS().size());
}
代码示例来源:origin: stanfordnlp/CoreNLP
body = new LinkedList<>(body.subList(0, body.size() - 1));
代码示例来源:origin: apache/ignite
delimQueue.removeAll(delimQueue.subList(replaceIdx, delimQueue.size()));
代码示例来源:origin: cmusphinx/sphinx4
inSpeech = true;
outputQueue.add(new SpeechStartSignal(cdata.getCollectTime() - speechLeader - startSpeechFrames));
outputQueue.addAll(inputQueue.subList(
Math.max(0, inputQueue.size() - startSpeechFrames - speechLeaderFrames), inputQueue.size()));
inputQueue.clear();
代码示例来源:origin: org.apache.hadoop/hadoop-common
try {
if (args.get(0).equals("-list")) {
return listSpanReceivers(args.subList(1, args.size()));
} else if (args.get(0).equals("-add")) {
return addSpanReceiver(args.subList(1, args.size()));
} else if (args.get(0).equals("-remove")) {
return removeSpanReceiver(args.subList(1, args.size()));
} else {
System.err.println("Unrecognized tracing command: " + args.get(0));
代码示例来源:origin: foxinmy/weixin4j
public List<Article> getArticles() {
if (articles.size() > MAX_ARTICLE_COUNT) {
return articles.subList(0, MAX_ARTICLE_COUNT);
} else {
return articles;
}
}
代码示例来源:origin: foxinmy/weixin4j
public List<MpArticle> getArticles() {
if (articles.size() > MAX_ARTICLE_COUNT) {
return articles.subList(0, MAX_ARTICLE_COUNT);
} else {
return articles;
}
}
代码示例来源:origin: INRIA/spoon
@Override
public CtPath relativePath(CtElement parent) {
List<CtElement> roots = new ArrayList<>();
roots.add(parent);
int index = 0;
for (CtPathElement pathEl : getElements()) {
if (pathEl.getElements(roots).size() > 0) {
break;
}
index++;
}
CtPathImpl result = new CtPathImpl();
result.elements = new LinkedList<>(elements.subList(index, elements.size()));
return result;
}
代码示例来源:origin: yahoo/egads
ListUtils.kernelQ(buffer, buffer.subList(0, 1), sdBuffer.subList(0, 1));
ListUtils.subtractQ(preKernelSum, preRemovedValues);
LinkedList<Float> midExchangedValues =
ListUtils.kernelQ(buffer, buffer.subList(preWindowSize, preWindowSize + 1),
sdBuffer.subList(preWindowSize, preWindowSize + 1));
ListUtils.addQ(preKernelSum, midExchangedValues);
ListUtils.maxQ(preKernelSum.subList(preWindowSize, preWindowSize + postWindowSize), eps);
LinkedList<Float> postDensity =
ListUtils.maxQ(postKernelSum.subList(preWindowSize, preWindowSize + postWindowSize), eps);
tempQ1.addAll(preKernelSum.subList(0, preWindowSize));
tempQ2.clear();
tempQ2.add(1.0F / preWindowSize);
levelThreshold =
(float) (-Math.log(levelSet) - Math.log(2 * Math.PI) / 2 - ListUtils.sumLog(sdBuffer
.subList(preWindowSize, preWindowSize + postWindowSize)) / postWindowSize);
/ postWindowSize
+ Math.log(levelSet * Math.sqrt(2 * Math.PI)) + ListUtils.sumLog(sdBuffer
.subList(preWindowSize, preWindowSize + postWindowSize)) / postWindowSize);
代码示例来源:origin: spring-projects/spring-integration
adapter.stop();
synchronized (triggerPeriods) {
assertThat(triggerPeriods.subList(0, 5), contains(10L, 12L, 11L, 12L, 11L));
代码示例来源:origin: spring-projects/spring-integration
adapter.stop();
synchronized (overridePresent) {
assertThat(overridePresent.subList(0, 5), contains(null, override, null, override, null));
代码示例来源:origin: cloudera/crunch
public NodePath splitAt(int splitIndex, PCollectionImpl<?> newHead) {
NodePath top = new NodePath();
for (int i = 0; i <= splitIndex; i++) {
top.path.add(path.get(i));
}
LinkedList<PCollectionImpl<?>> nextPath = Lists.newLinkedList();
nextPath.add(newHead);
nextPath.addAll(path.subList(splitIndex + 1, path.size()));
path = nextPath;
return top;
}
}
代码示例来源:origin: org.apache.crunch/crunch
public NodePath splitAt(int splitIndex, PCollectionImpl<?> newHead) {
NodePath top = new NodePath();
for (int i = 0; i <= splitIndex; i++) {
top.path.add(path.get(i));
}
LinkedList<PCollectionImpl<?>> nextPath = Lists.newLinkedList();
nextPath.add(newHead);
nextPath.addAll(path.subList(splitIndex + 1, path.size()));
path = nextPath;
return top;
}
内容来源于网络,如有侵权,请联系作者删除!