當前位置: 首頁>>代碼示例>>Java>>正文


Java LinkedList.toArray方法代碼示例

本文整理匯總了Java中java.util.LinkedList.toArray方法的典型用法代碼示例。如果您正苦於以下問題:Java LinkedList.toArray方法的具體用法?Java LinkedList.toArray怎麽用?Java LinkedList.toArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.LinkedList的用法示例。


在下文中一共展示了LinkedList.toArray方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initTransformer

import java.util.LinkedList; //導入方法依賴的package包/類
/**
 * 初始化類字節碼的轉換器
 *
 * @param inst 用於管理字節碼轉換器
 */
private static void initTransformer(Instrumentation inst) throws UnmodifiableClassException {
    LinkedList<Class> retransformClasses = new LinkedList<Class>();
    CustomClassTransformer customClassTransformer = new CustomClassTransformer();
    inst.addTransformer(customClassTransformer, true);
    Class[] loadedClasses = inst.getAllLoadedClasses();
    for (Class clazz : loadedClasses) {
        for (final AbstractClassHook hook : customClassTransformer.getHooks()) {
            if (hook.isClassMatched(clazz.getName().replace(".", "/"))) {
                if (inst.isModifiableClass(clazz) && !clazz.getName().startsWith("java.lang.invoke.LambdaForm")) {
                    retransformClasses.add(clazz);
                }
            }
        }
    }
    // hook已經加載的類
    Class[] classes = new Class[retransformClasses.size()];
    retransformClasses.toArray(classes);
    if (classes.length > 0) {
        inst.retransformClasses(classes);
    }
}
 
開發者ID:baidu,項目名稱:openrasp,代碼行數:27,代碼來源:Agent.java

示例2: getSlotIndexs

import java.util.LinkedList; //導入方法依賴的package包/類
public String[] getSlotIndexs(ConsoleAccess telnet) throws IOException,
        AbortedException {
    StringTokenizer st = this.getResults(telnet, "show slot");
    Matcher matcher;
    LinkedList<String> slotList = new LinkedList<String>();

    while (st.hasMoreTokens()) {
        matcher = slotIndexPattern.matcher(st.nextToken());
        if (matcher.matches()) {
            slotList.add(matcher.group(1));
        }
    }
    if (slotList.size() == 0)
        return (new String[0]);
    return slotList.toArray(new String[0]);
}
 
開發者ID:openNaEF,項目名稱:openNaEF,代碼行數:17,代碼來源:SuperHubTelnetUtil.java

示例3: getFields

import java.util.LinkedList; //導入方法依賴的package包/類
public static String[] getFields(String line, char separator)
{
    if(line != null && !line.equals(""))
    {
        StringBuffer field = new StringBuffer();
        LinkedList fieldArr = new LinkedList();
        for(int i = 0; i < line.length(); i++)
        {
            char ch = line.charAt(i);
            if(ch == separator)
            {
                fieldArr.add(field.toString().trim());
                field = new StringBuffer();
            } else
            {
                field.append(ch);
            }
        }

        fieldArr.add(field.toString().trim());
        return (String[])fieldArr.toArray(new String[fieldArr.size()]);
    } else
    {
        return new String[0];
    }
}
 
開發者ID:DatabaseGroup,項目名稱:apted,代碼行數:27,代碼來源:FormatUtilities.java

示例4: fixEnum

import java.util.LinkedList; //導入方法依賴的package包/類
/**
 * Decodes a javax.naming.NamingEnumeration.
 * Java's NamingEnumeration is a kludge: it holds a list
 * and a hidden exception waiting to be thrown after the last
 * list element is retrieved.  But there's no way to discover
 * the hidden exception without retrieving all the list elements.
 */

private ArrayExc fixEnum( NamingEnumeration enumeration) {
	LinkedList lst = new LinkedList();
	Exception hiddenExc = null;

	try {		// catch the hidden exception
		while (enumeration.hasMore()) {
			lst.add( enumeration.next());
		}
	}
	catch( NamingException nex) {
		hiddenExc = nex;
	}
	Object[] vals = lst.toArray();
	return new ArrayExc( vals, hiddenExc);
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:24,代碼來源:LdapClient.java

示例5: main

import java.util.LinkedList; //導入方法依賴的package包/類
public static void main(String[] args)
{
   String[] colors = {"black", "blue", "yellow"};
   LinkedList<String> links = new LinkedList<>(Arrays.asList(colors));

   links.addLast("red"); // add as last item
   links.add("pink"); // add to the end
   links.add(3, "green"); // add at 3rd index
   links.addFirst("cyan"); // add as first item      

   // get LinkedList elements as an array     
   colors = links.toArray(new String[links.size()]);

   System.out.println("colors: ");

   for (String color : colors)
      System.out.println(color);
}
 
開發者ID:cleitonferreira,項目名稱:LivroJavaComoProgramar10Edicao,代碼行數:19,代碼來源:UsingToArray.java

示例6: readArrayLengthDataProvider

import java.util.LinkedList; //導入方法依賴的package包/類
@DataProvider(name = "readArrayLengthDataProvider")
public static Object[][] readArrayLengthDataProvider() {
    LinkedList<Object[]> cfgSet = new LinkedList<>();
    for (int i : new int[]{0, 1, 42}) {
        createListOfDummyArrays(i).stream().forEach((array) -> {
            cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(array), i});
        });
    }
    cfgSet.add(new Object[]{null, null});
    cfgSet.add(new Object[]{JavaConstant.NULL_POINTER, null});
    cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.intField), null});
    cfgSet.add(new Object[]{JavaConstant.forInt(DUMMY_CLASS_INSTANCE.intField), null});
    return cfgSet.toArray(new Object[0][0]);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:ReadArrayLengthDataProvider.java

示例7: getNames

import java.util.LinkedList; //導入方法依賴的package包/類
public static synchronized String[] getNames() {
    if (names == null) {
        LinkedList<String> list = new LinkedList<String>();
        InputStream str
            = PlatformClasses.class
                .getResourceAsStream("/com/sun/tools/hat/resources/platform_names.txt");
        if (str != null) {
            try {
                BufferedReader rdr
                    = new BufferedReader(new InputStreamReader(str));
                for (;;) {
                    String s = rdr.readLine();
                    if (s == null) {
                        break;
                    } else if (s.length() > 0) {
                        list.add(s);
                    }
                }
                rdr.close();
                str.close();
            } catch (IOException ex) {
                ex.printStackTrace();
                // Shouldn't happen, and if it does, continuing
                // is the right thing to do anyway.
            }
        }
        names = list.toArray(new String[list.size()]);
    }
    return names;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:31,代碼來源:PlatformClasses.java

示例8: testToArray1_BadArg

import java.util.LinkedList; //導入方法依賴的package包/類
/**
 * toArray(incompatible array type) throws ArrayStoreException
 */
public void testToArray1_BadArg() {
    LinkedList l = new LinkedList();
    l.add(new Integer(5));
    try {
        l.toArray(new String[10]);
        shouldThrow();
    } catch (ArrayStoreException success) {}
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:12,代碼來源:LinkedListTest.java

示例9: findMethodsByExactParameters

import java.util.LinkedList; //導入方法依賴的package包/類
/**
 * Returns an array of all methods declared/overridden in a class with the specified parameter types.
 * <p>
 * <p>The return type is optional, it will not be compared if it is {@code null}.
 * Use {@code void.class} if you want to search for methods returning nothing.
 *
 * @param clazz          The class to look in.
 * @param returnType     The return type, or {@code null} (see above).
 * @param parameterTypes The parameter types.
 * @return An array with matching methods, all set to accessible already.
 */
public static Method[] findMethodsByExactParameters(final Class<?> clazz, final Class<?> returnType,
                                                    final Class<?>... parameterTypes) {
    final LinkedList<Method> result = new LinkedList<>();
    for (final Method method : clazz.getDeclaredMethods()) {
        if (returnType != null && returnType != method.getReturnType())
            continue;

        final Class<?>[] methodParameterTypes = method.getParameterTypes();
        if (parameterTypes.length != methodParameterTypes.length)
            continue;

        boolean match = true;
        for (int i = 0; i < parameterTypes.length; ++i) {
            if (parameterTypes[i] != methodParameterTypes[i]) {
                match = false;
                break;
            }
        }

        if (!match)
            continue;

        method.setAccessible(true);
        result.add(method);
    }
    return result.toArray(new Method[result.size()]);
}
 
開發者ID:rrrfff,項目名稱:AndHook,代碼行數:39,代碼來源:XposedHelpers.java

示例10: getTriangles

import java.util.LinkedList; //導入方法依賴的package包/類
public Polygon[] getTriangles() {
    LinkedList<Polygon> polygons = new LinkedList<>();

    int[] indices1 = getXTriangles();
    int[] indices2 = getYTriangles();
    int[] indices3 = getZTriangles();

    int[] xPoints = getXVertices();
    int[] yPoints = getYVertices();
    int[] zPoints = getZVertices();

    int len = indices1.length;

    for (int i = 0; i < len; ++i) {
        Point p1 = Calculations.tileToCanvas(gridX + xPoints[indices1[i]], gridY + zPoints[indices1[i]],
                -yPoints[indices1[i]] + z);
        Point p2 = Calculations.tileToCanvas(gridX + xPoints[indices2[i]], gridY + zPoints[indices2[i]],
                -yPoints[indices2[i]] + z);
        Point p3 = Calculations.tileToCanvas(gridX + xPoints[indices3[i]], gridY + zPoints[indices3[i]],
                -yPoints[indices3[i]] + z);
        if (p1 != null && p2 != null && p3 != null) {
            if (p1.x >= 0 && p2.x >= 0 && p3.x >= 0) {
                polygons.add(new Polygon(new int[]{ p1.x, p2.x, p3.x }, new int[]{ p1.y, p2.y, p3.y }, 3));
            }
        }
    }

    return polygons.toArray(new Polygon[polygons.size()]);
}
 
開發者ID:Parabot,項目名稱:Parabot-317-API-Minified-OS-Scape,代碼行數:30,代碼來源:Model.java

示例11: getEditorCookies

import java.util.LinkedList; //導入方法依賴的package包/類
/**
 * Returns editor cookies available for modified and not open files in the commit table
 * @return
 */
@Override
protected EditorCookie[] getEditorCookies () {
    LinkedList<EditorCookie> allCookies = new LinkedList<EditorCookie>();
    if (controller != null) {
        EditorCookie[] cookies = controller.getEditorCookies(true);
        if (cookies.length > 0) {
            allCookies.add(cookies[0]);
        }
    }
    return allCookies.toArray(new EditorCookie[allCookies.size()]);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:GitCommitPanel.java

示例12: getSickKind

import java.util.LinkedList; //導入方法依賴的package包/類
public String[] getSickKind() {
	LinkedList<String> temp=new LinkedList<>();
	for(String name:sickKind.keySet())
		temp.add(name);
	if(temp.size()==0)
		return null;
	return (String[])temp.toArray(new String[temp.size()]);
}
 
開發者ID:SchoolUniform,項目名稱:RealSurvival,代碼行數:9,代碼來源:PlayerData.java

示例13: getEditorCookies

import java.util.LinkedList; //導入方法依賴的package包/類
/**
 * Returns editor cookies available for modified and not open files in the commit table
 * @return
 */
EditorCookie[] getEditorCookies() {
    LinkedList<EditorCookie> allCookies = new LinkedList<EditorCookie>();
    for (Map.Entry<File, MultiDiffPanel> e : displayedDiffs.entrySet()) {
        EditorCookie[] cookies = e.getValue().getEditorCookies(true);
        if (cookies.length > 0) {
            allCookies.add(cookies[0]);
        }
    }
    return allCookies.toArray(new EditorCookie[allCookies.size()]);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:CommitPanel.java

示例14: validate

import java.util.LinkedList; //導入方法依賴的package包/類
/**
 * Overall validation
 * @param value Value to validate
 * @throws OverallValidationException If validation fails
 */
protected void validate(PropertyBox value) throws OverallValidationException {

	LinkedList<ValidationException> failures = new LinkedList<>();
	for (Validator<PropertyBox> validator : getValidators()) {
		try {
			validator.validate(value);
		} catch (ValidationException ve) {
			failures.add(ve);
			if (isStopOverallValidationAtFirstFailure()) {
				break;
			}
		}
	}

	// collect validation exceptions, if any
	if (!failures.isEmpty()) {

		OverallValidationException validationException = (failures.size() == 1)
				? new OverallValidationException(failures.getFirst().getMessage(),
						failures.getFirst().getMessageCode(), failures.getFirst().getMessageArguments())
				: new OverallValidationException(failures.toArray(new ValidationException[failures.size()]));

		// notify validation status
		notifyInvalidValidationStatus(validationException, getOverallValueComponent().orElse(null), null);

		throw validationException;
	}

	// notify validation status
	notifyValidValidationStatus(getOverallValueComponent().orElse(null), null);
}
 
開發者ID:holon-platform,項目名稱:holon-vaadin7,代碼行數:37,代碼來源:DefaultPropertyInputGroup.java

示例15: getDrivers

import java.util.LinkedList; //導入方法依賴的package包/類
/**
 * Gets the registered JDBC drivers with the specified class name.
 *
 * @param drvClass driver class name; must not be null.
 *
 * @return a non-null array of JDBCDriver instances with the specified class name.
 *
 * @throws NullPointerException if the specified class name is null.
 */
public JDBCDriver[] getDrivers(String drvClass) {
    if (drvClass == null) {
        throw new NullPointerException();
    }
    LinkedList<JDBCDriver> res = new LinkedList<>();
    JDBCDriver[] drvs = getDrivers();
    for (int i = 0; i < drvs.length; i++) {
        if (drvClass.equals(drvs[i].getClassName())) {
            res.add(drvs[i]);
        }
    }
    return res.toArray (new JDBCDriver[res.size ()]);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:JDBCDriverManager.java


注:本文中的java.util.LinkedList.toArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。