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


Java HashSet.toArray方法代碼示例

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


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

示例1: setRootMethods

import java.util.HashSet; //導入方法依賴的package包/類
protected void setRootMethods(String jarFile) throws Exception {
    JarFile file = new JarFile(jarFile);
    HashSet<String> list = new HashSet(8);

    for (Enumeration<JarEntry> entries = file.entries(); entries.hasMoreElements();) {
        JarEntry entry = entries.nextElement();

        if (entry.getName().endsWith(".class")) {
            String name = entry.getName();
            int idx = name.lastIndexOf('/');
            String packageName = (idx == -1) ? name : name.substring(0, idx);
            packageName = packageName.replace('/', '.');
            list.add(packageName);
        }
    }

    ClientUtils.SourceCodeSelection[] ret = new ClientUtils.SourceCodeSelection[list.size()];
    String[] cls = list.toArray(new String[0]);

    for (int i = 0; i < list.size(); i++) {
        ret[i] = new ClientUtils.SourceCodeSelection(cls[i] + ".", "", ""); //NOI18N
    }

    settings.setInstrumentationRootMethods(ret);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:InstrumentationTest.java

示例2: getParents

import java.util.HashSet; //導入方法依賴的package包/類
/**
 * 
 */
public static Object[] getParents(mxIGraphModel model, Object[] cells) {
  HashSet<Object> parents = new HashSet<Object>();

  if (cells != null) {
    for (int i = 0; i < cells.length; i++) {
      Object parent = model.getParent(cells[i]);

      if (parent != null) {
        parents.add(parent);
      }
    }
  }

  return parents.toArray();
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:19,代碼來源:mxGraphModel.java

示例3: getReaderWriterInfo

import java.util.HashSet; //導入方法依賴的package包/類
private static <S extends ImageReaderWriterSpi>
    String[] getReaderWriterInfo(Class<S> spiClass, SpiInfo spiInfo)
{
    // Ensure category is present
    Iterator<S> iter;
    try {
        iter = theRegistry.getServiceProviders(spiClass, true);
    } catch (IllegalArgumentException e) {
        return new String[0];
    }

    HashSet<String> s = new HashSet<>();
    while (iter.hasNext()) {
        ImageReaderWriterSpi spi = iter.next();
        String[] info = spiInfo.info(spi);
        if (info != null) {
            Collections.addAll(s, info);
        }
    }

    return s.toArray(new String[s.size()]);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:ImageIO.java

示例4: findPaths

import java.util.HashSet; //導入方法依賴的package包/類
/**
 * Finds all paths from the specified start vertices to the vertices fullfilling the specified condition.
 *
 * @param graph
 *            Complete graph.
 * @return All vertices including start and end vertices defining the subgraph with all paths.
 */
public AtomicVertex[] findPaths(AtomicVertex[] graph) {
    prepareGraph(graph);
    final HashSet<Vertex> pathVertices = new HashSet<>();
    final HashSet<AtomicVertex> currentPath = new HashSet<>();
    for (int i = 0; i < graph.length; i++) {
        final AtomicVertex vertex = graph[i];
        if (startSetCondition.isFulfilled(vertex)) {
            if (directPathsOnly) {
                findDirectPaths(vertex, pathVertices);
            } else {
                prepareIfFinal(vertex);
                final int pathLength = calculateShortestPath(vertex, currentPath);
                if (pathLength < Integer.MAX_VALUE) {
                    vertex.setOrder(pathLength);
                    followPaths(vertex, pathVertices);
                }
            }
        }
    }
    return pathVertices.toArray(new AtomicVertex[pathVertices.size()]);
}
 
開發者ID:sake92,項目名稱:hepek-classycle,代碼行數:29,代碼來源:PathsFinder.java

示例5: getDefaultFactory

import java.util.HashSet; //導入方法依賴的package包/類
/**
 * Returns an implementation of a {@code ProviderFactory} which
 * creates instances of Providers.
 *
 * The created Provider instances will be linked to all appropriate
 * and enabled system-defined tracing mechanisms in the JDK.
 *
 * @return a {@code ProviderFactory} that is used to create Providers.
 */
public static ProviderFactory getDefaultFactory() {
    HashSet<ProviderFactory> factories = new HashSet<ProviderFactory>();

    // Try to instantiate a DTraceProviderFactory
    String prop = AccessController.doPrivileged(
        new GetPropertyAction("com.sun.tracing.dtrace"));

    if ( (prop == null || !prop.equals("disable")) &&
         DTraceProviderFactory.isSupported() ) {
        factories.add(new DTraceProviderFactory());
    }

    // Try to instantiate an output stream factory
    prop = AccessController.doPrivileged(
        new GetPropertyAction("sun.tracing.stream"));
    if (prop != null) {
        for (String spec : prop.split(",")) {
            PrintStream ps = getPrintStreamFromSpec(spec);
            if (ps != null) {
                factories.add(new PrintStreamProviderFactory(ps));
            }
        }
    }

    // See how many factories we instantiated, and return an appropriate
    // factory that encapsulates that.
    if (factories.size() == 0) {
        return new NullProviderFactory();
    } else if (factories.size() == 1) {
        return factories.toArray(new ProviderFactory[1])[0];
    } else {
        return new MultiplexProviderFactory(factories);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:44,代碼來源:ProviderFactory.java

示例6: getAllFamilyNames

import java.util.HashSet; //導入方法依賴的package包/類
String[] getAllFamilyNames() {
    HashSet<String> aSet = new HashSet<>();
    try {
        initAllNames(FAMILY_NAME_ID, aSet);
    } catch (Exception e) {
        /* In case of malformed font */
    }
    return aSet.toArray(new String[0]);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:TrueTypeFont.java

示例7: sortPoints

import java.util.HashSet; //導入方法依賴的package包/類
private Point[] sortPoints(Point[] p) {
    //Prune duplicates
    HashSet<Point> set = new HashSet<Point>(Arrays.asList(p));
    p = new Point[set.size()];
    p = set.toArray(p);
    //Then sort
    Arrays.sort(p, comparator);
    return p;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:EqualPolygon.java

示例8: getPlatformFontNames

import java.util.HashSet; //導入方法依賴的package包/類
@Override
public String[] getPlatformFontNames() {
    HashSet<String> nameSet = new HashSet<String>();
    X11FontManager fm = (X11FontManager) fontManager;
    FontConfigManager fcm = fm.getFontConfigManager();
    FcCompFont[] fcCompFonts = fcm.loadFontConfig();
    for (int i=0; i<fcCompFonts.length; i++) {
        for (int j=0; j<fcCompFonts[i].allFonts.length; j++) {
            nameSet.add(fcCompFonts[i].allFonts[j].fontFile);
        }
    }
    return nameSet.toArray(new String[0]);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:14,代碼來源:FcFontConfiguration.java

示例9: compilerFlags

import java.util.HashSet; //導入方法依賴的package包/類
public Compiler.Flags[] compilerFlags() {
    HashSet<Compiler.Flags> flags = new HashSet<>();
    if (verboseLocal.get() == Boolean.TRUE) {
        flags.add(Compiler.Flags.VERBOSE);
    }
    if (this.canUseCompilerCache) {
        flags.add(Compiler.Flags.USECACHE);
    }
    return flags.toArray(new Compiler.Flags[0]);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:TestHarness.java

示例10: setRequestedPermissions

import java.util.HashSet; //導入方法依賴的package包/類
private void setRequestedPermissions(Object[][] permissions, int minSdk) {
    HashSet<String> set = new HashSet<>();
    for (Object[] versions : permissions) {
        int maxSdk = Integer.MAX_VALUE;
        if (versions[1] != null) {
            maxSdk = (int) versions[1];
        }
        if (minSdk <= Build.VERSION.SDK_INT && Build.VERSION.SDK_INT <= maxSdk) {
            set.add((String) versions[0]);
        }
    }
    requestedPermissions = set.toArray(new String[set.size()]);
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:14,代碼來源:Apk.java

示例11: extractTransportAddresses

import java.util.HashSet; //導入方法依賴的package包/類
public static TransportAddress[] extractTransportAddresses(TransportService transportService) {
    HashSet<TransportAddress> transportAddresses = new HashSet<>();
    BoundTransportAddress boundTransportAddress = transportService.boundAddress();
    transportAddresses.addAll(Arrays.asList(boundTransportAddress.boundAddresses()));
    transportAddresses.add(boundTransportAddress.publishAddress());
    return transportAddresses.toArray(new TransportAddress[transportAddresses.size()]);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:8,代碼來源:MockTransportService.java

示例12: getLocations

import java.util.HashSet; //導入方法依賴的package包/類
public String[] getLocations() throws IOException {
  HashSet<String> hostSet = new HashSet<String>();
  for (Path file : getPaths()) {
    FileSystem fs = file.getFileSystem(getJob());
    FileStatus status = fs.getFileStatus(file);
    BlockLocation[] blkLocations = fs.getFileBlockLocations(status,
                                        0, status.getLen());
    if (blkLocations != null && blkLocations.length > 0) {
      addToSet(hostSet, blkLocations[0].getHosts());
    }
  }
  return hostSet.toArray(new String[hostSet.size()]);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:14,代碼來源:MultiFileSplit.java

示例13: calcType2

import java.util.HashSet; //導入方法依賴的package包/類
private Integer[] calcType2(long begin, long end) {
    HashSet<Integer> ids = new HashSet<>();

    calcAux(ids, begin, patternValue);
    calcAux(ids, 0, end);

    return ids.toArray(new Integer[ids.size()]);
}
 
開發者ID:actiontech,項目名稱:dble,代碼行數:9,代碼來源:PartitionByPattern.java

示例14: getAllFullNames

import java.util.HashSet; //導入方法依賴的package包/類
String[] getAllFullNames() {
    HashSet aSet = new HashSet();
    try {
        initAllNames(FULL_NAME_ID, aSet);
    } catch (Exception e) {
        /* In case of malformed font */
    }
    return (String[])aSet.toArray(new String[0]);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:10,代碼來源:TrueTypeFont.java

示例15: getLocations

import java.util.HashSet; //導入方法依賴的package包/類
/**
 * Collect a set of hosts from all child InputSplits.
 */
public String[] getLocations() throws IOException {
  HashSet<String> hosts = new HashSet<String>();
  for (InputSplit s : splits) {
    String[] hints = s.getLocations();
    if (hints != null && hints.length > 0) {
      for (String host : hints) {
        hosts.add(host);
      }
    }
  }
  return hosts.toArray(new String[hosts.size()]);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:16,代碼來源:CompositeInputSplit.java


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