java.util.LinkedList.set()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(149)

本文整理了Java中java.util.LinkedList.set()方法的一些代码示例,展示了LinkedList.set()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LinkedList.set()方法的具体详情如下:
包路径:java.util.LinkedList
类名称:LinkedList
方法名:set

LinkedList.set介绍

[英]Replaces the element at the specified position in this list with the specified element.
[中]用指定的元素替换此列表中指定位置的元素。

代码示例

代码示例来源:origin: hankcs/HanLP

@Override
public Pipe<M, M> set(int index, Pipe<M, M> element)
{
  return pipeList.set(index, element);
}

代码示例来源:origin: apache/hbase

@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="VO_VOLATILE_INCREMENT",
  justification="replaceAtIndex is invoked under a synchronize block so safe")
private void replaceAtIndex(int idx, ImmutableSegment newSegment) {
 pipeline.set(idx, newSegment);
 readOnlyCopy = new LinkedList<>(pipeline);
 // the version increment is indeed needed, because the swap uses removeAll() method of the
 // linked-list that compares the objects to find what to remove.
 // The flattening changes the segment object completely (creation pattern) and so
 // swap will not proceed correctly after concurrent flattening.
 version++;
}

代码示例来源:origin: FudanNLP/fnlp

@Override
public void normalize() {
  float base = 1;
  if(scores.get(0)!=0.0f)
    base = scores.get(0)/2;
  float sum = 0;
  for(int i=0;i<scores.size();i++){
    float s  = (float) Math.exp(scores.get(i)/base);
    scores.set(i, s);
    sum +=s;
  }
  for(int i=0;i<scores.size();i++){
    float s = scores.get(i)/sum;
    scores.set(i, s);		
  }
}

代码示例来源:origin: FudanNLP/fnlp

/**
 * 合并重复标签,有问题(未排序)
 */
public void mergeDuplicate() {
  for(int i = 0; i < labels.size(); i++)
    for(int j = i + 1; j < labels.size(); j++){
      T tagi = labels.get(i);
      T tagj = labels.get(j);
      if(tagi.equals(tagj)){
        scores.set(i, scores.get(i) + scores.get(j));
        labels.remove(j);
        scores.remove(j);
        j--;
      }
    }
}

代码示例来源:origin: org.springframework.boot/spring-boot

private static List<Configurations> collate(
    List<Configurations> orderedConfigurations) {
  LinkedList<Configurations> collated = new LinkedList<>();
  for (Configurations item : orderedConfigurations) {
    if (collated.isEmpty() || collated.getLast().getClass() != item.getClass()) {
      collated.add(item);
    }
    else {
      collated.set(collated.size() - 1, collated.getLast().merge(item));
    }
  }
  return collated;
}

代码示例来源:origin: Sable/soot

pathStackIndex.set(level, new Integer(q + 1));
continue;
pathStackIndex.set(level, new Integer(p + 1));
continue;

代码示例来源:origin: apache/activemq

/**
 * Get the BitArray for the index
 *
 * @param index
 * @return BitArray
 */
private BitArray getBitArray(long index) {
  int bin = getBin(index);
  BitArray answer = null;
  if (bin >= 0) {
    if (bin >= maxNumberOfArrays) {
      int overShoot = bin - maxNumberOfArrays + 1;
      while (overShoot > 0) {
        list.removeFirst();
        longFirstIndex += BitArray.LONG_SIZE;
        list.add(new BitArray());
        overShoot--;
      }
      bin = maxNumberOfArrays - 1;
    }
    answer = list.get(bin);
    if (answer == null) {
      answer = new BitArray();
      list.set(bin, answer);
    }
  }
  return answer;
}

代码示例来源:origin: ninjaframework/ninja

argList.set(i, "\"" + _escapeQuotesAndBackslashes(argList.get(i)) + "\"");

代码示例来源:origin: debezium/debezium

protected UUIDSet(com.github.shyiko.mysql.binlog.GtidSet.UUIDSet uuidSet) {
  this.uuid = uuidSet.getUUID();
  uuidSet.getIntervals().forEach(interval -> {
    intervals.add(new Interval(interval.getStart(), interval.getEnd()));
  });
  Collections.sort(this.intervals);
  if (this.intervals.size() > 1) {
    // Collapse adjacent intervals ...
    for (int i = intervals.size() - 1; i != 0; --i) {
      Interval before = this.intervals.get(i - 1);
      Interval after = this.intervals.get(i);
      if ((before.getEnd() + 1) == after.getStart()) {
        this.intervals.set(i - 1, new Interval(before.getStart(), after.getEnd()));
        this.intervals.remove(i);
      }
    }
  }
}
protected UUIDSet(String uuid, Interval interval) {

代码示例来源:origin: apache/ignite

/**
 *
 */
@Test
public void testLinkedListWriteUnmodifiable() {
  GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer();
  LinkedList<Object> src = Lists.newLinkedList(Arrays.asList(obj, "a", "b", "c"));
  obj.foo = src;
  BinaryObjectBuilderImpl mutObj = wrap(obj);
  GridBinaryTestClasses.TestObjectContainer deserialized = mutObj.build().deserialize();
  List<Object> res = (List<Object>)deserialized.foo;
  src.set(0, deserialized);
  assertEquals(src, res);
}

代码示例来源:origin: torakiki/pdfsam

@Override
protected E doSet(int index, E element) {
  return wrapped.set(index, element);
}

代码示例来源:origin: jline/jline

public void set(int index, CharSequence item) {
  items.set(index - offset, item);
}

代码示例来源:origin: webx/citrus

/** 除去template结尾的换行。 */
private void chomp(LinkedList<Node> nodes) {
  if (!nodes.isEmpty() && nodes.getLast() instanceof Text) {
    Text node = (Text) nodes.getLast();
    String text = node.text;
    if (text.endsWith("\n")) {
      text = text.substring(0, text.length() - 1);
    }
    if (isEmpty(text)) {
      nodes.removeLast();
    } else {
      nodes.set(nodes.size() - 1, new Text(text, node.location));
    }
  }
}

代码示例来源:origin: webx/citrus

/** 除去template结尾的换行。 */
private void chomp(LinkedList<Node> nodes) {
  if (!nodes.isEmpty() && nodes.getLast() instanceof Text) {
    Text node = (Text) nodes.getLast();
    String text = node.text;
    if (text.endsWith("\n")) {
      text = text.substring(0, text.length() - 1);
    }
    if (isEmpty(text)) {
      nodes.removeLast();
    } else {
      nodes.set(nodes.size() - 1, new Text(text, node.location));
    }
  }
}

代码示例来源:origin: webx/citrus

/** 除去template结尾的换行。 */
private void chomp(LinkedList<Node> nodes) {
  if (!nodes.isEmpty() && nodes.getLast() instanceof Text) {
    Text node = (Text) nodes.getLast();
    String text = node.text;
    if (text.endsWith("\n")) {
      text = text.substring(0, text.length() - 1);
    }
    if (isEmpty(text)) {
      nodes.removeLast();
    } else {
      nodes.set(nodes.size() - 1, new Text(text, node.location));
    }
  }
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Replace the property source with the given name with the given property source object.
 * @param name the name of the property source to find and replace
 * @param propertySource the replacement property source
 * @throws IllegalArgumentException if no property source with the given name is present
 * @see #contains
 */
public void replace(String name, PropertySource<?> propertySource) {
  logger.debug(String.format("Replacing [%s] PropertySource with [%s]",
      name, propertySource.getName()));
  int index = assertPresentAndGetIndex(name);
  this.propertySourceList.set(index, propertySource);
}

代码示例来源:origin: crashub/crash

@Override
 void perform(Editor editor, EditorBuffer buffer) throws IOException {
  int nextHistoryCursor = getNext(editor);
  if (nextHistoryCursor >= -1 && nextHistoryCursor < editor.history.size()) {
   String s = nextHistoryCursor == -1 ? editor.historyBuffer : editor.history.get(nextHistoryCursor);
   while (buffer.moveRight()) {
    // Do nothing
   }
   String t = buffer.replace(s);
   if (editor.historyCursor == -1) {
    editor.historyBuffer = t;
   } else {
    editor.history.set(editor.historyCursor, t);
   }
   editor.historyCursor = nextHistoryCursor;
  }
 }
}

代码示例来源:origin: webx/citrus

nodes.removeFirst();
} else {
  nodes.set(0, new Text(text, firstNode.location));
  nodes.removeLast();
} else {
  nodes.set(nodes.size() - 1, new Text(text, lastNode.location));

代码示例来源:origin: webx/citrus

nodes.removeFirst();
} else {
  nodes.set(0, new Text(text, firstNode.location));
  nodes.removeLast();
} else {
  nodes.set(nodes.size() - 1, new Text(text, lastNode.location));

代码示例来源:origin: webx/citrus

nodes.removeFirst();
} else {
  nodes.set(0, new Text(text, firstNode.location));
  nodes.removeLast();
} else {
  nodes.set(nodes.size() - 1, new Text(text, lastNode.location));

相关文章

微信公众号

最新文章

更多