@Override public Pipe<M, M> set(int index, Pipe<M, M> element) { return pipeList.set(index, element); }
@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++; }
@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); } }
/** * 合并重复标签,有问题(未排序) */ 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--; } } }
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; }
/** * 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; }
argList.set(i, "\"" + _escapeQuotesAndBackslashes(argList.get(i)) + "\"");
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) {
/** * */ @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); }
@Override protected E doSet(int index, E element) { return wrapped.set(index, element); }
public void set(int index, CharSequence item) { items.set(index - offset, item); }
/** 除去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)); } } }
/** 除去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)); } } }
/** 除去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)); } } }
/** * 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); }
@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; } } }