Refine search
public TintInfo(LinkedList<int[]> stateList, LinkedList<Integer> colorList) { if (colorList == null || stateList == null) return; mTintColors = new int[colorList.size()]; for (int i = 0; i < colorList.size(); i++) mTintColors[i] = colorList.get(i); mTintStates = stateList.toArray(new int[stateList.size()][]); }
private String[] split(String str, String splitStr) // Same as String.split(.) in JDK 1.4 { LinkedList<String> l = new LinkedList<String>(); StringTokenizer strTok = new StringTokenizer(str, splitStr); while(strTok.hasMoreTokens()) { String tok = strTok.nextToken(); l.add(tok); } return (String[])l.toArray(new String[l.size()]); }
static StackTraceElement[] trimStackTrace(StackTraceElement[] stackTrace) { LinkedList<StackTraceElement> list = Lists.newLinkedList(); for (int i = stackTrace.length - 1; i >= 0; i--) { StackTraceElement s = stackTrace[i]; if (s.getClassName().startsWith(Checkers.class.getPackage().getName())) { break; } list.addLast(s); } return list.toArray(new StackTraceElement[list.size()]); }
private static synchronized void addFieldGetter(FieldGetter fieldGetter, Integer index, boolean addLast) { checkParameter(fieldGetter); LinkedList<FieldGetter> ret = getCurrentFieldGetters(); if (index != null) { ret.add(index, fieldGetter); } else { if (addLast) { ret.addLast(fieldGetter); } else { ret.addFirst(fieldGetter); } } getters = ret.toArray(new FieldGetter[ret.size()]); }
private static X509Certificate[] createChain(X509Certificate signer, X509Certificate[] candidates) { LinkedList chain = new LinkedList(); chain.add(0, signer); // Signer is self-signed if (signer.getSubjectDN().equals(signer.getIssuerDN())){ return (X509Certificate[])chain.toArray(new X509Certificate[1]); } Principal issuer = signer.getIssuerDN(); X509Certificate issuerCert; int count = 1; while (true) { issuerCert = findCert(issuer, candidates); if( issuerCert == null) { break; } chain.add(issuerCert); count++; if (issuerCert.getSubjectDN().equals(issuerCert.getIssuerDN())) { break; } issuer = issuerCert.getIssuerDN(); } return (X509Certificate[])chain.toArray(new X509Certificate[count]); }
/** * Get a sorted List of all elements in this queue, in descending order. * * @return list of cached elements in descending order */ public CachedBlock[] get() { LinkedList<CachedBlock> blocks = new LinkedList<>(); while (!queue.isEmpty()) { blocks.addFirst(queue.poll()); } return blocks.toArray(new CachedBlock[blocks.size()]); }
LinkedList keys = new LinkedList(Arrays.asList(topCities)); keys.addFirst("Minneapolis"); assertComparatorYieldsOrder(keys.toArray(new String[0]), comparator); comparator.setUnknownObjectBehavior(FixedOrderComparator.UNKNOWN_AFTER); keys = new LinkedList(Arrays.asList(topCities)); keys.add("Minneapolis"); assertComparatorYieldsOrder(keys.toArray(new String[0]), comparator);
public static synchronized void removeFieldGetter(Class<? extends FieldGetter> fieldGetterClass) { LinkedList<FieldGetter> ret = getCurrentFieldGetters(); for (Iterator<FieldGetter> it = ret.iterator(); it.hasNext();) { if (it.next().getClass() == fieldGetterClass) { it.remove(); } } getters = ret.toArray(new FieldGetter[ret.size()]); } }
context.add(w.compiledWord + "i" + (i - index)); // 在尾巴上做个标记,不然特征冲突了 context.add(w.label + "i" + (i - index)); context.add(w.compiledWord + "j" + (i - index)); // 在尾巴上做个标记,不然特征冲突了 context.add(w.label + "j" + (i - index)); context.add(wordBeforeI.label + '@' + nodeArray[from].label + '→' + nodeArray[to].label); context.add(nodeArray[from].label + '→' + wordBeforeJ.label + '@' + nodeArray[to].label); List<Pair<String, Double>> pairList = model.predict(context.toArray(new String[0])); Pair<String, Double> maxPair = new Pair<String, Double>("null", -1.0);
/** Find a path (by name) from one node to the root or a parent. * @param node the node to start in * @param parent parent node to stop in (can be <code>null</code> for the root) * @return list of child names--i.e. a path from the parent to the child node * @exception IllegalArgumentException if <code>node</code>'s getName() * method returns <code>null</code> */ public static String[] createPath(Node node, Node parent) { LinkedList<String> ar = new LinkedList<String>(); while ((node != null) && (node != parent)) { if (node.getName() == null) { boolean isFilter = false; if (node instanceof FilterNode) { isFilter = true; } throw new IllegalArgumentException( "Node:" + node.getClass() // NOI18N +"[" + node.getDisplayName() + "]" // NOI18N +(isFilter ? (" of original:" + ((FilterNode) node).getOriginal().getClass()) : "") // NOI18N +" gets null name!" ); // NOI18N } ar.addFirst(node.getName()); node = node.getParentNode(); } String[] res = new String[ar.size()]; ar.toArray(res); return res; }
/** * 初始化官方默认 FieldGetter * * 注意: * 默认不启用 IsMethodFieldGetter,用户可以通过下面的代码启用: * Engine.addLastFieldGetter(new FieldGetters.IsMethodFieldGetter()); * * 也可以通过直接调用 target.isXxx() 方法来达到与 target.xxx 表达式相同的目的 */ private static FieldGetter[] init() { LinkedList<FieldGetter> ret = new LinkedList<FieldGetter>(); ret.addLast(new GetterMethodFieldGetter(null)); ret.addLast(new ModelFieldGetter()); ret.addLast(new RecordFieldGetter()); ret.addLast(new MapFieldGetter()); ret.addLast(new RealFieldGetter(null)); ret.addLast(new ArrayLengthGetter()); // ret.addLast(new IsMethodFieldGetter()); return ret.toArray(new FieldGetter[ret.size()]); }
/** * Write this stream to the specified channel. Call multiple times until size returns zero to make * sure all bytes in the stream have been written. * * @return the number of bytes written, possibly zero. * @throws IOException if channel is closed, not yet connected, or some other I/O error occurs. */ public int sendTo(SocketChannel chan) throws IOException { finishWriting(); if (size() == 0) { return 0; } int result; if (this.chunks != null) { ByteBuffer[] bufs = new ByteBuffer[this.chunks.size() + 1]; bufs = this.chunks.toArray(bufs); bufs[this.chunks.size()] = this.buffer; result = (int) chan.write(bufs); } else { result = chan.write(this.buffer); } this.size -= result; return result; }
private ClassNode[] makeGenericsBounds(AST rn, int boundType) { AST boundsRoot = rn.getNextSibling(); if (boundsRoot == null) return null; assertNodeType(boundType, boundsRoot); LinkedList bounds = new LinkedList(); for (AST boundsNode = boundsRoot.getFirstChild(); boundsNode != null; boundsNode = boundsNode.getNextSibling() ) { ClassNode bound = null; bound = makeTypeWithArguments(boundsNode); configureAST(bound, boundsNode); bounds.add(bound); } if (bounds.isEmpty()) return null; return (ClassNode[]) bounds.toArray(ClassNode.EMPTY_ARRAY); }
private void postProcessTemplate(Template template, LinkedList<Map<String, Template>> templateStack) { templateStack.addFirst(template.subtemplates); // 处理nodes for (Node node : template.nodes) { postProcessNode(node, templateStack); } LinkedList<Node> nodes = createLinkedList(template.nodes); chomp(nodes); trimIfNeccessary(nodes, template.params); collapseWhitespacesIfNeccessary(nodes, template.params); template.nodes = nodes.toArray(new Node[nodes.size()]); // 递归处理子模板 for (Template subTemplate : template.subtemplates.values()) { postProcessTemplate(subTemplate, templateStack); } templateStack.removeFirst(); }