当前位置: 首页>>代码示例>>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;未经允许,请勿转载。