本文整理汇总了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);
}
示例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();
}
示例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()]);
}
示例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()]);
}
示例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);
}
}
示例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]);
}
示例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;
}
示例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]);
}
示例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]);
}
示例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()]);
}
示例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()]);
}
示例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()]);
}
示例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()]);
}
示例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]);
}
示例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()]);
}